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

CreateMBeanCommandTest

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

Fields Summary
CreateMBeanCommand
testCommand
Constructors Summary
public CreateMBeanCommandTest(String name)

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

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

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

    
public voidtestgetParamsInfo()

        testCommand.setOption(testCommand.TARGET_OPTION, "server");
        testCommand.setOption(testCommand.NAME_OPTION, "name");
        testCommand.setOption(testCommand.OBJECT_NAME_OPTION, "objName1");
        Vector operands = new Vector();
        operands.add("impl1");
        testCommand.setOperands(operands);
        testCommand.setOption("attributes", "attr1=value1:attr2=value2");
        Object[] params = testCommand.getParamsInfo();
        Map mbeanParams = (Map) params[1];
        Map attributesList = (Map) params[2];
        assertEquals(params[0], "server");
        assertEquals(mbeanParams.get(ServerTags.IMPL_CLASS_NAME), "impl1");
        assertEquals(mbeanParams.get(ServerTags.OBJECT_NAME), "objName1");
        assertEquals(mbeanParams.get(ServerTags.NAME), "name");
        assertEquals(attributesList.get("attr1"), "value1");
        assertEquals(attributesList.get("attr2"), "value2");
    
public voidtestgetParamsInfoWithInvalidAttrs()

        //testCommand.setOption(testCommand.TARGET_OPTION, "server");
        //testCommand.setOption(testCommand.NAME_OPTION, "name");
        //testCommand.setOption(testCommand.OBJECT_NAME_OPTION, "objName1");
        Vector operands = new Vector();
        operands.add("impl1");
        testCommand.setOperands(operands);
        testCommand.setOption("attributes", "attr1=value1attr2=value2");
        try{
            Object[] params = testCommand.getParamsInfo();
        }catch (CommandValidationException cve){
            assertEquals(cve.getMessage(), "CLI178 Invalid attribute syntax.");
        }