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.Util; 31 32 import com.sun.appserv.management.config.JavaConfig; 33 import com.sun.appserv.management.config.ProfilerConfig; 34 import com.sun.appserv.management.config.ProfilerConfigKeys; 35 36 import com.sun.appserv.management.util.jmx.JMXUtil; 37 38 39 import com.sun.enterprise.management.AMXTestBase; 40 import com.sun.enterprise.management.Capabilities; 41 42 44 public final class ProfilerConfigTest extends AMXTestBase 45 { 46 private static final String NATIVE_LIBRARY_PATH = "a/b/c"; 47 private static final String CLASSPATH = "/foo/bar"; 48 49 private static Map <String ,String > 50 getOptional() 51 { 52 final Map <String ,String > optional = new HashMap <String ,String >(); 53 optional.put( ProfilerConfigKeys.NATIVE_LIBRARY_PATH_KEY, NATIVE_LIBRARY_PATH); 54 optional.put( ProfilerConfigKeys.CLASSPATH_KEY, CLASSPATH); 55 optional.put( ProfilerConfigKeys.ENABLED_KEY, "false"); 56 return optional; 57 } 58 59 public 60 ProfilerConfigTest () 61 { 62 if ( checkNotOffline( "testIllegalCreate" ) ) 63 { 64 ensureDefaultInstance( getConfigConfig().getJavaConfig() ); 65 } 66 } 67 68 public static ProfilerConfig 69 ensureDefaultInstance( final JavaConfig javaConfig ) 70 { 71 ProfilerConfig prof = javaConfig.getProfilerConfig( ); 72 if ( prof == null ) 73 { 74 final String NAME = "profiler"; 75 76 prof = javaConfig.createProfilerConfig( NAME, getOptional() ); 77 assert prof != null; 78 } 79 80 return prof; 81 } 82 83 private void 84 testGetters( final ProfilerConfig prof ) 85 { 86 assert( prof.getClasspath() != null ); 87 prof.setClasspath( prof.getClasspath() ); 88 89 assert( prof.getNativeLibraryPath() != null ); 90 prof.setNativeLibraryPath( prof.getNativeLibraryPath() ); 91 92 assert( prof.getJVMOptions() != null ); 93 prof.setJVMOptions( prof.getJVMOptions() ); 94 95 prof.setEnabled( prof.getEnabled() ); 96 } 97 98 public synchronized void 99 testCreateRemoveProfiler() 100 throws Exception 101 { 102 if ( checkNotOffline( "testIllegalCreate" ) ) 103 { 104 ensureDefaultInstance( getConfigConfig().getJavaConfig() ); 105 106 final JavaConfig javaConfig = getConfigConfig().getJavaConfig(); 107 108 javaConfig.removeProfilerConfig(); 109 assert javaConfig.getProfilerConfig() == null : 110 "Can't remove ProfilerConfig from " + 111 JMXUtil.toString( Util.getObjectName(javaConfig) ); 112 113 ensureDefaultInstance( javaConfig ); 114 assert javaConfig.getProfilerConfig() != null; 115 Util.getExtra( javaConfig.getProfilerConfig() ).getMBeanInfo(); 116 117 testGetters( javaConfig.getProfilerConfig() ); 118 119 javaConfig.removeProfilerConfig(); 120 ensureDefaultInstance( javaConfig ); 121 assert javaConfig.getProfilerConfig() != null; 122 Util.getExtra( javaConfig.getProfilerConfig() ).getMBeanInfo(); 123 testGetters( javaConfig.getProfilerConfig() ); 124 } 125 } 126 } 127 128 129 | Popular Tags |