FileDocCategorySizeDatePackage
ConfigMgrTestBase.javaAPI DocGlassfish v2 API8323Fri May 04 22:23:54 BST 2007com.sun.enterprise.management.config

ConfigMgrTestBase

public abstract class ConfigMgrTestBase extends com.sun.enterprise.management.AMXTestBase

Fields Summary
protected static final Map
ILLEGAL_OPTIONS
Constructors Summary
protected ConfigMgrTestBase()

		super();
	
Methods Summary
protected abstract com.sun.appserv.management.config.AMXConfigcreateProgeny(java.lang.String name, java.util.Map options)

public com.sun.appserv.management.config.AMXConfiggetProgeny(java.lang.String name)

		final Container	container	= getProgenyContainer();
		final String			progenyType	= getProgenyJ2EEType();
		
		//trace( "getProgeny: " + progenyType + "=" + name );
		final Object	progeny	= container.getContainee( progenyType, name );
		
		if ( progeny != null && ! (progeny instanceof AMXConfig) )
		{
			assert( progeny instanceof AMX );
			failure(
				"getProgeny: " + progenyType + "=" + name + " not an AMXConfig, interface = " +
				Util.getExtra( Util.asAMX(progeny )).getInterfaceName() );
		}
		
		return( (AMXConfig)progeny );
	
protected abstract com.sun.appserv.management.base.ContainergetProgenyContainer()

protected abstract java.lang.StringgetProgenyJ2EEType()

protected java.lang.StringgetProgenyTestName()

		return( "test-" + ClassUtil.stripPackageName( this.getClass().getName() ) );
	
protected voidremove(java.lang.String name)

		removeProgeny( name );
	
voidremoveEx(java.lang.String name)

		final AMX	proxy	= getProgeny( name );
		if ( proxy != null )
		{
			assert( proxy.getName().equals( name )  );
			final ObjectName	objectName	= Util.getObjectName( proxy );
			
		    try
		    {
		    	remove(name);
		    
			    final MBeanServerConnection	conn	= getConnection();
			    while ( conn.isRegistered( objectName ) )
			    {
			    	trace( "waiting for mbean to be unregistered: " + objectName );
			    }
		    }
		    catch(Exception e)
		    {
		    	trace( "error removing MBean: " +
		    		objectName + " = " + ExceptionUtil.getRootCause( e ).getMessage() );
		    }
	    }
	    else
	    {
	    	// trace( "ConfigMgrTestBase.removeEx: " + name + " does not exist." );
	    }
	
protected abstract voidremoveProgeny(java.lang.String name)

public final synchronized voidtestCreateRemove()

	    if ( ! checkNotOffline( "testCreateRemove" ) )
	    {
	        return;
	    }
	    
		final long	start	= now();
		
		String	name	= getProgenyTestName();
		
		final String	progenyJ2EEType	= getProgenyJ2EEType();
		
		AMXConfig	proxy	= getProgeny( name );
		if ( proxy != null )
		{
			final ObjectName	objectName	= Util.getExtra( proxy ).getObjectName();
			remove( name );
	   		waitUnregistered( objectName );
	   		assert( ! getConnection().isRegistered( objectName ) );
			assert( getProgeny( name ) == null );
			proxy	= null;
		}
		
		final Container	container	= getProgenyContainer();
		final CreateRemoveListener		listener	=
			new CreateRemoveListener( container, progenyJ2EEType, name );
		
		// create it
		try
		{
	        proxy = createProgeny( name, null );
	    }
	    catch( Exception e )
	    {
	        trace( getStackTrace( ExceptionUtil.getRootCause(e) ) );
	        failure( "Can't create item of j2eeType=" + progenyJ2EEType +
	            ",name=" + name );
	    }
	    assert( proxy.getName().equals( name ) );
		final ObjectName	objectName	= Util.getObjectName( proxy );
	    assert( getConnection().isRegistered( objectName ) );
	    assert( container.getContainee( progenyJ2EEType, name)  != null  );
	    assert( container.getContainee( progenyJ2EEType, name)  == proxy  );
	    final AMXConfig	progeny	= getProgeny( name );
	    assert( progeny == proxy );

		// remove it
		final ProxyFactory	factory	= Util.getExtra( proxy ).getProxyFactory();
		assert( name.equals( progeny.getName() ) );
	    remove( name );
	    waitUnregistered( objectName );
	    assert( ! getConnection().isRegistered( objectName ) );
	    waitProxyGone( factory, objectName );
		assert( getProgeny( name ) == null );
		
		listener.waitNotifs();
		
		printElapsed( "testCreateRemove: created/remove/listen for: " + progenyJ2EEType, start );
	
public final synchronized voidtestIllegalCreate()

	
		   
	 
		 
	
	    if ( ! checkNotOffline( "testIllegalCreate" ) )
	    {
	        return;
	    }
	    
		final String	name	= getProgenyTestName() + "-Illegal";
		
		try
		{
	    	final AMXConfig	proxy = createProgeny( name, ILLEGAL_OPTIONS );
	    	fail( "Expecting failure from createProgenyIllegal for progeny type: " + getProgenyJ2EEType() );
	    }
	    catch( final Exception e )
	    {
	    	final Throwable rootCause	= ExceptionUtil.getRootCause( e );
	    	if ( ! ( rootCause instanceof IllegalArgumentException ) )
	    	{
	    		warning( "expecting IllegalArgumentException, got: " + rootCause.getClass().getName() +
	    		", msg = " + rootCause.getMessage() );
	    		rootCause.printStackTrace();
	    	}
	    }
        catch( final Throwable t )
        {
	    	final Throwable rootCause	= ExceptionUtil.getRootCause( t );
            warning( "expecting IllegalArgumentException, got: " +  ExceptionUtil.toString(rootCause) );
            assert false;
        }