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 45 46 51 52 57 58 public class GetClientStubsCommandTest extends TestCase { 59 60 public void testvalidateOptionsValid() throws Exception { 61 Vector operands = new Vector (); 62 operands.add(System.getProperty("java.io.tmpdir")); 63 testCommand.setOperands(operands); 64 assertEquals(testCommand.validateOptions(), true); 65 } 66 67 public void testvalidateOptionsInvalidDirectory() throws Exception { 68 final String enc = "ISO-8859-1"; 70 final File f = new File (System.getProperty("java.io.tmpdir"), 71 "ordinaryFile"); 72 f.deleteOnExit(); 73 final PrintWriter pw = new PrintWriter ( 74 new OutputStreamWriter (new FileOutputStream (f), enc)); 75 pw.println("xyz"); 76 pw.close(); 77 Vector operands = new Vector (); 78 operands.add(f.getAbsolutePath()); 79 testCommand.setOperands(operands); 80 try{ 81 testCommand.validateOptions(); 82 }catch (CommandValidationException cve){ 83 assertEquals(cve.getMessage(), "CLI153 " + f.getAbsolutePath() + 84 " does not exist or does not have write permission"); 85 } 86 } 87 88 public GetClientStubsCommandTest(String name){ 89 super(name); 90 } 91 92 GetClientStubsCommand 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 GetClientStubsCommand(); 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(GetClientStubsCommandTest.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(GetClientStubsCommandTest.suite(), false); 124 System.exit(result.errorCount() + result.failureCount()); 125 } 126 } 127 128 | Popular Tags |