KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junitx > runner > util > StackFilterTest


1 package junitx.runner.util;
2
3 import java.io.PrintWriter JavaDoc;
4 import java.io.StringWriter JavaDoc;
5 import java.util.Properties JavaDoc;
6
7 import junit.framework.TestCase;
8
9 /**
10  * @version $Id: StackFilterTest.java,v 1.3 2003/05/08 02:51:16 vbossica Exp $
11  * @author <a HREF="mailto:vbossica@users.sourceforge.net">Vladimir Ritz Bossicard</a>
12  */

13 public class StackFilterTest extends TestCase {
14
15     public void testFilter() throws Exception JavaDoc {
16         StackFilter stack = new StackFilter();
17         assertNotNull("stack should not be null", stack);
18         stack.init(new Properties JavaDoc());
19
20         StringWriter JavaDoc writer = new StringWriter JavaDoc();
21         PrintWriter JavaDoc pwin = new PrintWriter JavaDoc(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 JavaDoc fUnfiltered = writer.toString();
39
40         writer = new StringWriter JavaDoc();
41         PrintWriter JavaDoc expected = new PrintWriter JavaDoc(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 JavaDoc fFiltered = writer.toString();
46
47         assertEquals(fFiltered, stack.filterStack(fUnfiltered));
48     }
49
50 }
Popular Tags