1 16 package org.apache.commons.lang; 17 18 import junit.framework.Test; 19 import junit.framework.TestCase; 20 import junit.framework.TestSuite; 21 import junit.textui.TestRunner; 22 23 30 public class IncompleteArgumentExceptionTest extends TestCase { 31 32 public static void main(String [] args) { 33 TestRunner.run(suite()); 34 } 35 36 public static Test suite() { 37 return new TestSuite(IncompleteArgumentExceptionTest.class); 38 } 39 40 public IncompleteArgumentExceptionTest(String testName) { 41 super(testName); 42 } 43 44 46 public void test1arg_nullInput() { 47 final Throwable t = new IncompleteArgumentException(null); 48 assertEquals("null is incomplete.", t.getMessage()); 49 } 50 51 public void test1arg_validInput() { 52 final String name = "argument"; 53 final Throwable t = new IncompleteArgumentException(name); 54 assertEquals(name + " is incomplete.", t.getMessage()); 55 } 56 57 public void test2arg_allNullInput() { 58 final Throwable t = new IncompleteArgumentException(null, null); 59 assertEquals( 60 "null is missing the following items: null", 61 t.getMessage()); 62 } 63 64 public void test2arg_nullString() { 65 final Throwable t = 66 new IncompleteArgumentException( 67 null, 68 new String [] { "one", "two" }); 69 assertEquals( 70 "null is missing the following items: [one, two]", 71 t.getMessage()); 72 } 73 74 public void test2arg_nullArray() { 75 final String name = "one"; 76 final Throwable t = new IncompleteArgumentException(name, null); 77 assertEquals( 78 name + " is missing the following items: null", 79 t.getMessage()); 80 } 81 82 public void test2arg_validInput() { 83 final String name = "input"; 84 final Throwable t = 85 new IncompleteArgumentException( 86 name, 87 new String [] { "one", "two" }); 88 assertEquals( 89 name + " is missing the following items: [one, two]", 90 t.getMessage()); 91 } 92 93 } | Popular Tags |