1 23 24 package com.sun.enterprise.management.config; 25 26 import java.util.Set ; 27 import java.util.HashSet ; 28 import java.util.Arrays ; 29 30 import javax.management.ObjectName ; 31 32 import com.sun.appserv.management.config.JavaConfig; 33 import com.sun.appserv.management.util.misc.StringUtil; 34 import com.sun.appserv.management.util.misc.GSetUtil; 35 36 import com.sun.enterprise.management.AMXTestBase; 37 import com.sun.enterprise.management.Capabilities; 38 39 41 public final class JavaConfigTest extends AMXTestBase 42 { 43 public 44 JavaConfigTest () 45 { 46 } 47 48 public void 49 testGetJVMOptions() 50 { 51 final JavaConfig jc = getConfigConfig().getJavaConfig(); 52 53 final String [] jvmOptions = jc.getJVMOptions(); 54 55 if ( jvmOptions.length < 2 ) 56 { 57 warning( "Fewer than 2 JVM options, is this right: " + 58 StringUtil.toString( jvmOptions )); 59 60 } 61 62 70 } 71 72 public void 73 testSetJVMOptions() 74 { 75 final String newOption1 = "-DJavaConfigTest.OK=true"; 76 final String newOption2 = "-XJavaConfigTest.OK=true"; 77 78 final JavaConfig jc = getConfigConfig().getJavaConfig(); 79 80 final Set <String > beforeSet = GSetUtil.newUnmodifiableStringSet( jc.getJVMOptions() ); 81 82 final Set <String > requestSet = new HashSet <String >( beforeSet ); 84 requestSet.add( newOption1 ); 85 requestSet.add( newOption2 ); 86 jc.setJVMOptions( GSetUtil.toStringArray( requestSet ) ); 87 88 Set <String > afterSet = GSetUtil.newUnmodifiableStringSet( jc.getJVMOptions() ); 89 90 assert( afterSet.contains( newOption1 ) ); 92 assert( afterSet.contains( newOption2 ) ); 93 94 for( final String beforeOption : beforeSet ) 96 { 97 assert( afterSet.contains( beforeOption ) ); 98 } 99 100 requestSet.remove( newOption1 ); 102 requestSet.remove( newOption2 ); 103 jc.setJVMOptions( GSetUtil.toStringArray( requestSet ) ); 104 105 afterSet = GSetUtil.newUnmodifiableStringSet( jc.getJVMOptions() ); 107 assert( ! afterSet.contains( newOption1 ) ); 108 assert( ! afterSet.contains( newOption2 ) ); 109 110 assert( afterSet.equals( beforeSet ) ); 112 } 113 114 public void 115 testGetters() 116 throws Exception 117 { 118 final JavaConfig jc = getConfigConfig().getJavaConfig(); 119 120 String s; 121 122 s = jc.getBytecodePreprocessors(); 123 if ( s != null ) 124 { 125 jc.setBytecodePreprocessors( s ); 126 } 127 128 s = jc.getClasspathPrefix(); 129 if ( s != null ) 130 { 131 jc.setClasspathPrefix( s ); 132 } 133 134 s = jc.getClasspathSuffix(); 135 if ( s != null ) 136 { 137 jc.setClasspathSuffix( s ); 138 } 139 140 s = jc.getSystemClasspath(); 141 if ( s != null ) 142 { 143 jc.setSystemClasspath( s ); 144 } 145 146 final boolean debugEnabled = jc.getDebugEnabled(); 147 jc.setDebugEnabled( debugEnabled ); 148 149 s = jc.getDebugOptions(); 150 if ( s != null ) 151 { 152 jc.setDebugOptions( s ); 153 } 154 155 final boolean envClasspathIgnored = jc.getEnvClasspathIgnored(); 156 jc.setEnvClasspathIgnored( envClasspathIgnored ); 157 158 s = jc.getJavaHome(); 159 if ( s != null ) 160 { 161 jc.setJavaHome( s ); 162 } 163 164 s = jc.getJavacOptions(); 165 if ( s != null ) 166 { 167 jc.setJavacOptions( s ); 168 } 169 170 final String [] options = jc.getJVMOptions(); 171 if ( options != null ) 172 { 173 jc.setJVMOptions( options ); 174 } 175 176 s = jc.getNativeLibraryPathPrefix(); 177 if ( s != null ) 178 { 179 jc.setNativeLibraryPathPrefix( s ); 180 } 181 182 s = jc.getNativeLibraryPathSuffix(); 183 if ( s != null ) 184 { 185 jc.setNativeLibraryPathSuffix( s ); 186 } 187 188 s = jc.getRMICOptions(); 189 if ( s != null ) 190 { 191 jc.setRMICOptions( s ); 192 } 193 194 s = jc.getServerClasspath(); 195 if ( s != null ) 196 { 197 jc.setServerClasspath( s ); 198 } 199 } 200 } 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | Popular Tags |