1 23 package com.sun.enterprise.management.config; 24 25 import java.io.IOException ; 26 import java.io.Serializable ; 27 28 import java.util.Set ; 29 import java.util.Map ; 30 import java.util.HashMap ; 31 import java.util.Collections ; 32 33 import javax.management.ObjectName ; 34 35 import com.sun.appserv.management.base.AMX; 36 import com.sun.appserv.management.base.Util; 37 import com.sun.appserv.management.base.Container; 38 import com.sun.appserv.management.base.XTypes; 39 40 import com.sun.appserv.management.config.AMXConfig; 41 import com.sun.appserv.management.config.HTTPServiceConfig; 42 import com.sun.appserv.management.config.VirtualServerConfig; 43 import com.sun.appserv.management.config.HTTPAccessLogConfig; 44 import com.sun.appserv.management.config.VirtualServerConfigKeys; 45 46 import com.sun.appserv.management.util.misc.MapUtil; 47 48 49 import com.sun.enterprise.management.AMXTestBase; 50 import com.sun.enterprise.management.Capabilities; 51 52 54 public final class VirtualServerConfigTest extends ConfigMgrTestBase 55 { 56 static final String HOSTS = "localhost"; 57 58 public 59 VirtualServerConfigTest () 60 { 61 } 62 63 protected Container 64 getProgenyContainer() 65 { 66 return getHTTPService(); 67 } 68 69 protected String 70 getProgenyJ2EEType() 71 { 72 return XTypes.VIRTUAL_SERVER_CONFIG; 73 } 74 75 76 protected void 77 removeProgeny( final String name ) 78 { 79 getHTTPService().removeVirtualServerConfig( name ); 80 } 81 82 protected final VirtualServerConfig 83 create(String name) 84 { 85 return (VirtualServerConfig)createProgeny( name, null ); 86 } 87 88 private Map <String ,String > 89 getOptional() 90 { 91 final Map <String ,String > m = new HashMap <String ,String >(); 92 m.put( VirtualServerConfigKeys.STATE_KEY, VirtualServerConfigKeys.STATE_DISABLED ); 93 m.put( VirtualServerConfigKeys.DOC_ROOT_PROPERTY_KEY, "/" ); 94 m.put( VirtualServerConfigKeys.ACCESS_LOG_PROPERTY_KEY, "/" ); 95 96 return m; 97 } 98 99 protected final AMXConfig 100 createProgeny( 101 final String name, 102 final Map <String ,String > extra ) 103 { 104 final Map <String ,String > allOptions = MapUtil.newMap( extra, getOptional() ); 105 106 return( getHTTPService().createVirtualServerConfig( name, "localhost", allOptions ) ); 107 } 108 109 protected final HTTPServiceConfig 110 getHTTPService() 111 { 112 return getConfigConfig().getHTTPServiceConfig(); 113 } 114 115 public void 116 testCreateHTTPAccessLog() 117 throws Exception 118 { 119 if ( ! checkNotOffline( "testCreateRemove" ) ) 120 { 121 return; 122 } 123 124 final String NAME = "VirtualServerConfigMgrTest-testCreateHTTPAccessLog"; 125 try 126 { 127 removeEx( NAME ); 128 final VirtualServerConfig newVS = 129 (VirtualServerConfig)createProgeny( NAME, null); 130 assert newVS != null; 131 134 assert( newVS.getHTTPAccessLogConfig() == null ); 135 136 final HTTPAccessLogConfig accessLog = 137 newVS.createHTTPAccessLogConfig( false, "${com.sun.aas.instanceRoot}/logs/access", null); 138 assert ( accessLog != null ); 139 assert ( Util.getObjectName( accessLog ).equals( Util.getObjectName( newVS.getHTTPAccessLogConfig() ) ) ); 140 141 newVS.removeHTTPAccessLogConfig(); 142 } 143 finally 144 { 145 remove( NAME ); 146 } 147 } 148 } 149 150 151 | Popular Tags |