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 import org.apache.commons.lang.exception.Nestable; 23 24 31 public class UnhandledExceptionTest extends TestCase { 32 33 public static void main(String [] args) { 34 TestRunner.run(suite()); 35 } 36 37 public static Test suite() { 38 return new TestSuite(UnhandledExceptionTest.class); 39 } 40 41 public UnhandledExceptionTest(String testName) { 42 super(testName); 43 } 44 45 47 public void testConstructor_throwable_nullInput() { 48 final Throwable t = null; 49 new UnhandledException(t); 50 } 51 52 public void testConstructor_stringAndThrowable_nullInput() { 53 new UnhandledException(null, null); 54 } 55 56 58 public void testGetCause() { 59 final Throwable t = new NullPointerException (); 60 final Nestable n = new UnhandledException(t); 61 assertEquals(t, n.getCause()); 62 } 63 64 public void testGetCauseAndGetMessage() { 65 final Throwable t = new NullPointerException (); 66 final String msg = "nullArg"; 67 final Nestable n = new UnhandledException(msg, t); 68 assertEquals(t, n.getCause()); 69 assertEquals(msg, n.getMessage()); 70 } 71 72 } | Popular Tags |