testSetJVMOptions()
{
final String newOption1 = "-DJavaConfigTest.OK=true";
final String newOption2 = "-XJavaConfigTest.OK=true";
final JavaConfig jc = getConfigConfig().getJavaConfig();
final Set<String> beforeSet = GSetUtil.newUnmodifiableStringSet( jc.getJVMOptions() );
// add our new options
final Set<String> requestSet = new HashSet<String>( beforeSet );
requestSet.add( newOption1 );
requestSet.add( newOption2 );
jc.setJVMOptions( GSetUtil.toStringArray( requestSet ) );
Set<String> afterSet = GSetUtil.newUnmodifiableStringSet( jc.getJVMOptions() );
// make sure our new options are present
assert( afterSet.contains( newOption1 ) );
assert( afterSet.contains( newOption2 ) );
// make sure all prior options are still present
for( final String beforeOption : beforeSet )
{
assert( afterSet.contains( beforeOption ) );
}
// now remove our two options
requestSet.remove( newOption1 );
requestSet.remove( newOption2 );
jc.setJVMOptions( GSetUtil.toStringArray( requestSet ) );
// verify our two options are gone
afterSet = GSetUtil.newUnmodifiableStringSet( jc.getJVMOptions() );
assert( ! afterSet.contains( newOption1 ) );
assert( ! afterSet.contains( newOption2 ) );
// make sure all prior options are still present
assert( afterSet.equals( beforeSet ) );