1 package junit.tests; 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 public StackFilterTest(String name) { 12 super(name); 13 } 14 15 protected void setUp() { 16 StringWriter swin= new StringWriter(); 17 PrintWriter pwin= new PrintWriter(swin); 18 pwin.println("junit.framework.AssertionFailedError"); 19 pwin.println(" at junit.framework.Assert.fail(Assert.java:144)"); 20 pwin.println(" at junit.framework.Assert.assert(Assert.java:19)"); 21 pwin.println(" at junit.framework.Assert.assert(Assert.java:26)"); 22 pwin.println(" at MyTest.f(MyTest.java:13)"); 23 pwin.println(" at MyTest.testStackTrace(MyTest.java:8)"); 24 pwin.println(" at java.lang.reflect.Method.invoke(Native Method)"); 25 pwin.println(" at junit.framework.TestCase.runTest(TestCase.java:156)"); 26 pwin.println(" at junit.framework.TestCase.runBare(TestCase.java:130)"); 27 pwin.println(" at junit.framework.TestResult$1.protect(TestResult.java:100)"); 28 pwin.println(" at junit.framework.TestResult.runProtected(TestResult.java:118)"); 29 pwin.println(" at junit.framework.TestResult.run(TestResult.java:103)"); 30 pwin.println(" at junit.framework.TestCase.run(TestCase.java:121)"); 31 pwin.println(" at junit.framework.TestSuite.runTest(TestSuite.java:157)"); 32 pwin.println(" at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)"); 33 pwin.println(" at junit.swingui.TestRunner$17.run(TestRunner.java:669)"); 34 fUnfiltered= swin.toString(); 35 36 StringWriter swout= new StringWriter(); 37 PrintWriter pwout= new PrintWriter(swout); 38 pwout.println("junit.framework.AssertionFailedError"); 39 pwout.println(" at MyTest.f(MyTest.java:13)"); 40 pwout.println(" at MyTest.testStackTrace(MyTest.java:8)"); 41 fFiltered= swout.toString(); 42 } 43 44 public void testFilter() { 45 assertEquals(fFiltered, BaseTestRunner.filterStack(fUnfiltered)); 46 } 47 } | Popular Tags |