1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Map ; 26 import java.util.Set ; 27 import java.util.HashSet ; 28 import java.util.HashMap ; 29 30 import javax.management.ObjectName ; 31 import javax.management.JMException ; 32 33 34 import com.sun.enterprise.management.AMXTestBase; 35 import com.sun.enterprise.management.Capabilities; 36 37 import com.sun.appserv.management.config.DomainConfig; 38 import com.sun.appserv.management.config.LifecycleModuleConfig; 39 40 import com.sun.appserv.management.helper.RefHelper; 41 42 import com.sun.enterprise.management.support.AMXLifecycleModule; 43 44 46 public final class LifecycleModuleConfigTest extends AMXTestBase 47 { 48 private static final String IMPL_CLASSNAME = AMXLifecycleModule.class.getName(); 50 51 private static final String TEST_NAME_BASE = "custom"; 52 private static final String TEST_TYPE = "CustomMBeanConfigTest"; 53 54 public 55 LifecycleModuleConfigTest () 56 { 57 if ( checkNotOffline( "ensureDefaultInstance" ) ) 58 { 59 ensureDefaultInstance( getDomainConfig() ); 60 } 61 } 62 63 public static String 64 getDefaultInstanceName() 65 { 66 return getDefaultInstanceName( "LifecycleModuleConfig" ); 67 } 68 69 public static LifecycleModuleConfig 70 ensureDefaultInstance( final DomainConfig domainConfig ) 71 { 72 LifecycleModuleConfig result = 73 domainConfig.getLifecycleModuleConfigMap().get( getDefaultInstanceName() ); 74 75 if ( result == null ) 76 { 77 result = createInstance( 78 domainConfig, 79 getDefaultInstanceName(), 80 IMPL_CLASSNAME, 81 1 ); 82 } 83 84 return result; 85 } 86 87 public static LifecycleModuleConfig 88 createInstance( 89 final DomainConfig domainConfig, 90 final String name, 91 final String classname, 92 final int loadOrder ) 93 { 94 final boolean isFailureFatal = false; 95 final boolean enabled = true; 96 final String classpath = "/test"; 97 final String description = null; 98 99 final LifecycleModuleConfig life = 100 domainConfig.createLifecycleModuleConfig( name, 101 description, 102 classname, 103 classpath, 104 "" + loadOrder, 105 isFailureFatal, 106 enabled, 107 null ); 108 109 return life; 110 } 111 112 113 public Map <String ,LifecycleModuleConfig> 114 getLifecycleModuleConfigs() 115 { 116 return getDomainConfig().getLifecycleModuleConfigMap(); 117 } 118 119 private void 120 _testGetAll() 121 { 122 123 final Map <String ,LifecycleModuleConfig> all = getLifecycleModuleConfigs(); 124 assert( all != null ); 125 } 126 127 private void 128 sanityCheck( final LifecycleModuleConfig config ) 129 { 130 config.setClassname( config.getClassname() ); 131 132 final String classpath = config.getClasspath(); 133 config.setClasspath( classpath == null ? "" : classpath ); 134 135 config.setLoadOrder( config.getLoadOrder() ); 136 137 config.setIsFailureFatal( config.getIsFailureFatal() ); 138 139 config.setEnabled( config.getEnabled() ); 140 } 141 142 public synchronized void 143 testAttrs() 144 { 145 ensureDefaultInstance( getDomainConfig() ); 146 147 final Map <String ,LifecycleModuleConfig> all = getLifecycleModuleConfigs(); 148 149 if ( all.size() != 0 ) 150 { 151 for( final LifecycleModuleConfig config : all.values() ) 152 { 153 sanityCheck( config ); 154 } 155 } 156 else 157 { 158 warning( "LifecycleModuleConfigTest: No LifecycleModuleConfig to test" ); 159 } 160 } 161 162 public synchronized void 163 testCreateRemove() 164 { 165 final DomainConfig domainConfig = getDomainConfig(); 166 167 } 168 } 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | Popular Tags |