FileDocCategorySizeDatePackage
JavaConfigTest.javaAPI DocGlassfish v2 API6298Fri May 04 22:23:54 BST 2007com.sun.enterprise.management.config

JavaConfigTest

public final class JavaConfigTest extends com.sun.enterprise.management.AMXTestBase

Fields Summary
Constructors Summary
public JavaConfigTest()

	
Methods Summary
public voidtestGetJVMOptions()

	    final JavaConfig    jc  = getConfigConfig().getJavaConfig();
	    
	    final String[]  jvmOptions  = jc.getJVMOptions();
	    
	    if ( jvmOptions.length < 2 )
	    {
	        warning( "Fewer than 2 JVM options, is this right: " +
	            StringUtil.toString( jvmOptions ));
	        
	    }
	    
	    /*
	    Arrays.sort( jvmOptions );
        trace("length = " + jvmOptions.length);
        for (int ii=0; ii<jvmOptions.length; ii++)
        {
            trace("jvmOptions[" + ii + "] = " + jvmOptions[ii]);
        }
        */
	
public voidtestGetters()

	    final JavaConfig    jc  = getConfigConfig().getJavaConfig();
	    
	    String  s;
	    
    	s   = jc.getBytecodePreprocessors();
    	if ( s != null )
    	{
    	    jc.setBytecodePreprocessors( s );
    	}

    	s   = jc.getClasspathPrefix();
    	if ( s != null )
    	{
    	    jc.setClasspathPrefix( s );
    	}

    	s   = jc.getClasspathSuffix();
    	if ( s != null )
    	{
    	    jc.setClasspathSuffix( s );
    	}

    	s   = jc.getSystemClasspath();
    	if ( s != null )
    	{
    	    jc.setSystemClasspath( s );
    	}

    	final boolean debugEnabled =	jc.getDebugEnabled();
    	jc.setDebugEnabled( debugEnabled );

    	s   = jc.getDebugOptions();
    	if ( s != null )
    	{
    	    jc.setDebugOptions( s );
    	}

    	final boolean	envClasspathIgnored = jc.getEnvClasspathIgnored();
    	jc.setEnvClasspathIgnored( envClasspathIgnored );

    	s   = jc.getJavaHome();
    	if ( s != null )
    	{
    	    jc.setJavaHome( s );
    	}

    	s   = jc.getJavacOptions();
    	if ( s != null )
    	{
    	    jc.setJavacOptions( s );
    	}

    	final String[]	options = jc.getJVMOptions();
    	if ( options != null )
    	{
    	    jc.setJVMOptions( options );
    	}

    	s   = jc.getNativeLibraryPathPrefix();
    	if ( s != null )
    	{
    	    jc.setNativeLibraryPathPrefix( s );
    	}

    	s   = jc.getNativeLibraryPathSuffix();
    	if ( s != null )
    	{
    	    jc.setNativeLibraryPathSuffix( s );
    	}

    	s   = jc.getRMICOptions();
    	if ( s != null )
    	{
    	    jc.setRMICOptions( s );
    	}

    	s   = jc.getServerClasspath();
    	if ( s != null )
    	{
    	    jc.setServerClasspath( s );
    	}
	
public voidtestSetJVMOptions()

	    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 ) );