1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Map ; 26 import java.util.HashMap ; 27 28 import javax.management.ObjectName ; 29 30 import com.sun.appserv.management.base.Container; 31 import com.sun.appserv.management.base.XTypes; 32 33 import com.sun.appserv.management.config.AMXConfig; 34 import com.sun.appserv.management.config.DomainConfig; 35 import com.sun.appserv.management.config.CustomResourceConfig; 36 37 38 import com.sun.enterprise.management.AMXTestBase; 39 import com.sun.enterprise.management.Capabilities; 40 41 43 public final class CustomResourceConfigTest extends ResourceConfigTestBase 44 { 45 static final Map <String ,String > OPTIONAL = new HashMap <String ,String >(); 46 47 static private final String RES_TYPE = "CustomResourceConfigTest.Dummy"; 49 static private final String FACTORY_CLASS = 50 "com.sun.enterprise.management.config.CustomResourceConfigTestDummy"; 51 52 public 53 CustomResourceConfigTest () 54 { 55 if ( checkNotOffline( "ensureDefaultInstance" ) ) 56 { 57 ensureDefaultInstance( getDomainConfig() ); 58 } 59 } 60 61 public static String 62 getDefaultInstanceName() 63 { 64 return getDefaultInstanceName( "CustomResourceConfig" ); 65 } 66 67 68 public static CustomResourceConfig 69 ensureDefaultInstance( final DomainConfig domainConfig ) 70 { 71 CustomResourceConfig result = 72 domainConfig.getCustomResourceConfigMap().get( getDefaultInstanceName() ); 73 74 if ( result == null ) 75 { 76 result = createInstance( domainConfig, 77 getDefaultInstanceName(), RES_TYPE, FACTORY_CLASS, null ); 78 } 79 80 return result; 81 } 82 83 public static CustomResourceConfig 84 createInstance( 85 final DomainConfig domainConfig, 86 final String name, 87 final String resType, 88 final String factoryClass, 89 final Map <String ,String > optional ) 90 { 91 final CustomResourceConfig config = 92 domainConfig.createCustomResourceConfig( name, resType, factoryClass, optional ); 93 94 return config; 95 } 96 97 98 protected Container 99 getProgenyContainer() 100 { 101 return getDomainConfig(); 102 } 103 104 protected String 105 getProgenyJ2EEType() 106 { 107 return XTypes.CUSTOM_RESOURCE_CONFIG; 108 } 109 110 111 protected void 112 removeProgeny( final String name ) 113 { 114 getDomainConfig().removeCustomResourceConfig( name ); 115 } 116 117 protected String 118 getProgenyTestName() 119 { 120 return( "CustomResourceConfigTest" ); 121 } 122 123 protected final AMXConfig 124 createProgeny(final String name, final Map <String ,String > options ) 125 { 126 final CustomResourceConfig config = 127 createInstance( getDomainConfig(), name, RES_TYPE, FACTORY_CLASS, options ); 128 129 addReference( config ); 130 131 return config; 132 } 133 } 134 135 136 | Popular Tags |