1 23 24 package com.sun.enterprise.cli.framework; 25 26 import junit.framework.*; 27 32 33 public class CommandExceptionTest extends TestCase { 34 public void testFullConstructor(){ 35 final String message = "m"; 36 final Throwable t = new Throwable (); 37 CommandException ce = new CommandException(message, t); 38 assertEquals(message, ce.getMessage()); 39 assertEquals(t, ce.getCause()); 40 } 41 42 public void testEmptyConstructor(){ 43 CommandException ce = new CommandException(); 44 assertNull(ce.getMessage()); 45 } 46 47 public void testEncapsulatedException() { 48 final NullPointerException npe = new NullPointerException ("a null pointer"); 49 CommandException ce = new CommandException(npe); 50 assertEquals("java.lang.NullPointerException: a null pointer", ce.getMessage()); 51 assertEquals(npe, ce.getCause()); 52 } 53 54 public void testSimple() { 55 CommandException ce = new CommandException("this is the message"); 56 assertEquals("this is the message", ce.getMessage()); 57 } 58 59 public CommandExceptionTest(String name){ 60 super(name); 61 } 62 63 protected void setUp() { 64 } 65 66 protected void tearDown() { 67 } 68 69 private void nyi(){ 70 fail("Not Yet Implemented"); 71 } 72 73 public static void main(String args[]){ 74 if (args.length == 0){ 75 junit.textui.TestRunner.run(CommandExceptionTest.class); 76 } else { 77 junit.textui.TestRunner.run(makeSuite(args)); 78 } 79 } 80 private static TestSuite makeSuite(String args[]){ 81 final TestSuite ts = new TestSuite(); 82 for (int i = 0; i < args.length; i++){ 83 ts.addTest(new CommandExceptionTest(args[i])); 84 } 85 return ts; 86 } 87 } 88 | Popular Tags |