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 GenerateJVMReportCommandTest extends TestCase { 57 58 public void testvalidateOptionsValid() throws Exception { 59 testCommand.setOption("type", "summary"); 60 assertEquals(testCommand.validateOptions(), true); 61 } 62 63 public void testvalidateOptionsInvalidType() throws Exception { 64 testCommand.setOption("type", "invalidOperation"); 65 try{ 66 testCommand.validateOptions(); 67 }catch (CommandValidationException cve){ 68 assertEquals(cve.getMessage(), "CLI165 Invalid type option value. "); 69 } 70 71 } 72 73 public void testgetOperationNameValid() throws Exception { 74 testCommand.setOption("type", "thread"); 75 assertEquals(testCommand.validateOptions(), true); 76 assertEquals(testCommand.getOperationName(), "getThreadDump"); 77 } 78 79 public GenerateJVMReportCommandTest(String name){ 80 super(name); 81 } 82 83 GenerateJVMReportCommand testCommand = null; 84 85 protected void setUp() throws Exception { 86 final CLIDescriptorsReader cliDescriptorsReader = CLIDescriptorsReader.getInstance(); 91 ValidCommand validCommand = cliDescriptorsReader.getCommand(null); 92 LocalStringsManagerFactory.setCommandLocalStringsManagerProperties( 93 CLIDescriptorsReader.getInstance().getProperties()); 94 testCommand = new GenerateJVMReportCommand(); 95 testCommand.setName("sampleCommand"); 96 } 97 98 99 100 protected void tearDown() { 101 } 102 103 private void nyi(){ 104 fail("Not Yet Implemented"); 105 } 106 107 public static Test suite(){ 108 TestSuite suite = new TestSuite(GenerateJVMReportCommandTest.class); 109 return suite; 110 } 111 112 public static void main(String args[]) throws Exception { 113 final TestRunner runner= new TestRunner(); 114 final TestResult result = runner.doRun(GenerateJVMReportCommandTest.suite(), false); 115 System.exit(result.errorCount() + result.failureCount()); 116 } 117 } 118 119 | Popular Tags |