1 61 62 package org.jaxen; 63 64 65 import java.io.PrintWriter ; 66 import java.io.StringWriter ; 67 68 import junit.framework.TestCase; 69 70 71 75 public class JaxenRuntimeExceptionTest extends TestCase { 76 77 public JaxenRuntimeExceptionTest(String name) { 78 super(name); 79 } 80 81 public void testMessageIsNonNull() { 82 83 JaxenException ex = new JaxenException("Hello"); 84 JaxenRuntimeException rex = new JaxenRuntimeException(ex); 85 assertEquals(ex.getMessage(), rex.getMessage()); 86 assertEquals(ex, rex.getCause()); 87 88 } 89 90 public void testPrintStackTrace() { 91 JaxenException cause = new JaxenException("1234"); 92 JaxenRuntimeException ex = new JaxenRuntimeException(cause); 93 StringWriter out = new StringWriter (); 94 PrintWriter pw = new PrintWriter (out); 95 ex.printStackTrace(pw); 96 pw.close(); 97 assertTrue(out.toString().indexOf("Caused by: org.jaxen.JaxenException") > 0); 98 assertTrue(out.toString().indexOf("1234") > 0); 99 } 100 101 } 102 | Popular Tags |