FileDocCategorySizeDatePackage
UnsetCommandTest.javaAPI DocGlassfish v2 API6389Fri May 04 22:25:18 BST 2007com.sun.enterprise.cli.commands

UnsetCommandTest

public class UnsetCommandTest extends TestCase
Execute these tests using gmake (and Ant) by: cd gmake ANT_TARGETS=CommandTest.java

Fields Summary
UnsetCommand
testCommand
Constructors Summary
public UnsetCommandTest(String name)

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        final TestRunner runner= new TestRunner();
        final TestResult result = runner.doRun(UnsetCommandTest.suite(), false);
        System.exit(result.errorCount() + result.failureCount());
    
private voidnyi()

        fail("Not Yet Implemented");
    
protected voidsetUp()


        
        //Properties systemProperties = new java.util.Propertis();
        //systemProperties.put("com.sun.aas.configRoot",)
        //String configProperty = SystemPropertyConstants.CONFIG_ROOT_PROPERTY;
        //System.out.println(configProperty + " = " + System.getProperty(configProperty));
        final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance();
        ValidCommand validCommand = cliDescriptorsReader.getCommand(null);
        LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(
            CLIDescriptorsReader.getInstance().getProperties());
        testCommand = new UnsetCommand();
        testCommand.setName("sampleCommand");
    
public static junit.framework.Testsuite()

        TestSuite suite = new TestSuite(UnsetCommandTest.class);
        return suite;
    
protected voidtearDown()

    
public voidtestrunCommandInvalidPrefix()

        try{
            Vector operands = new Vector();
            operands.add("_ADMIN_INTERACTIVE");
            testCommand.setOperands(operands);
            testCommand.runCommand();
        }catch(CommandException ce){
            assertEquals(ce.getMessage(), "CLI163 Could not unset environment variable, _ADMIN_INTERACTIVE.");
        }
    
public voidtestrunCommandRemoveEnvVariables()

        Vector operands = new Vector();
        System.setProperty("user.home", System.getProperty("java.io.tmpdir"));//tempDir.getPath());
        operands.add("AS_ADMIN_USER");
        operands.add("AS_ADMIN_PASSWORD");
        testCommand.setOperands(operands);
        CommandEnvironment.getInstance().setEnvironment("user", "admin");
        CommandEnvironment.getInstance().setEnvironment("password", "adminadmin");
        testCommand.runCommand();
        assertEquals(testCommand.getOption("user"), null);
        assertEquals(testCommand.getOption("password"), null);
    
public voidtestrunCommandRemoveEnvVariablesWithWildCard()

        Vector operands = new Vector();
        System.setProperty("user.home", System.getProperty("java.io.tmpdir"));
        operands.add("AS_ADMIN_*");
        testCommand.setOperands(operands);
        CommandEnvironment.getInstance().setEnvironment("user", "admin");
        CommandEnvironment.getInstance().setEnvironment("password", "adminadmin");
        testCommand.runCommand();
        assertEquals(testCommand.getOption("user"), null);
        assertEquals(testCommand.getOption("password"), null);
    
public voidtestrunCommandRemoveNonExistingEnvVariable()

        try{
            Vector operands = new Vector();
            operands.add("AS_ADMIN_INTERACTIVE");
            testCommand.setOperands(operands);
            testCommand.runCommand();
        }catch(CommandException ce){
            assertEquals(ce.getMessage(), "CLI149 Unable to remove environment variable, " +
                    "AS_ADMIN_INTERACTIVE.");
        }