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.Iterator ; 34 import java.util.Arrays ; 35 36 import javax.management.ObjectName ; 37 38 39 import com.sun.appserv.management.base.AMX; 40 import com.sun.appserv.management.base.Util; 41 42 import com.sun.appserv.management.DomainRoot; 43 import com.sun.appserv.management.client.AppserverConnectionSource; 44 45 import com.sun.appserv.management.config.DomainConfig; 46 import com.sun.appserv.management.config.NamedConfigElement; 47 import com.sun.appserv.management.config.StandaloneServerConfig; 48 import com.sun.appserv.management.config.ConfigConfig; 49 import com.sun.appserv.management.config.NodeAgentConfig; 50 51 import com.sun.appserv.management.util.misc.MapUtil; 52 import com.sun.appserv.management.util.misc.CollectionUtil; 53 54 55 import com.sun.enterprise.management.AMXTestBase; 56 import com.sun.enterprise.management.Capabilities; 57 58 59 61 public final class StandaloneServerConfigTest extends AMXTestBase 62 { 63 public 64 StandaloneServerConfigTest() 65 { 66 if ( checkNotOffline( "ensureDefaultInstance" ) ) 67 { 68 ensureDefaultInstance( getDomainRoot() ); 69 } 70 } 71 72 public static String 73 getDefaultInstanceName() 74 { 75 return "server"; 76 } 77 78 82 public static StandaloneServerConfig 83 ensureDefaultInstance( final DomainRoot domainRoot ) 84 { 85 final Map <String ,StandaloneServerConfig> servers = 86 domainRoot.getDomainConfig().getStandaloneServerConfigMap(); 87 88 StandaloneServerConfig server = servers.get( getDefaultInstanceName() ); 89 assert( server != null ); 90 91 return server; 92 } 93 94 public static Capabilities 95 getCapabilities() 96 { 97 return getOfflineCapableCapabilities( false ); 98 } 99 100 public void 101 testCreateStandaloneServerConfig() 102 throws Throwable 103 { 104 final ConfigSetup setup = new ConfigSetup( getDomainRoot() ); 105 final int basePort = 52700; 106 107 final Map <String ,NodeAgentConfig> nodeAgentConfigs = getDomainConfig().getNodeAgentConfigMap(); 108 109 if ( nodeAgentConfigs.keySet().size() == 0 ) 110 { 111 warning( "testCreateStandaloneServerConfig: No node agents available, skipping test." ); 112 } 113 else 114 { 115 for( final String nodeAgentName : nodeAgentConfigs.keySet() ) 116 { 117 final String serverName = nodeAgentName + ".StandaloneServerConfigTestServer"; 118 final String configName = serverName + "-config"; 119 120 setup.removeServer( serverName ); 121 setup.removeConfig( configName ); 122 123 final ConfigConfig config = setup.createConfig( configName ); 124 assert( configName.equals( config.getName() ) ); 125 final Map <String ,Object > attrs = Util.getExtra( config ).getAllAttributes(); 126 127 try 128 { 129 final StandaloneServerConfig server = 130 setup.createServer( serverName, basePort, nodeAgentName, config.getName() ); 131 132 setup.removeServer( server.getName() ); 133 } 134 catch( Throwable t ) 135 { 136 try 137 { 138 setup.removeConfig( config.getName() ); 139 } 140 catch( Exception ee ) 141 { 142 } 143 throw t; 144 } 145 } 146 } 147 } 148 } 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | Popular Tags |