You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2007/07/18 18:43:44 UTC
svn commit: r557323 - in /logging/log4j/trunk/tests: ./ input/filter/
src/java/org/apache/log4j/filter/ witness/filter/
Author: carnold
Date: Wed Jul 18 09:43:43 2007
New Revision: 557323
URL: http://svn.apache.org/viewvc?view=rev&rev=557323
Log:
Bug 42099: Add ExpressionFilter tests
Added:
logging/log4j/trunk/tests/input/filter/simpleFilter10.xml
logging/log4j/trunk/tests/input/filter/simpleFilter11.xml
logging/log4j/trunk/tests/input/filter/simpleFilter12.xml
logging/log4j/trunk/tests/input/filter/simpleFilter9.xml
logging/log4j/trunk/tests/witness/filter/simpleFilter.11
- copied, changed from r557181, logging/log4j/trunk/tests/witness/filter/simpleFilter.7
Modified:
logging/log4j/trunk/tests/build.xml
logging/log4j/trunk/tests/src/java/org/apache/log4j/filter/SimpleFilterTest.java
logging/log4j/trunk/tests/witness/filter/simpleFilter.7
Modified: logging/log4j/trunk/tests/build.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/build.xml?view=diff&rev=557323&r1=557322&r2=557323
==============================================================================
--- logging/log4j/trunk/tests/build.xml (original)
+++ logging/log4j/trunk/tests/build.xml Wed Jul 18 09:43:43 2007
@@ -828,7 +828,7 @@
</target>
<target name="Concurrent" depends="check, build">
- <junit printsummary="yes" fork="no" haltonfailure="${haltonfailure}" dir="${basedir}">
+ <junit printsummary="yes" fork="yes" haltonfailure="${haltonfailure}" dir="${basedir}">
<classpath refid="tests.classpath"/>
<formatter type="plain" usefile="false"/>
<test name="org.apache.log4j.concurrent.RollingFileAppenderTest" />
@@ -846,7 +846,7 @@
<target name="ReaderWriterLock" depends="check, build, cleanOutputDir">
- <junit printsummary="yes" fork="no" haltonfailure="${haltonfailure}" dir="${basedir}">
+ <junit printsummary="yes" fork="yes" haltonfailure="${haltonfailure}" dir="${basedir}">
<sysproperty key="runLen" value="100"/>
<classpath refid="tests.classpath"/>
<formatter type="plain" usefile="false"/>
Added: logging/log4j/trunk/tests/input/filter/simpleFilter10.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/input/filter/simpleFilter10.xml?view=auto&rev=557323
==============================================================================
--- logging/log4j/trunk/tests/input/filter/simpleFilter10.xml (added)
+++ logging/log4j/trunk/tests/input/filter/simpleFilter10.xml Wed Jul 18 09:43:43 2007
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE configuration SYSTEM 'log4j.dtd' >
+
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="true">
+
+ <appender name="TEMP" class="org.apache.log4j.FileAppender">
+ <param name="Append" value="false" />
+ <param name="File" value="output/temp" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%p - %m\n"/>
+ </layout>
+
+ <filter class="org.apache.log4j.filter.ExpressionFilter">
+ <param name="expression" value="LEVEL == WARN" />
+ <param name="AcceptOnMatch" value="true" />
+ </filter>
+
+
+ <filter class="org.apache.log4j.filter.DenyAllFilter"/>
+
+ </appender>
+
+ <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
+ <logger name="org.apache.log4j.joran.action"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.joran.JoranConfigurator"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
+
+ <root>
+ <appender-ref ref="TEMP" />
+ </root>
+</log4j:configuration>
Added: logging/log4j/trunk/tests/input/filter/simpleFilter11.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/input/filter/simpleFilter11.xml?view=auto&rev=557323
==============================================================================
--- logging/log4j/trunk/tests/input/filter/simpleFilter11.xml (added)
+++ logging/log4j/trunk/tests/input/filter/simpleFilter11.xml Wed Jul 18 09:43:43 2007
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE log4j:configuration SYSTEM 'log4j.dtd'>
+
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
+ configDebug="true">
+
+ <appender name="TEMP" class="org.apache.log4j.FileAppender">
+ <param name="Append" value="false" />
+ <param name="File" value="output/temp" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%p - %m\n"/>
+ </layout>
+ <filter class="org.apache.log4j.filter.ExpressionFilter">
+ <param name="expression" value="LEVEL == WARN" />
+ <param name="AcceptOnMatch" value="false" />
+ </filter>
+
+ </appender>
+
+ <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
+ <logger name="org.apache.log4j.joran.action"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.joran.JoranConfigurator"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
+
+
+ <root>
+ <appender-ref ref="TEMP" />
+ </root>
+</log4j:configuration>
Added: logging/log4j/trunk/tests/input/filter/simpleFilter12.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/input/filter/simpleFilter12.xml?view=auto&rev=557323
==============================================================================
--- logging/log4j/trunk/tests/input/filter/simpleFilter12.xml (added)
+++ logging/log4j/trunk/tests/input/filter/simpleFilter12.xml Wed Jul 18 09:43:43 2007
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE log4j:configuration SYSTEM 'log4j.dtd'>
+
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
+ configDebug="true">
+
+ <appender name="TEMP" class="org.apache.log4j.FileAppender">
+ <param name="Append" value="false" />
+ <param name="File" value="output/temp" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%p %c - %m\n"/>
+ </layout>
+ <filter class="org.apache.log4j.filter.ExpressionFilter">
+ <param name="expression" value="( LEVEL == WARN ) && ( LOGGER == org.apache.log4j.filter.SimpleFilterTest )"/>
+ </filter>
+ <filter class="org.apache.log4j.filter.DenyAllFilter"/>
+
+ </appender>
+
+ <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
+ <logger name="org.apache.log4j.joran.action"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.joran.JoranConfigurator"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
+
+
+ <root>
+ <appender-ref ref="TEMP" />
+ </root>
+</log4j:configuration>
Added: logging/log4j/trunk/tests/input/filter/simpleFilter9.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/input/filter/simpleFilter9.xml?view=auto&rev=557323
==============================================================================
--- logging/log4j/trunk/tests/input/filter/simpleFilter9.xml (added)
+++ logging/log4j/trunk/tests/input/filter/simpleFilter9.xml Wed Jul 18 09:43:43 2007
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE log4j:configuration SYSTEM 'log4j.dtd' >
+
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
+
+ <appender name="A1" class="org.apache.log4j.FileAppender">
+
+ <param name="Append" value="false" />
+ <param name="File" value="output/temp" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%p - %m\n"/>
+ </layout>
+ <!-- Accept all LoggingEvents containing the string
+ "1" in the message field. -->
+ <filter class="org.apache.log4j.filter.ExpressionFilter">
+ <param name="expression" value="MSG LIKE .*1" />
+ </filter>
+ <!-- Accept all LoggingEvents containing the string
+ "2" in its message field. -->
+ <filter class="org.apache.log4j.filter.ExpressionFilter">
+ <param name="expression" value="MSG LIKE .*2" />
+ </filter>
+ <!-- Deny (filter out) everything else. -->
+ <filter class="org.apache.log4j.filter.DenyAllFilter"/>
+ </appender>
+
+ <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
+ <logger name="org.apache.log4j.joran.action"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.joran.JoranConfigurator"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
+ <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
+
+ <root>
+ <appender-ref ref="A1" />
+ </root>
+</log4j:configuration>
Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/filter/SimpleFilterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/filter/SimpleFilterTest.java?view=diff&rev=557323&r1=557322&r2=557323
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/filter/SimpleFilterTest.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/filter/SimpleFilterTest.java Wed Jul 18 09:43:43 2007
@@ -135,6 +135,75 @@
assertTrue(Compare.compare(FILTERED, "witness/filter/simpleFilter.8"));
}
+ public void test9() throws Exception {
+ JoranConfigurator joc = new JoranConfigurator();
+ joc.doConfigure("./input/filter/simpleFilter9.xml", LogManager.getLoggerRepository());
+ joc.dumpErrors();
+ common();
+
+ ControlFilter cf = new ControlFilter(new String[]{TEST1_PAT, EXCEPTION1, EXCEPTION2, EXCEPTION3});
+
+
+ Transformer.transform(TEMP, FILTERED, new Filter[] {cf,
+ new LineNumberFilter(),
+ new SunReflectFilter(),
+ new JunitTestRunnerFilter()});
+
+ assertTrue(Compare.compare(FILTERED, "witness/filter/simpleFilter.1"));
+ }
+
+ public void test10() throws Exception {
+ JoranConfigurator joc = new JoranConfigurator();
+ joc.doConfigure("./input/filter/simpleFilter10.xml", LogManager.getLoggerRepository());
+ joc.dumpErrors();
+ common();
+
+ ControlFilter cf = new ControlFilter(new String[]{TEST1_PAT, EXCEPTION1, EXCEPTION2, EXCEPTION3});
+
+
+ Transformer.transform(TEMP, FILTERED, new Filter[] {cf,
+ new LineNumberFilter(),
+ new SunReflectFilter(),
+ new JunitTestRunnerFilter()});
+
+ assertTrue(Compare.compare(FILTERED, "witness/filter/simpleFilter.6"));
+ }
+
+ public void test11() throws Exception {
+ JoranConfigurator joc = new JoranConfigurator();
+ joc.doConfigure("./input/filter/simpleFilter11.xml", LogManager.getLoggerRepository());
+ joc.dumpErrors();
+ common();
+
+ ControlFilter cf = new ControlFilter(new String[]{TEST1_PAT, EXCEPTION1, EXCEPTION2, EXCEPTION3});
+
+
+ Transformer.transform(TEMP, FILTERED, new Filter[] {cf,
+ new LineNumberFilter(),
+ new SunReflectFilter(),
+ new JunitTestRunnerFilter()});
+
+ assertTrue(Compare.compare(FILTERED, "witness/filter/simpleFilter.11"));
+ }
+
+ public void test12() throws Exception {
+ JoranConfigurator joc = new JoranConfigurator();
+ joc.doConfigure("./input/filter/simpleFilter12.xml", LogManager.getLoggerRepository());
+ joc.dumpErrors();
+ common();
+
+ ControlFilter cf = new ControlFilter(new String[]{TEST8_PAT, EXCEPTION1, EXCEPTION2, EXCEPTION3});
+
+
+ Transformer.transform(TEMP, FILTERED, new Filter[] {cf,
+ new LineNumberFilter(),
+ new SunReflectFilter(),
+ new JunitTestRunnerFilter()});
+
+ assertTrue(Compare.compare(FILTERED, "witness/filter/simpleFilter.8"));
+ }
+
+
void common() {
int i = -1;
Copied: logging/log4j/trunk/tests/witness/filter/simpleFilter.11 (from r557181, logging/log4j/trunk/tests/witness/filter/simpleFilter.7)
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/witness/filter/simpleFilter.11?view=diff&rev=557323&p1=logging/log4j/trunk/tests/witness/filter/simpleFilter.7&r1=557181&p2=logging/log4j/trunk/tests/witness/filter/simpleFilter.11&r2=557323
==============================================================================
--- logging/log4j/trunk/tests/witness/filter/simpleFilter.7 (original)
+++ logging/log4j/trunk/tests/witness/filter/simpleFilter.11 Wed Jul 18 09:43:43 2007
@@ -9,7 +9,7 @@
DEBUG - Message 5
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
- at org.apache.log4j.filter.SimpleFilterTest.test7(X)
+ at org.apache.log4j.filter.SimpleFilterTest.test11(X)
at java.lang.reflect.Method.invoke(X)
at junit.framework.TestCase.runTest(X)
at junit.framework.TestCase.runBare(X)
@@ -17,10 +17,12 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
DEBUG - Message 5
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
- at org.apache.log4j.filter.SimpleFilterTest.test7(X)
+ at org.apache.log4j.filter.SimpleFilterTest.test11(X)
at java.lang.reflect.Method.invoke(X)
at junit.framework.TestCase.runTest(X)
at junit.framework.TestCase.runBare(X)
@@ -28,10 +30,12 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
ERROR - Message 6
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
- at org.apache.log4j.filter.SimpleFilterTest.test7(X)
+ at org.apache.log4j.filter.SimpleFilterTest.test11(X)
at java.lang.reflect.Method.invoke(X)
at junit.framework.TestCase.runTest(X)
at junit.framework.TestCase.runBare(X)
@@ -39,10 +43,12 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
ERROR - Message 6
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
- at org.apache.log4j.filter.SimpleFilterTest.test7(X)
+ at org.apache.log4j.filter.SimpleFilterTest.test11(X)
at java.lang.reflect.Method.invoke(X)
at junit.framework.TestCase.runTest(X)
at junit.framework.TestCase.runBare(X)
@@ -50,3 +56,5 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
Modified: logging/log4j/trunk/tests/witness/filter/simpleFilter.7
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/witness/filter/simpleFilter.7?view=diff&rev=557323&r1=557322&r2=557323
==============================================================================
--- logging/log4j/trunk/tests/witness/filter/simpleFilter.7 (original)
+++ logging/log4j/trunk/tests/witness/filter/simpleFilter.7 Wed Jul 18 09:43:43 2007
@@ -17,6 +17,8 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
DEBUG - Message 5
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
@@ -28,6 +30,8 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
ERROR - Message 6
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
@@ -39,6 +43,8 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
ERROR - Message 6
java.lang.Exception: Just testing
at org.apache.log4j.filter.SimpleFilterTest.common(X)
@@ -50,3 +56,5 @@
at junit.framework.TestResult.runProtected(X)
at junit.framework.TestResult.run(X)
at junit.framework.TestCase.run(X)
+ at junit.framework.TestSuite.runTest(X)
+ at junit.framework.TestSuite.run(X)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org