1 package junit.tests.runner; 2 3 import java.io.*; 4 import junit.framework.*; 5 import junit.runner.BaseTestRunner; 6 7 public class StackFilterTest extends TestCase { 8 String fFiltered; 9 String fUnfiltered; 10 11 protected void setUp() { 12 StringWriter swin= new StringWriter(); 13 PrintWriter pwin= new PrintWriter(swin); 14 pwin.println("junit.framework.AssertionFailedError"); 15 pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); 16 pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); 17 pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); 18 pwin.println(" at MyTest.f(MyTest.java:13)"); 19 pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); 20 pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); 21 pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); 22 pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); 23 pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); 24 pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); 25 pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); 26 pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); 27 pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); 28 pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); 29 pwin.println(" at junit.swingui.TestRunner$17.run(TestRunner.java:669)"); 30 fUnfiltered= swin.toString(); 31 32 StringWriter swout= new StringWriter(); 33 PrintWriter pwout= new PrintWriter(swout); 34 pwout.println("junit.framework.AssertionFailedError"); 35 pwout.println(" at MyTest.f(MyTest.java:13)"); 36 pwout.println(" at MyTest.testStackTrace(MyTest.java:8)"); 37 fFiltered= swout.toString(); 38 } 39 40 public void testFilter() { 41 assertEquals(fFiltered, BaseTestRunner.getFilteredTrace(fUnfiltered)); 42 } 43 } | Popular Tags |