1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Set ; 26 import java.util.Map ; 27 import java.util.HashMap ; 28 import java.util.Collections ; 29 30 import java.io.IOException ; 31 32 import javax.management.ObjectName ; 33 34 import com.sun.appserv.management.base.AMX; 35 import com.sun.appserv.management.base.Container; 36 import com.sun.appserv.management.base.XTypes; 37 38 import com.sun.appserv.management.config.AMXConfig; 39 import com.sun.appserv.management.config.HTTPListenerConfig; 40 import com.sun.appserv.management.config.HTTPServiceConfig; 41 import com.sun.appserv.management.config.SSLConfig; 42 import com.sun.appserv.management.config.PropertiesAccess; 43 import com.sun.appserv.management.config.HTTPListenerConfigKeys; 44 import com.sun.appserv.management.config.HTTPListenerConfigFamilyValues; 45 import static com.sun.appserv.management.config.SSLConfigKeys.*; 46 47 48 import com.sun.enterprise.management.AMXTestBase; 49 import com.sun.enterprise.management.Capabilities; 50 51 import com.sun.appserv.management.util.jmx.JMXUtil; 52 import com.sun.appserv.management.util.misc.MapUtil; 53 import com.sun.appserv.management.util.misc.TypeCast; 54 55 57 public final class HTTPListenerConfigTest extends ConfigMgrTestBase 58 { 59 static final String ADDRESS = "0.0.0.0"; 60 static final String DEF_VIRTUAL_SERVER = "server"; 61 static final String SERVER_NAME = "localhost"; 62 63 static final Map <String ,Object > OPTIONAL = new HashMap <String ,Object >(); 65 static 66 { 67 OPTIONAL.put( PropertiesAccess.PROPERTY_PREFIX + "xyz", "abc"); 68 OPTIONAL.put( HTTPListenerConfigKeys.ENABLED_KEY, Boolean.FALSE); 69 OPTIONAL.put( HTTPListenerConfigKeys.ACCEPTOR_THREADS_KEY, new Integer (4 ) ); 70 OPTIONAL.put( HTTPListenerConfigKeys.XPOWERED_BY_KEY, Boolean.TRUE ); 73 } 75 76 public 77 HTTPListenerConfigTest () 78 { 79 } 80 81 82 HTTPServiceConfig 83 getHTTPServiceConfig( ) 84 { 85 return( getConfigConfig( ).getHTTPServiceConfig() ); 86 } 87 88 public void 89 testGetHTTPListeners() 90 { 91 final HTTPServiceConfig httpService = 92 getConfigConfig( ).getHTTPServiceConfig(); 93 94 final Map <String ,HTTPListenerConfig> proxies = httpService.getHTTPListenerConfigMap(); 95 96 for( final String listenerName : proxies.keySet() ) 97 { 98 final HTTPListenerConfig listener = (HTTPListenerConfig) 99 proxies.get( listenerName ); 100 101 listener.getEnabled(); 102 } 103 } 104 105 protected String 106 getProgenyTestName() 107 { 108 return( "HTTPListenerConfigMgrTest-test-listener" ); 109 } 110 111 protected Container 112 getProgenyContainer() 113 { 114 return getHTTPService(); 115 } 116 117 protected String 118 getProgenyJ2EEType() 119 { 120 return XTypes.HTTP_LISTENER_CONFIG; 121 } 122 123 124 protected void 125 removeProgeny( final String name ) 126 { 127 getHTTPService().removeHTTPListenerConfig( name ); 128 } 129 130 protected final AMXConfig 131 createProgeny( final String name, final Map <String ,String > options ) 132 { 133 final Map <String ,String > optional = TypeCast.asMap( OPTIONAL ); 136 assert( ! MapUtil.isAllStrings( optional ) ); 137 138 final Map <String ,String > allOptions = MapUtil.newMap( options, optional ); 139 assert( ! MapUtil.isAllStrings( allOptions ) ); 140 141 final int port = 31000 + (name.hashCode() % 31000); 142 143 final HTTPListenerConfig config = 144 getHTTPService().createHTTPListenerConfig(name, 145 ADDRESS, port, DEF_VIRTUAL_SERVER, SERVER_NAME, allOptions ); 146 147 return( config ); 148 } 149 150 protected final HTTPServiceConfig 151 getHTTPService() 152 { 153 return getConfigConfig().getHTTPServiceConfig(); 154 } 155 156 157 158 public void 159 testCreateSSL() 160 throws Exception 161 { 162 final Map <String ,String > options = 163 Collections.unmodifiableMap( MapUtil.newMap( 164 new String [] 165 { 166 CLIENT_AUTH_ENABLED_KEY, "false", 167 SSL_2_ENABLED_KEY, "true", 168 SSL_3_ENABLED_KEY, "true", 169 SSL_2_CIPHERS_KEY, "+rc4,-rc4export,-rc2,-rc2export,+idea,+des,+desede3", 170 SSL3_TLS_CIPHERS_KEY, 171 "+rsa_rc4_128_md5,+rsa3des_sha,+rsa_des_sha,-rsa_rc4_40_md5" + 172 "-rsa_rc2_40_md5,-rsa_null_md5,-rsa_des_56_sha,-rsa_rc4_56_sha", 173 TLS_ENABLED_KEY, "true", 174 TLS_ROLLBACK_ENABLED_KEY, "true", 175 } 176 )); 177 178 if ( ! checkNotOffline( "testCreateSSL" ) ) 179 { 180 return; 181 } 182 183 final String NAME = "HTTPListenerConfigMgr-listener-for-testCreateSSL"; 184 185 try 186 { 187 removeEx( NAME ); 188 final HTTPListenerConfig newListener = 189 (HTTPListenerConfig)createProgeny( NAME, null ); 190 assert newListener != null; 191 192 final Map <String ,HTTPListenerConfig> listeners = 194 getHTTPService().getHTTPListenerConfigMap(); 195 final HTTPListenerConfig listener = listeners.get( NAME ); 196 assert listener != null; 197 assert listener == newListener; 198 199 final String CERT_NICKNAME = NAME + "Cert"; 200 201 final SSLConfig ssl = listener.createSSLConfig( CERT_NICKNAME, options); 202 assert ssl != null; 203 assert ssl.getCertNickname().equals( CERT_NICKNAME ); 204 205 listener.removeSSLConfig(); 206 } 207 finally 208 { 209 remove( NAME ); 210 } 211 } 212 } 213 214 215 | Popular Tags |