MiscTest.javaAPI DocGlassfish v2 API5704Fri May 04 22:23:54 BST


public final class MiscTest extends

Fields Summary
Constructors Summary
public MiscTest()

Methods Summary
public static

	    return getOfflineCapableCapabilities( true );
public voidtestMBeanInfo()

	    final MBeanInfo info    = new MBeanInfo(
	        null );
	    assert( info.getNotifications() != null );
	    assert( info.getOperations() != null );
	    assert( info.getAttributes() != null );
	    assert( info.getConstructors() != null );
public voidtestProxyDetectsMBeanRemoved()
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() );
			// all calls should fail
			Util.getObjectName( ns );
			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 ) );