MiscTestpublic final class MiscTest extends com.sun.enterprise.management.AMXTestBase
Constructors Summary |
---|
public MiscTest()
|
Methods Summary |
---|
public static com.sun.enterprise.management.Capabilities | getCapabilities()
return getOfflineCapableCapabilities( true );
| public void | testMBeanInfo()
final MBeanInfo info = new MBeanInfo(
"foo.bar",
null,
null,
null,
null,
null );
assert( info.getNotifications() != null );
assert( info.getOperations() != null );
assert( info.getAttributes() != null );
assert( info.getConstructors() != null );
| public void | testProxyDetectsMBeanRemoved()Verify that when an MBean is removed, the proxy
throws an InstanceNotFoundException. This test is included here because
it otherwise causes problems when running other unit tests that want to operate
on all MBeans--this test creates and removes one, which causes the other
tests to fail.
// use the NotificationServiceMgr as a convenient way of making
// an MBean (a NotificationService) come and go.
final NotificationServiceMgr mgr = getDomainRoot().getNotificationServiceMgr();
final NotificationService ns = mgr.createNotificationService( "UserData", 10 );
assert( ns.getUserData().equals( "UserData" ) );
final ObjectName nsObjectName = Util.getObjectName( ns );
mgr.removeNotificationService( ns.getName() );
try
{
// all calls should fail
Util.getObjectName( ns );
ns.getName();
ns.getUserData();
failure( "expecting exception due to missing MBean" );
}
catch( Exception e )
{
// root cause should be an InstanceNotFoundException containing the ObjectName
final Throwable t = ExceptionUtil.getRootCause( e );
assert( t instanceof InstanceNotFoundException );
final InstanceNotFoundException inf = (InstanceNotFoundException)t;
final String msg = inf.getMessage();
final int objectNameStart = msg.indexOf( "amx:" );
final String objectNameString = msg.substring( objectNameStart, msg.length() );
final ObjectName on = Util.newObjectName( objectNameString );
assert( on.equals( nsObjectName ) );
}
|
|