FileDocCategorySizeDatePackage
StandaloneServerConfigTest.javaAPI DocGlassfish v2 API6679Fri May 04 22:23:56 BST 2007com.sun.enterprise.management.config

StandaloneServerConfigTest

public final class StandaloneServerConfigTest extends com.sun.enterprise.management.AMXTestBase

Fields Summary
Constructors Summary
public StandaloneServerConfigTest()

	    if ( checkNotOffline( "ensureDefaultInstance" ) )
	    {
	        ensureDefaultInstance( getDomainRoot() );
	    }
	
Methods Summary
private void_testCreateStandaloneServerConfig(java.lang.String serverNameSuffix, int basePort)

        final ConfigSetup setup  = new ConfigSetup( getDomainRoot() );
        
        final Map<String,NodeAgentConfig> nodeAgentConfigs    = getDomainConfig().getNodeAgentConfigMap();
        
        if ( nodeAgentConfigs.keySet().size() == 0 )
        {
            warning( "testCreateStandaloneServerConfig: No node agents available, skipping test." );
        }
        else
        {
            // create a server for each node agent
            for( final String nodeAgentName : nodeAgentConfigs.keySet() )
            {
                final String serverName    = nodeAgentName + serverNameSuffix;
                final String configName    = serverName + "-config";
                
                // in case a previous failed run left them around
                setup.removeServer( serverName );
                setup.removeConfig( configName );
                
                final ConfigConfig  config  = setup.createConfig( configName );
                assert( configName.equals( config.getName() ) );
                
                // sanity check
                final Map<String,Object>    attrs   = Util.getExtra( config ).getAllAttributes();
                
                try
                {
                    final StandaloneServerConfig  server =
                        setup.createServer( serverName, basePort, nodeAgentName, config.getName() );
                    // it worked, get rid of it
                    setup.removeServer( server.getName() );
                }
                catch( Throwable t)
                {
                    assert false : ExceptionUtil.toString( t );
                }
                finally
                {
                    try
                    {
                        setup.removeConfig( config.getName() );
                    }
                    catch( Exception ee )
                    {
                        // we wanted to get rid of it...oh well.
                    }
                }
            }
        }
	
public static com.sun.appserv.management.config.StandaloneServerConfigensureDefaultInstance(com.sun.appserv.management.DomainRoot domainRoot)
We want the default instance to be available on both PE and EE so we have no choice but to use the DAS instance.

	    final Map<String,StandaloneServerConfig>    servers =
	        domainRoot.getDomainConfig().getStandaloneServerConfigMap();
	    
	    StandaloneServerConfig  server  = servers.get( getDefaultInstanceName() );
	    assert( server != null );
	    
	    return server;
	
public static com.sun.enterprise.management.CapabilitiesgetCapabilities()

	    return getOfflineCapableCapabilities( false );
	
public static java.lang.StringgetDefaultInstanceName()

        return "server";
    
public voidtestCreateStandaloneServerConfig()

        final int basePort = 52788;
        
        _testCreateStandaloneServerConfig( ".StandaloneServerConfigTest", basePort );
    
public voidtestCreateStandaloneServerConfigWithDefaults()

        final int basePort = 0; // use the defaults
        
        _testCreateStandaloneServerConfig( ".StandaloneServerConfigTestWithDefaults", basePort);