1 23 package com.sun.enterprise.cli.commands; 24 25 31 import com.sun.enterprise.cli.framework.*; 32 import junit.framework.*; 38 import junit.textui.TestRunner; 39 import com.sun.enterprise.util.SystemPropertyConstants; 40 import com.sun.enterprise.admin.servermgmt.DomainConfig; 41 import com.sun.enterprise.admin.servermgmt.pe.PEFileLayout; 42 import com.sun.enterprise.config.serverbeans.ServerTags; 43 44 import java.io.File ; 45 import java.io.PrintWriter ; 46 import java.io.OutputStreamWriter ; 47 import java.io.FileOutputStream ; 48 import java.util.Vector ; 49 import java.util.Map ; 50 51 56 57 62 63 public class CreateMBeanCommandTest extends TestCase { 64 65 public CreateMBeanCommandTest(String name){ 66 super(name); 67 } 68 69 public void testgetParamsInfoWithInvalidAttrs() throws Exception { 70 Vector operands = new Vector (); 74 operands.add("impl1"); 75 testCommand.setOperands(operands); 76 testCommand.setOption("attributes", "attr1=value1attr2=value2"); 77 try{ 78 Object [] params = testCommand.getParamsInfo(); 79 }catch (CommandValidationException cve){ 80 assertEquals(cve.getMessage(), "CLI178 Invalid attribute syntax."); 81 } 82 83 84 } 85 86 public void testgetParamsInfo() throws Exception { 87 testCommand.setOption(testCommand.TARGET_OPTION, "server"); 88 testCommand.setOption(testCommand.NAME_OPTION, "name"); 89 testCommand.setOption(testCommand.OBJECT_NAME_OPTION, "objName1"); 90 Vector operands = new Vector (); 91 operands.add("impl1"); 92 testCommand.setOperands(operands); 93 testCommand.setOption("attributes", "attr1=value1:attr2=value2"); 94 Object [] params = testCommand.getParamsInfo(); 95 Map mbeanParams = (Map ) params[1]; 96 Map attributesList = (Map ) params[2]; 97 assertEquals(params[0], "server"); 98 assertEquals(mbeanParams.get(ServerTags.IMPL_CLASS_NAME), "impl1"); 99 assertEquals(mbeanParams.get(ServerTags.OBJECT_NAME), "objName1"); 100 assertEquals(mbeanParams.get(ServerTags.NAME), "name"); 101 assertEquals(attributesList.get("attr1"), "value1"); 102 assertEquals(attributesList.get("attr2"), "value2"); 103 } 104 105 CreateMBeanCommand testCommand = null; 106 107 protected void setUp() throws Exception { 108 final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance(); 113 ValidCommand validCommand = cliDescriptorsReader.getCommand(null); 114 LocalStringsManagerFactory.setCommandLocalStringsManagerProperties( 115 CLIDescriptorsReader.getInstance().getProperties()); 116 testCommand = new CreateMBeanCommand(); 117 testCommand.setName("sampleCommand"); 118 } 119 120 121 122 protected void tearDown() { 123 } 124 125 private void nyi(){ 126 fail("Not Yet Implemented"); 127 } 128 129 public static Test suite(){ 130 TestSuite suite = new TestSuite(BackupCommandsTest.class); 131 return suite; 132 } 133 134 public static void main(String args[]) throws Exception { 135 final TestRunner runner= new TestRunner(); 136 final TestResult result = runner.doRun(BaseLifeCycleCommandTest.suite(), false); 137 System.exit(result.errorCount() + result.failureCount()); 138 } 139 } 140 141 | Popular Tags |