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

DeployCommandTest

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

Fields Summary
DeployCommand
testCommand
Constructors Summary
public DeployCommandTest(String name)

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

        final TestRunner runner= new TestRunner();
        final TestResult result = runner.doRun(BackupCommandsTest.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 DeployCommand();
        testCommand.setName("sampleCommand");
    
public static junit.framework.Testsuite()

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

    
public voidtestCreateDeploymentProperties()

            //set options that has option values
            testCommand.setOption("name", "foobar");
            testCommand.setOption("verify", "true");
            testCommand.setOption("precompilejsp", "true");
            testCommand.setOption("enabled", "true");
            testCommand.setOption("force", "true");
            testCommand.setOption("availabilityenabled", "true");
            testCommand.setOption("generatermistubs", "true");
            testValidateOptionsValidOptions();
            testCommand.validateOptions();

                //use refection since createDeploymentProperties is a private method
            final Method[] methods = testCommand.getClass().getDeclaredMethods();
            Map<String, String> map = null;
            
            for (Method method : methods) {
                if (method.getName().equals("createDeploymentProperties")) {
                    method.setAccessible(true);
                    map = (Map)method.invoke(testCommand, new Object[]{});
                }
                
            }

            assertEquals("value for name is foobar", "foobar", map.get("name"));
            assertEquals("value for verify is true", "true", map.get("verify"));
            assertEquals("value for precompilejsp is true", "true", map.get("precompilejsp"));
            assertEquals("value for enable is true", "true", map.get("enable"));
            assertEquals("value for availabilityenabled is true", "true", map.get("availabilityenabled"));
            assertEquals("value for generatermistubs is true", "true", map.get("generatermistubs"));
    
public voidtestValidateOptionsInvalidOptions()

        try{
            testCommand.setOption("createtables", "true");
            testCommand.setOption("dropandcreatetables", "true");
            testCommand.validateOptions();
        }
        catch (CommandValidationException cve){
            assertEquals(cve.getMessage(), 
            "CLI169 Options createtables and dropandcreatetables are mutually exclusive.  You must specify one or the other but not both.");
        }
    
public voidtestValidateOptionsValidOptions()

            Vector operands = new Vector();
            operands.add("earFile");
            testCommand.setOperands(operands);
            testCommand.validateOptions();