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

ReferencesTest

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

Fields Summary
private static final String
MAIL_RESOURCE_NAME
Constructors Summary
public ReferencesTest()

    
Methods Summary
com.sun.appserv.management.config.MailResourceConfigcreateMailResourceConfig()

    
        
    
    
        final MailResourceConfig    mr  =
            getDomainConfig().createMailResourceConfig(
                MAIL_RESOURCE_NAME,
                "localhost",
                "mailuser@domain.com",
                "mailfrom@domain.com",
                null );
        return mr;
    
com.sun.appserv.management.config.MailResourceConfigensureMailResourceConfig()

        final Map<String,MailResourceConfig>  mails =
            getDomainConfig().getMailResourceConfigMap();
        
        MailResourceConfig mr   = mails.get( MAIL_RESOURCE_NAME );
        if ( mr == null )
        {
            mr  = createMailResourceConfig();
        }
        return mr;
    
voidremoveMailResourceConfig()

        final Map<String,MailResourceConfig>  mails =
            getDomainConfig().getMailResourceConfigMap();
        
        MailResourceConfig mr   = mails.get( MAIL_RESOURCE_NAME );
        if ( mr != null )
        {
            getDomainConfig().removeMailResourceConfig( mr.getName() );
        }
    
public voidtestCreateAndRemoveResourceRefStandaloneServer()

	    if ( ! checkNotOffline( "testCreateRemove" ) )
	    {
	        return;
	    }
	    
        final Map<String,AppserverConnectionSource> nodeAgents  =
            getNodeAgents();
        
        if ( nodeAgents.keySet().size() == 0 )
        {
            warning(
                "testCreateAndRemoveResourceRefStandaloneServer: no Node Agents--SKIPPING TEST" );
            return;
        }
        final String    nodeAgentName   = nodeAgents.keySet().iterator().next();
        
        final ConfigSetup setup  = new ConfigSetup( getDomainRoot() );
        
        ensureMailResourceConfig();
        
        final String    serverName  = "testCreateAndRemoveResourceRefStandaloneServer";
        final String    configName  = serverName + "-config";
        
        final ConfigConfig  config  = setup.createConfig( configName );
        try
        {
            final int       basePort    = 34770;
            
            final StandaloneServerConfig server =
                setup.createServer( serverName, basePort, nodeAgentName, configName );
            try
            {
        		final ResourceRefConfig ref =
        		    server.createResourceRefConfig( MAIL_RESOURCE_NAME );
        		assert( ref != null );
        		
                server.removeResourceRefConfig( ref.getName() );
            }
            catch( Exception e )
            {
                setup.removeServer( serverName );
                throw e;
            }
            finally
            {
                removeMailResourceConfig();
            }
        }
        catch( Exception e )
        {
            setup.removeConfig( configName );
            throw e;
        }
    
public voidtestCreateRefToMissingTarget()

	    if ( ! checkNotOffline( "testCreateRemove" ) )
	    {
	        return;
	    }
	    
	    final String MISSING_NAME   = "NonExistent";
	    
	    final DomainConfig domainConfig = getDomainRoot().getDomainConfig();
	    final StandaloneServerConfig serverConfig =
	        domainConfig.getStandaloneServerConfigMap().get( "server" );
	    
	    try
	    {
	        serverConfig.createResourceRefConfig( MISSING_NAME );
	        assert false;
	        
	        serverConfig.createDeployedItemRefConfig( MISSING_NAME );
	        assert false;
	    }
	    catch( Exception e )
	    {
	        // good
	    }