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 java.util.Vector ; 40 45 46 51 52 public class DottedNamesCommandTest extends TestCase { 53 54 public void testcheckPropertyToConvertValid() throws Exception { 55 assertEquals(testCommand.checkPropertyToConvert("server.jdbc-resource.jdbc1.property"), true); 56 } 57 58 public void testcheckPropertyToConvertInvalid() throws Exception { 59 assertEquals(testCommand.checkPropertyToConvert("server.jdbc-resource.jdbc1.property.xyz"), false); 60 } 61 62 public void testconvertUnderscoreToHyphenWithEquals() throws Exception { 63 String value = testCommand.convertUnderscoreToHyphen("server.jdbc-resource.jdbc1.attr_1=value"); 64 assertEquals(value, "server.jdbc-resource.jdbc1.attr-1=value"); 65 66 } 67 68 public void testconvertUnderscoreToHyphenWithoutEquals() throws Exception { 69 70 String value = testCommand.convertUnderscoreToHyphen("server.jdbc-resource.jdbc1.attr_1"); 71 assertEquals(value, "server.jdbc-resource.jdbc1.attr-1"); 72 73 } 74 75 public void testValidateOptionsWithFailureCase() throws Exception { 76 testCommand.setName("get"); 77 testCommand.setOption("monitor", "true"); 78 testCommand.setOption("iterations", "1"); 79 testCommand.setOption("interval", "0"); 80 assertEquals(testCommand.validateOptions(), false); 81 } 82 83 public void testValidateOptions() throws Exception { 84 testCommand.setName("set"); 85 assertEquals(testCommand.validateOptions(), true); 86 } 87 88 public DottedNamesCommandTest(String name){ 89 super(name); 90 } 91 92 DottedNamesCommand testCommand = null; 93 94 protected void setUp() throws Exception { 95 final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance(); 100 ValidCommand validCommand = cliDescriptorsReader.getCommand(null); 101 LocalStringsManagerFactory.setCommandLocalStringsManagerProperties( 102 CLIDescriptorsReader.getInstance().getProperties()); 103 testCommand = new DottedNamesCommand(); 104 testCommand.setName("sampleCommand"); 105 } 106 107 108 109 protected void tearDown() { 110 } 111 112 private void nyi(){ 113 fail("Not Yet Implemented"); 114 } 115 116 public static Test suite(){ 117 TestSuite suite = new TestSuite(BackupCommandsTest.class); 118 return suite; 119 } 120 121 public static void main(String args[]) throws Exception { 122 final TestRunner runner= new TestRunner(); 123 final TestResult result = runner.doRun(BackupCommandsTest.suite(), false); 124 System.exit(result.errorCount() + result.failureCount()); 125 } 126 } 127 128 | Popular Tags |