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

JMXConnectorConfigTest

public final class JMXConnectorConfigTest extends ConfigMgrTestBase

Fields Summary
static final String
ADDRESS
static final String
TEST_REALM_CLASS
static final String
DEFAULT_PORT
static final Map
OPTIONAL
Constructors Summary
public JMXConnectorConfigTest()


	
	
		OPTIONAL.put( PropertiesAccess.PROPERTY_PREFIX + "xyz", "abc");
		OPTIONAL.put( JMXConnectorConfigKeys.SECURITY_ENABLED_KEY, "false");
	
	    if ( checkNotOffline( "ensureDefaultInstance" ) )
	    {
	        ensureDefaultInstance( getConfigConfig().getAdminServiceConfig() );
	    }
	
Methods Summary
final com.sun.appserv.management.config.AuthRealmConfigcreateAuthRealmConfig(java.lang.String name)

	    removeAuthRealmConfig( name );
	    
	    return getSecurityServiceConfig().createAuthRealmConfig(
	        name, TEST_REALM_CLASS, null );
	
private java.lang.StringcreateAuthRealmName(java.lang.String progenyName)

	    return progenyName + ".TestRealm";
	
public static com.sun.appserv.management.config.JMXConnectorConfigcreateInstance(java.lang.String name, java.lang.String address, java.lang.String port, com.sun.appserv.management.config.AuthRealmConfig authRealm, java.util.Map optional)

	    final AdminServiceConfig  adminServiceConfig =
	        getConfigConfig( authRealm ).getAdminServiceConfig();
	    
	    return adminServiceConfig.createJMXConnectorConfig( name,
	                address, port, authRealm.getName(), optional );
	
protected final com.sun.appserv.management.config.AMXConfigcreateProgeny(java.lang.String name, java.util.Map options)

		final Map<String,String>	allOptions	= MapUtil.newMap( options, OPTIONAL );
		
		final	int	port	= (name.hashCode() % 16000) + 33111;
		
		final String            authRealmName   = createAuthRealmName( name );
		final AuthRealmConfig   authRealmConfig = createAuthRealmConfig( authRealmName );
		
		try
		{
    	    return getAdminServiceConfig().createJMXConnectorConfig(name,
    	        ADDRESS, "" + port, authRealmName, allOptions);
	    }
	    catch( Exception e )
	    {
	        removeAuthRealmConfig( authRealmName );
	        throw new RuntimeException( e );
	    }
	
public static com.sun.appserv.management.config.JMXConnectorConfigensureDefaultInstance(com.sun.appserv.management.config.AdminServiceConfig adminServiceConfig)

	    JMXConnectorConfig   result  =
	        adminServiceConfig.getJMXConnectorConfigMap().get( getDefaultInstanceName() );
	    
	    if ( result == null )
	    {
	        final SecurityServiceConfig securityServiceConfig   =
	            getConfigConfig( adminServiceConfig ).getSecurityServiceConfig();
	            
	        final AuthRealmConfig defaultAuthRealm  =
	            AuthRealmConfigTest.ensureDefaultInstance( securityServiceConfig );
	        
	        result  = createInstance( getDefaultInstanceName(),
	            ADDRESS, DEFAULT_PORT, defaultAuthRealm, OPTIONAL );
	    }
	    
	    return result;
	
final com.sun.appserv.management.config.AdminServiceConfiggetAdminServiceConfig()

		return( getConfigConfig(). getAdminServiceConfig());
	
public static java.lang.StringgetDefaultInstanceName()

        return getDefaultInstanceName( "JMXConnectorConfig" );
    
protected com.sun.appserv.management.base.ContainergetProgenyContainer()

		return getAdminServiceConfig();
	
protected java.lang.StringgetProgenyJ2EEType()

		return XTypes.JMX_CONNECTOR_CONFIG;
	
final com.sun.appserv.management.config.SecurityServiceConfiggetSecurityServiceConfig()

	    return getConfigConfig().getSecurityServiceConfig();
	
final voidremoveAuthRealmConfig(java.lang.String name)

	    try
	    {
	        getSecurityServiceConfig().removeAuthRealmConfig( name );
	    }
	    catch( Exception e )
	    {
	    }
	
protected voidremoveProgeny(java.lang.String name)

		try
		{
		    getAdminServiceConfig().removeJMXConnectorConfig( name );
		}
		finally
		{
	        try
	        {
	            removeAuthRealmConfig( createAuthRealmName( name ) );
	        }
	        catch( Exception e )
	        {
	        }
	    }
	
public voidtestCreateSSL()

	    if ( ! checkNotOffline( "testCreateSSL" ) )
	    {
	        return;
	    }
	    
		final String	NAME	= "JMXConnectorConfigTest-testCreateSSL";
		try
		{
			removeEx(NAME);
			final JMXConnectorConfig	newConfig	=
				(JMXConnectorConfig)createProgeny( NAME, null);
				
			final Map<String,JMXConnectorConfig>	jmxConnectors	=
				getAdminServiceConfig().getJMXConnectorConfigMap();
			
			final JMXConnectorConfig jmxConnector = (JMXConnectorConfig)
				jmxConnectors.get(NAME);
			assert jmxConnector != null;
			assert jmxConnector == newConfig;
			
			final String	CERT_NICKNAME	= NAME + "Cert";
			
			final SSLConfig ssl = jmxConnector.createSSLConfig( CERT_NICKNAME, null);
			assert ssl != null;
			assert ssl.getCertNickname().equals( CERT_NICKNAME );
			
			jmxConnector.removeSSLConfig();
		}
		finally
		{
			remove(NAME);
		}