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