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 import java.io.File ; 41 import java.io.PrintWriter ; 42 import java.io.OutputStreamWriter ; 43 import java.io.FileOutputStream ; 44 49 50 55 56 public class GenerateReportCommandTest extends TestCase { 57 58 public void testvalidateOptionsValid() throws Exception { 59 testCommand.setOption("local", "true"); 60 testCommand.setOption("targetdir", "currentdir"); 61 testCommand.setOption("logstartdate", "10202004"); 62 testCommand.setOption("logenddate", "10212004"); 63 assertEquals(testCommand.validateOptions(), true); 64 } 65 66 public void testvalidateOptionsInvalidTarget() throws Exception { 67 try{ 68 testCommand.setOption("local", "true"); 69 testCommand.validateOptions(); 70 }catch (CommandValidationException cve){ 71 assertEquals(cve.getMessage(), "CLI179 option targetdir required in local mode"); 72 } 73 74 } 75 76 public void testvalidateOptionsInvalidLogEndDate() throws Exception { 77 try{ 78 testCommand.setOption("local", "true"); 79 testCommand.setOption("targetdir", "currentdir"); 80 testCommand.setOption("logstartdate", "10202004"); 81 testCommand.validateOptions(); 82 }catch (CommandValidationException cve){ 83 assertEquals(cve.getMessage(), "optionrequiredwithoption"); 84 } 85 } 86 87 public GenerateReportCommandTest(String name){ 88 super(name); 89 } 90 91 GenerateReportCommand testCommand = null; 92 93 protected void setUp() throws Exception { 94 final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance(); 99 ValidCommand validCommand = cliDescriptorsReader.getCommand(null); 100 LocalStringsManagerFactory.setCommandLocalStringsManagerProperties( 101 CLIDescriptorsReader.getInstance().getProperties()); 102 testCommand = new GenerateReportCommand(); 103 testCommand.setName("sampleCommand"); 104 } 105 106 107 108 protected void tearDown() { 109 } 110 111 private void nyi(){ 112 fail("Not Yet Implemented"); 113 } 114 115 public static Test suite(){ 116 TestSuite suite = new TestSuite(GenerateReportCommandTest.class); 117 return suite; 118 } 119 120 public static void main(String args[]) throws Exception { 121 final TestRunner runner= new TestRunner(); 122 final TestResult result = runner.doRun(GenerateReportCommandTest.suite(), false); 123 System.exit(result.errorCount() + result.failureCount()); 124 } 125 } 126 127 | Popular Tags |