1 21 22 package nu.xom.tests; 23 24 import nu.xom.xslt.XSLException; 25 26 35 public class XSLExceptionTest extends XOMTestCase { 36 37 private XSLException ex; 38 private Exception cause; 39 40 public XSLExceptionTest(String name) { 41 super(name); 42 } 43 44 protected void setUp() { 45 ex = new XSLException("message"); 46 cause = new Exception (); 47 } 48 49 public void testConstructor() { 50 String message = "testing 1-2-3"; 51 XSLException ex = new XSLException(message, cause); 52 assertEquals(message, ex.getMessage()); 53 assertEquals(cause, ex.getCause()); 54 } 55 56 public void testInitCause() { 57 58 assertNull(ex.getCause()); 59 ex.initCause(cause); 60 assertEquals(cause, ex.getCause()); 61 62 try { 63 ex.initCause(null); 64 fail("Reinitialized cause over null"); 65 } 66 catch (IllegalStateException success) { 67 assertNotNull(success.getMessage()); 69 } 70 71 try { 72 ex.initCause(new Exception ()); 73 fail("Reinitialized cause over null"); 74 } 75 catch (IllegalStateException success) { 76 assertNotNull(success.getMessage()); 78 } 79 80 } 81 82 83 public void testNullInitCause() { 84 85 XSLException ex = new XSLException(null, null); 86 assertNull(ex.getCause()); 87 88 try { 89 ex.initCause(new Exception ()); 90 fail("Reinitialized cause over null"); 91 } 92 catch (IllegalStateException result) { 93 } 95 96 try { 97 ex.initCause(null); 98 fail("Reinitialized cause over null"); 99 } 100 catch (IllegalStateException result) { 101 } 103 104 } 105 106 public void testSelfCause() { 107 108 try { 109 ex.initCause(ex); 110 fail("Allowed self-causation"); 111 } 112 catch (IllegalArgumentException result) { 113 } 115 116 } 117 118 public void testGetMessage() { 119 Exception ex = new XSLException("testing"); 120 assertEquals("testing", ex.getMessage()); 121 } 122 123 } 124 | Popular Tags |