1 23 24 29 package com.sun.enterprise.management.config; 30 31 import java.util.Set ; 32 import java.util.Map ; 33 import java.util.HashMap ; 34 35 import javax.management.ObjectName ; 36 37 import com.sun.appserv.management.base.AMX; 38 import com.sun.appserv.management.base.Container; 39 import com.sun.appserv.management.base.XTypes; 40 import com.sun.appserv.management.util.misc.MapUtil; 41 42 import com.sun.appserv.management.base.Util; 43 import com.sun.appserv.management.config.AMXConfig; 44 import com.sun.appserv.management.config.IIOPServiceConfig; 45 import com.sun.appserv.management.config.IIOPListenerConfig; 46 import com.sun.appserv.management.config.SSLConfig; 47 import com.sun.appserv.management.config.PropertiesAccess; 48 import com.sun.appserv.management.config.IIOPListenerConfigKeys; 49 50 51 import com.sun.enterprise.management.AMXTestBase; 52 import com.sun.enterprise.management.Capabilities; 53 54 56 public final class IIOPListenerConfigTest extends ConfigMgrTestBase 57 { 58 static final String ADDRESS = "0.0.0.0"; 59 static final Map <String ,String > OPTIONAL = new HashMap <String ,String >(); 60 static 61 { 62 OPTIONAL.put( PropertiesAccess.PROPERTY_PREFIX + "xyz", "abc"); 63 OPTIONAL.put( IIOPListenerConfigKeys.ENABLED_KEY , "false"); 64 OPTIONAL.put( IIOPListenerConfigKeys.SECURITY_ENABLED_KEY, "true"); 65 } 66 67 public 68 IIOPListenerConfigTest () 69 { 70 } 71 72 protected Container 73 getProgenyContainer() 74 { 75 return getIIOPService(); 76 } 77 78 protected String 79 getProgenyJ2EEType() 80 { 81 return XTypes.IIOP_LISTENER_CONFIG; 82 } 83 84 85 protected void 86 removeProgeny( final String name ) 87 { 88 getIIOPService().removeIIOPListenerConfig( name ); 89 } 90 91 92 protected final ObjectName 93 create(String name) 94 { 95 return Util.getObjectName( createProgeny( name, null ) ); 96 } 97 98 protected final AMXConfig 99 createProgeny( final String name, final Map <String ,String > options ) 100 { 101 final Map <String ,String > allOptions = MapUtil.newMap( options, OPTIONAL ); 102 103 final int port = (name.hashCode() % 32000) + 32000; 104 allOptions.put( IIOPListenerConfigKeys.PORT_KEY, "" + port ); 105 106 return getIIOPService().createIIOPListenerConfig(name, ADDRESS, allOptions ); 107 } 108 109 protected final IIOPServiceConfig 110 getIIOPService() 111 { 112 return getConfigConfig().getIIOPServiceConfig(); 113 } 114 115 public void 116 testCreateSSL() 117 throws Exception 118 { 119 if ( ! checkNotOffline( "testCreateSSL" ) ) 120 { 121 return; 122 } 123 124 final String NAME = "IIOPListenerConfigMgr-testCreateSSL"; 125 126 removeEx( NAME ); 127 128 final IIOPListenerConfig newListener = 129 (IIOPListenerConfig)createProgeny( NAME, null ); 130 131 try 132 { 133 final Map <String ,IIOPListenerConfig> listeners = 134 getIIOPService().getIIOPListenerConfigMap(); 135 136 final IIOPListenerConfig listener = 137 (IIOPListenerConfig)listeners.get( NAME ); 138 assert listener != null; 139 assert listener == newListener; 140 141 final String CERT_NICKNAME = NAME + "Cert"; 142 143 final SSLConfig ssl = listener.createSSLConfig( CERT_NICKNAME, null); 144 assert ssl != null; 145 assert ssl.getCertNickname().equals( CERT_NICKNAME ); 146 147 listener.removeSSLConfig(); 148 } 149 finally 150 { 151 remove( NAME ); 152 } 153 } 154 171 } 172 173 174 | Popular Tags |