PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/apache-log4j-1.2.17/tests/src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java

#
Java | 66 lines | 35 code | 9 blank | 22 comment | 8 complexity | 4ff1258d1e46d62bec59079967afa56b MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.log4j.util;
  18. import org.apache.oro.text.perl.Perl5Util;
  19. public class EnhancedJunitTestRunnerFilter implements Filter {
  20. private Perl5Util util = new Perl5Util();
  21. private static final String[] PATTERNS = {
  22. "at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner",
  23. "at org.apache.tools.ant",
  24. "at junit.textui.TestRunner",
  25. "at com.intellij.rt.execution.junit",
  26. "at java.lang.reflect.Method.invoke",
  27. "at org.apache.maven.",
  28. "at org.codehaus.",
  29. "at org.junit.internal.runners.",
  30. "at junit.framework.JUnit4TestAdapter"
  31. };
  32. public EnhancedJunitTestRunnerFilter() {
  33. }
  34. /**
  35. * Filter out stack trace lines coming from the various JUnit TestRunners.
  36. */
  37. public String filter(String in) {
  38. if (in == null) {
  39. return null;
  40. }
  41. //
  42. // restore the one instance of Method.invoke that we actually want
  43. //
  44. if (in.indexOf("at junit.framework.TestCase.runTest") != -1) {
  45. return "\tat java.lang.reflect.Method.invoke(X)\n\t" + in.trim();
  46. }
  47. for (int i = 0; i < PATTERNS.length; i++) {
  48. if(in.indexOf(PATTERNS[i]) != -1) {
  49. return null;
  50. }
  51. }
  52. if (util.match("/\\sat /", in)) {
  53. return "\t" + in.trim();
  54. }
  55. return in;
  56. }
  57. }