1 23 package com.sun.enterprise.management.ext.offline; 24 25 import java.util.Set ; 26 import java.util.HashSet ; 27 28 import javax.management.ObjectName ; 29 30 import com.sun.appserv.management.base.Util; 31 import com.sun.appserv.management.util.misc.GSetUtil; 32 import com.sun.appserv.management.util.misc.CollectionUtil; 33 import com.sun.appserv.management.config.ConfigElement; 34 35 import com.sun.enterprise.management.AMXTestBase; 36 import com.sun.enterprise.management.offline.OfflineDottedNamePrefixes; 37 38 39 41 public final class OfflineDottedNamePrefixesTest extends AMXTestBase 42 { 43 public 44 OfflineDottedNamePrefixesTest() 45 { 46 } 47 48 private ObjectName 49 ON( final String objectNameString ) 50 { 51 return Util.newObjectName( objectNameString ); 52 } 53 54 public void 55 testGetInstance() 56 { 57 assert OfflineDottedNamePrefixes.getInstance() != null; 58 } 59 60 private static final String DOMAIN="amx:j2eeType=X-DomainConfig,name=na"; 61 private static final String SERVER_CONFIG="amx:j2eeType=X-StandaloneServerConfig,name=server-config"; 62 63 private String 64 getPrefix( final String objectNameString ) 65 { 66 return getPrefix( ON( objectNameString ) ); 67 } 68 69 private String 70 getPrefix( final ObjectName objectName ) 71 { 72 final OfflineDottedNamePrefixes prefixes = 73 OfflineDottedNamePrefixes.getInstance(); 74 75 return prefixes.getPrefix( objectName ); 76 } 77 78 public void 79 testIllegal() 80 { 81 try 82 { 83 assert( getPrefix( "amx:foo=bar" ) == null ); 84 assert false; 85 } 86 catch( Exception e ) 87 { 88 } 89 } 90 91 public void 92 testGetPrefix() 93 { 94 assert( getPrefix( DOMAIN ).equals( "domain" ) ); 95 assert( getPrefix( SERVER_CONFIG ).equals( "server-config" ) ); 96 } 97 98 public void 99 testAllAMXConfig() 100 { 101 if ( getConnection() == null ) 102 { 103 warning( "testAllAMXConfig: No MBeanServerConnection, skipping test" ); 104 return; 105 } 106 107 final Set <ConfigElement> all = getTestUtil().getAllAMX( ConfigElement.class ); 108 109 final Set <String > missing = new HashSet <String >(); 110 for( final ConfigElement config : all ) 111 { 112 final ObjectName objectName = Util.getObjectName( config ); 113 final String prefix = getPrefix( objectName ); 114 if ( prefix == null ) 115 { 116 missing.add( config.getJ2EEType() ); 117 } 118 else 119 { 120 } 122 } 123 124 if ( missing.size() != 0 ) 125 { 126 } 129 } 130 } 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | Popular Tags |