1 package junitx.runner.util; 2 3 import java.io.PrintWriter ; 4 import java.io.StringWriter ; 5 import java.util.Properties ; 6 7 import junit.framework.TestCase; 8 9 13 public class StackFilterTest extends TestCase { 14 15 public void testFilter() throws Exception { 16 StackFilter stack = new StackFilter(); 17 assertNotNull("stack should not be null", stack); 18 stack.init(new Properties ()); 19 20 StringWriter writer = new StringWriter (); 21 PrintWriter pwin = new PrintWriter (writer); 22 pwin.println("junit.framework.AssertionFailedError"); 23 pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); 24 pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); 25 pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); 26 pwin.println(" at MyTest.f(MyTest.java:13)"); 27 pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); 28 pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); 29 pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); 30 pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); 31 pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); 32 pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); 33 pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); 34 pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); 35 pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); 36 pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); 37 pwin.println(" at junitx.runner.TestRunner$17.run(TestRunner.java:669)"); 38 String fUnfiltered = writer.toString(); 39 40 writer = new StringWriter (); 41 PrintWriter expected = new PrintWriter (writer); 42 expected.println("junit.framework.AssertionFailedError"); 43 expected.println(" at MyTest.f(MyTest.java:13)"); 44 expected.println(" at MyTest.testStackTrace(MyTest.java:8)"); 45 String fFiltered = writer.toString(); 46 47 assertEquals(fFiltered, stack.filterStack(fUnfiltered)); 48 } 49 50 } | Popular Tags |