1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.util;
19
20 import org.apache.oro.text.perl.Perl5Util;
21
22
23 public class EnhancedJunitTestRunnerFilter implements Filter {
24 private Perl5Util util = new Perl5Util();
25
26 private static final String[] PATTERNS = {
27 "at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner",
28 "at org.apache.tools.ant",
29 "at junit.textui.TestRunner",
30 "at com.intellij.rt.execution.junit",
31 "at java.lang.reflect.Method.invoke",
32 "at org.apache.maven.",
33 "at org.codehaus.",
34 "at org.junit.internal.runners.",
35 "at junit.framework.JUnit4TestAdapter"
36 };
37
38 public EnhancedJunitTestRunnerFilter() {
39 }
40
41
42
43
44 public String filter(String in) {
45 if (in == null) {
46 return null;
47 }
48
49
50
51
52 if (in.indexOf("at junit.framework.TestCase.runTest") != -1) {
53 return "\tat java.lang.reflect.Method.invoke(X)\n\t" + in.trim();
54 }
55
56 for (int i = 0; i < PATTERNS.length; i++) {
57 if(in.indexOf(PATTERNS[i]) != -1) {
58 return null;
59 }
60 }
61 if (util.match("/\\sat /", in)) {
62 return "\t" + in.trim();
63 }
64 return in;
65 }
66 }