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 IllegalClassExceptionTest 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(IllegalClassExceptionTest.class); 38 } 39 40 public IllegalClassExceptionTest(String testName) { 41 super(testName); 42 } 43 44 46 public void testConstructor_classArgs_allNullInput() { 47 new IllegalClassException(null, null); 48 } 49 50 public void testConstructor_classArgs_nullExpected() { 51 new IllegalClassException(null, String .class); 52 } 53 54 public void testConstructor_classArgs_nullActual() { 55 new IllegalClassException(String .class, null); 56 } 57 58 60 public void testConstructor_stringArg_nullInput() { 61 new IllegalClassException(null); 62 } 63 64 66 public void testGetMessage_classArgs_nullInput() { 67 final Throwable t = new IllegalClassException(null, null); 68 assertEquals("Expected: null, actual: null", t.getMessage()); 69 } 70 71 public void testGetMessage_classArgs_normalInput() { 72 final Throwable t = 73 new IllegalClassException(String .class, Integer .class); 74 assertEquals( 75 "Expected: java.lang.String, actual: java.lang.Integer", 76 t.getMessage()); 77 } 78 79 public void testGetMessage_stringArg_nullInput() { 80 final Throwable t = new IllegalClassException(null); 81 assertEquals(null, t.getMessage()); 82 } 83 84 public void testGetMessage_stringArg_validInput() { 85 final String message = "message"; 86 final Throwable t = new IllegalClassException(message); 87 assertEquals(message, t.getMessage()); 88 } 89 90 } | Popular Tags |