ceki 2002/11/13 08:44:58 Modified: tests/src/java/org/apache/log4j MinimumTestCase.java PatternLayoutTestCase.java tests/src/java/org/apache/log4j/customLogger XLoggerTestCase.java tests/src/java/org/apache/log4j/net SocketServerTestCase.java tests/src/java/org/apache/log4j/util LineNumberFilter.java Transformer.java tests/src/java/org/apache/log4j/varia ErrorHandlerTestCase.java tests/src/java/org/apache/log4j/xml DOMTestCase.java XMLLayoutTestCase.java Added: tests/src/java/org/apache/log4j/util SunReflectFilter.java Log: Added SunReflectFilter.java which removes stack trace lines containing the pattern /at sun.reflect/ This filter has been added to many of our existing test cases in order to compensate the differences between JDK 1.3 and JDK 1.4 allowing them to run on both platforms indiscriminately. Test failures that have been occuring since gump moved to JDK 1.4 should not disappear. Revision Changes Path 1.6 +8 -3 jakarta-log4j/tests/src/java/org/apache/log4j/MinimumTestCase.java Index: MinimumTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/MinimumTestCase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MinimumTestCase.java 12 Apr 2002 15:11:49 -0000 1.5 +++ MinimumTestCase.java 13 Nov 2002 16:44:54 -0000 1.6 @@ -59,7 +59,11 @@ root.addAppender(appender); common(); - Transformer.transform("output/simple", FILTERED, new LineNumberFilter()); + Transformer.transform("output/simple", FILTERED, new Filter[] { + new LineNumberFilter(), + new SunReflectFilter()}); + + assertTrue(Compare.compare(FILTERED, "witness/simple")); } @@ -74,8 +78,9 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform("output/ttcc", FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new AbsoluteDateAndTimeFilter()}); + new LineNumberFilter(), + new AbsoluteDateAndTimeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/ttcc")); } 1.5 +30 -14 jakarta-log4j/tests/src/java/org/apache/log4j/PatternLayoutTestCase.java Index: PatternLayoutTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/PatternLayoutTestCase.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PatternLayoutTestCase.java 16 Apr 2002 14:36:15 -0000 1.4 +++ PatternLayoutTestCase.java 13 Nov 2002 16:44:54 -0000 1.5 @@ -24,6 +24,7 @@ import org.apache.log4j.util.ISO8601Filter; import org.apache.log4j.util.AbsoluteTimeFilter; import org.apache.log4j.util.RelativeTimeFilter; +import org.apache.log4j.util.SunReflectFilter; import org.apache.log4j.util.AbsoluteDateAndTimeFilter; public class PatternLayoutTestCase extends TestCase { @@ -76,7 +77,9 @@ public void test1() throws Exception { PropertyConfigurator.configure("input/patternLayout1.properties"); common(); - Transformer.transform(TEMP, FILTERED, new LineNumberFilter()); + Transformer.transform(TEMP, FILTERED, new Filter[] { + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.1")); } @@ -87,7 +90,8 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new ISO8601Filter()}); + new ISO8601Filter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.2")); } @@ -97,7 +101,8 @@ ControlFilter cf1 = new ControlFilter(new String[]{PAT1, EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new ISO8601Filter()}); + new ISO8601Filter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.3")); } @@ -110,7 +115,8 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new AbsoluteDateAndTimeFilter()}); + new AbsoluteDateAndTimeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.4")); } @@ -121,7 +127,8 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new AbsoluteDateAndTimeFilter()}); + new AbsoluteDateAndTimeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.5")); } @@ -133,7 +140,8 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new AbsoluteTimeFilter()}); + new AbsoluteTimeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.6")); } @@ -145,7 +153,8 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new AbsoluteTimeFilter()}); + new AbsoluteTimeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.7")); } @@ -156,7 +165,8 @@ EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new RelativeTimeFilter()}); + new RelativeTimeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.8")); } @@ -165,7 +175,8 @@ common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT5, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.9")); } @@ -175,7 +186,8 @@ ControlFilter cf1 = new ControlFilter(new String[]{PAT6, EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.10")); } @@ -185,7 +197,8 @@ ControlFilter cf1 = new ControlFilter(new String[]{PAT11a, PAT11b, EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.11")); } @@ -195,7 +208,8 @@ ControlFilter cf1 = new ControlFilter(new String[]{PAT12, EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.12")); } @@ -205,7 +219,8 @@ ControlFilter cf1 = new ControlFilter(new String[]{PAT13, EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.13")); } @@ -215,7 +230,8 @@ ControlFilter cf1 = new ControlFilter(new String[]{PAT14, EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), }); + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.14")); } 1.3 +3 -1 jakarta-log4j/tests/src/java/org/apache/log4j/customLogger/XLoggerTestCase.java Index: XLoggerTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/customLogger/XLoggerTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XLoggerTestCase.java 12 Apr 2002 15:11:49 -0000 1.2 +++ XLoggerTestCase.java 13 Nov 2002 16:44:54 -0000 1.3 @@ -52,7 +52,9 @@ Exception e = new Exception("Just testing"); logger.debug("Message " + ++i, e); - Transformer.transform("output/temp", FILTERED, new LineNumberFilter()); + Transformer.transform("output/temp", FILTERED, new Filter[] { + new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/customLogger."+number)); } 1.4 +16 -8 jakarta-log4j/tests/src/java/org/apache/log4j/net/SocketServerTestCase.java Index: SocketServerTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/net/SocketServerTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SocketServerTestCase.java 9 Oct 2002 22:50:08 -0000 1.3 +++ SocketServerTestCase.java 13 Nov 2002 16:44:54 -0000 1.4 @@ -107,7 +107,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT1, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.1")); } @@ -127,7 +128,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT2, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.2")); } @@ -146,7 +148,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT3, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.3")); } @@ -168,7 +171,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT4, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.4")); } @@ -202,7 +206,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT5, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.5")); } @@ -229,7 +234,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT6, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.6")); } @@ -252,7 +258,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT7, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.7")); } @@ -273,7 +280,8 @@ ControlFilter cf = new ControlFilter(new String[]{PAT8, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/socketServer.8")); } 1.3 +5 -2 jakarta-log4j/tests/src/java/org/apache/log4j/util/LineNumberFilter.java Index: LineNumberFilter.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/util/LineNumberFilter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LineNumberFilter.java 25 Apr 2002 21:17:36 -0000 1.2 +++ LineNumberFilter.java 13 Nov 2002 16:44:54 -0000 1.3 @@ -18,8 +18,11 @@ public String filter(String in) { if(util.match("/\\(.*:\\d{1,4}\\)/", in)) { - return util.substitute("s/:\\d{1,4}\\)/:XXX)/", in); - } else { + return util.substitute("s/\\(.*:\\d{1,4}\\)/\\(X\\)/", in); + + } else if (util.match("/\\(Native Method\\)/", in)) { + return util.substitute("s/\\(Native Method\\)/\\(X\\)/", in); + }else { return in; } } 1.5 +3 -1 jakarta-log4j/tests/src/java/org/apache/log4j/util/Transformer.java Index: Transformer.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/util/Transformer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Transformer.java 25 Apr 2002 21:17:36 -0000 1.4 +++ Transformer.java 13 Nov 2002 16:44:54 -0000 1.5 @@ -30,7 +30,9 @@ for(int i = 0; i < filters.length; i++) { line = filters[i].filter(line); } - output.println(line); + if(line != null) { + output.println(line); + } } } 1.1 jakarta-log4j/tests/src/java/org/apache/log4j/util/SunReflectFilter.java Index: SunReflectFilter.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software * License version 1.1, a copy of which has been included with this * distribution in the LICENSE.txt file. */ package org.apache.log4j.util; import java.io.*; import org.apache.oro.text.perl.Perl5Util; public class SunReflectFilter implements Filter { Perl5Util util = new Perl5Util(); public String filter(String in) { if(util.match("/at sun.reflect/", in)) { return null; } else { return in; } } } 1.3 +10 -19 jakarta-log4j/tests/src/java/org/apache/log4j/varia/ErrorHandlerTestCase.java Index: ErrorHandlerTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/varia/ErrorHandlerTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ErrorHandlerTestCase.java 9 Oct 2002 22:50:08 -0000 1.2 +++ ErrorHandlerTestCase.java 13 Nov 2002 16:44:56 -0000 1.3 @@ -12,25 +12,21 @@ import org.apache.log4j.util.LineNumberFilter; import org.apache.log4j.util.ControlFilter; import org.apache.log4j.util.ISO8601Filter; +import org.apache.log4j.util.SunReflectFilter; import org.apache.log4j.util.Transformer; import org.apache.log4j.util.Compare; public class ErrorHandlerTestCase extends TestCase { - static String TEMP_A1 = "output/temp.A1"; - static String TEMP_A2 = "output/temp.A2"; - static String FILTERED_A1 = "output/filtered.A1"; - static String FILTERED_A2 = "output/filtered.A2"; - + static String TEMP = "output/temp"; + static String FILTERED = "output/filtered"; static String EXCEPTION1 = "java.lang.Exception: Just testing"; static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)"; static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)"; - static String TEST1_1A_PAT = - "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message \\d"; - - static String TEST1_1B_PAT = "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message \\d"; + static String TEST1_A_PAT = "FALLBACK - test - Message \\d"; + static String TEST1_B_PAT = "FALLBACK - root - Message \\d"; static String TEST1_2_PAT = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} "+ "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d"; @@ -57,20 +53,15 @@ DOMConfigurator.configure("input/xml/fallback1.xml"); common(); - ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, - EXCEPTION1, EXCEPTION2, EXCEPTION3}); - - ControlFilter cf2 = new ControlFilter(new String[]{TEST1_2_PAT, + ControlFilter cf = new ControlFilter(new String[]{TEST1_A_PAT, TEST1_B_PAT, EXCEPTION1, EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP_A1, FILTERED_A1, new Filter[] {cf1, - new LineNumberFilter()}); - Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2, - new LineNumberFilter(), new ISO8601Filter()}); + Transformer.transform(TEMP, FILTERED, new Filter[] {cf, + new LineNumberFilter(), + new SunReflectFilter()}); - assertTrue(Compare.compare(FILTERED_A1, "witness/dom.A1.1")); - assertTrue(Compare.compare(FILTERED_A2, "witness/dom.A2.1")); + assertTrue(Compare.compare(FILTERED, "witness/fallback")); } void common() { 1.7 +5 -2 jakarta-log4j/tests/src/java/org/apache/log4j/xml/DOMTestCase.java Index: DOMTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/xml/DOMTestCase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DOMTestCase.java 16 Oct 2002 13:58:22 -0000 1.6 +++ DOMTestCase.java 13 Nov 2002 16:44:58 -0000 1.7 @@ -9,6 +9,7 @@ import org.apache.log4j.Level; import org.apache.log4j.util.Filter; import org.apache.log4j.util.LineNumberFilter; +import org.apache.log4j.util.SunReflectFilter; import org.apache.log4j.util.ControlFilter; import org.apache.log4j.util.ISO8601Filter; import org.apache.log4j.util.Transformer; @@ -63,10 +64,12 @@ EXCEPTION1, EXCEPTION2, EXCEPTION3}); Transformer.transform(TEMP_A1, FILTERED_A1, new Filter[] {cf1, - new LineNumberFilter()}); + new LineNumberFilter(), + new SunReflectFilter()}); Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2, - new LineNumberFilter(), new ISO8601Filter()}); + new LineNumberFilter(), new ISO8601Filter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED_A1, "witness/dom.A1.1")); assertTrue(Compare.compare(FILTERED_A2, "witness/dom.A2.1")); 1.4 +7 -3 jakarta-log4j/tests/src/java/org/apache/log4j/xml/XMLLayoutTestCase.java Index: XMLLayoutTestCase.java =================================================================== RCS file: /home/cvs/jakarta-log4j/tests/src/java/org/apache/log4j/xml/XMLLayoutTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- XMLLayoutTestCase.java 9 Oct 2002 22:50:08 -0000 1.3 +++ XMLLayoutTestCase.java 13 Nov 2002 16:44:58 -0000 1.4 @@ -14,6 +14,7 @@ import org.apache.log4j.util.XMLTimestampFilter; import org.apache.log4j.util.XMLLineAttributeFilter; import org.apache.log4j.util.LineNumberFilter; +import org.apache.log4j.util.SunReflectFilter; import org.apache.log4j.util.Transformer; import org.apache.log4j.util.Compare; @@ -43,7 +44,8 @@ root.addAppender(new FileAppender(xmlLayout, TEMP, false)); common(); Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(), - new XMLTimestampFilter()}); + new XMLTimestampFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.1")); } @@ -54,7 +56,8 @@ common(); Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(), new XMLTimestampFilter(), - new XMLLineAttributeFilter()}); + new XMLLineAttributeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.2")); } @@ -67,7 +70,8 @@ Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(), new XMLTimestampFilter(), - new XMLLineAttributeFilter()}); + new XMLLineAttributeFilter(), + new SunReflectFilter()}); assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.3")); }
-- To unsubscribe, e-mail: <mailto:log4j-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:log4j-dev-help@;jakarta.apache.org>