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

ConfigConfigTest

public final class ConfigConfigTest extends com.sun.enterprise.management.AMXTestBase implements com.sun.enterprise.management.MultipleServerSupportRequired

Fields Summary
Constructors Summary
public ConfigConfigTest()

	    if ( checkNotOffline( "ensureDefaultInstance" ) )
	    {
	        ensureDefaultInstance( getDomainRoot() );
	    }

	
Methods Summary
private com.sun.appserv.management.config.ConfigConfigcreate(java.lang.String name)

        final ConfigSetup setup  = new ConfigSetup( getDomainRoot() );
        
        setup.removeConfig( name );
        
        final ConfigConfig  config  = setup.createConfig( name );
        assert( name.equals( config.getName() ) );
        
        // see that it responds to a request
        final Map<String,Object>    attrs   = Util.getExtra( config ).getAllAttributes();
        //printVerbose( "Attributes for config " + config.getName() + ":" );
        //printVerbose( MapUtil.toString( attrs, NEWLINE ) );
    
        return config;
	
public static com.sun.appserv.management.config.ConfigConfigensureDefaultInstance(com.sun.appserv.management.DomainRoot domainRoot)

        ConfigConfig   config   = null;
        
        final DomainConfig  domainConfig    = domainRoot.getDomainConfig();
        final Map<String,ConfigConfig>  existing  = domainConfig.getConfigConfigMap();
        
        if ( supportsMultipleServers( domainRoot ) )
        {
            config = existing.get( getDefaultInstanceName( domainRoot ) );
            if ( config == null )
            {
                final ConfigSetup setup  = new ConfigSetup( domainRoot );
                config  = setup.createConfig( getDefaultInstanceName( domainRoot ) );
            }
        }
        else
        {
            config = existing.get( PE_CONFIG_NAME );
            assert( config != null ) : "No config named " + StringUtil.quote( PE_CONFIG_NAME );
        }
        return config;
	
public static java.lang.StringgetDefaultInstanceName(com.sun.appserv.management.DomainRoot domainRoot)

        String  name    = null;
        
        if ( domainRoot.getSystemInfo().supportsFeature( SystemInfo.MULTIPLE_SERVERS_FEATURE ) )
        {
            name    = getDefaultInstanceName( "ConfigConfigTest" );
        }
        else
        {
            name = PE_CONFIG_NAME;
        }
        return name;
    
public voidtestCreateRemove()

	    if ( ! checkNotOffline( "testCreateRemove" ) )
	    {
	        return;
	    }
	    
        final String NAME    = "ConfigConfigTest.testCreateRemove";
        
        final Map<String,ConfigConfig>  before  = getDomainConfig().getConfigConfigMap();
        
        final int   NUM = 2;
        final ConfigConfig[]    configs = new ConfigConfig[ NUM ];
        
        for( int i = 0; i < NUM; ++i )
        {
	        configs[ i ]    = create( NAME + i );
	    }
	    
        final ConfigSetup setup  = new ConfigSetup( getDomainRoot() );
        for( final ConfigConfig config : configs )
        {
            setup.removeConfig( config.getName() );
            
            // verify that the config is gone
            try
            {
                Util.getExtra( config ).getAllAttributes();
                fail( "Config " + config.getName() + " should no longer exist" );
            }
            catch( Exception e )
            {
                // good, we expected to be here
            }
	    }
	    
        final Map<String,ConfigConfig>  after  = getDomainConfig().getConfigConfigMap();
        assert( before.keySet().equals( after.keySet() ) );