logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r1352876 [2/2] - in /logging/log4j/branches/log4j12-bz53299/core/src/test: java/org/apache/log4j/ java/org/apache/log4j/customLogger/ java/org/apache/log4j/helpers/ java/org/apache/log4j/rewrite/ java/org/apache/log4j/spi/ java/org/apache/l...
Date Fri, 22 Jun 2012 13:24:16 GMT
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/DOMTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/DOMTestCase.java?rev=1352876&r1=1352875&r2=1352876&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/DOMTestCase.java
(original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/DOMTestCase.java
Fri Jun 22 13:24:11 2012
@@ -23,6 +23,7 @@ import org.apache.log4j.FileAppender;
 import org.apache.log4j.Level;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
+import org.apache.log4j.ResourceHelper;
 import org.apache.log4j.VectorAppender;
 import org.apache.log4j.spi.ErrorHandler;
 import org.apache.log4j.spi.LoggerFactory;
@@ -49,8 +50,6 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
 public class DOMTestCase extends TestCase {
-  static final String FILE_PREFIX = "target/test-classes/";
-  
   static String TEMP_A1 = "output/temp.A1";
   static String TEMP_A2 = "output/temp.A2";
   static String FILTERED_A1 = "output/filtered.A1";
@@ -91,7 +90,7 @@ public class DOMTestCase extends TestCas
   }
 
   public void test1() throws Exception {
-    DOMConfigurator.configure(FILE_PREFIX + "input/xml/DOMTestCase1.xml");
+    DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/DOMTestCase1.xml"));
     common();
 
     ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, 
@@ -114,15 +113,15 @@ public class DOMTestCase extends TestCas
         new SunReflectFilter(), new JunitTestRunnerFilter()
       });
 
-    assertTrue(Compare.compare(FILTERED_A1, FILE_PREFIX + "witness/dom.A1.1"));
-    assertTrue(Compare.compare(FILTERED_A2, FILE_PREFIX + "witness/dom.A2.1"));
+    assertTrue(Compare.compare(FILTERED_A1, ResourceHelper.witnessFullpath("/dom.A1.1")));
+    assertTrue(Compare.compare(FILTERED_A2, ResourceHelper.witnessFullpath("/dom.A2.1")));
   }
   
   /**
    *   Tests processing of external entities in XML file.
    */
   public void test4() throws Exception {
-    DOMConfigurator.configure(FILE_PREFIX + "input/xml/DOMTest4.xml");
+    DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/DOMTest4.xml"));
     common();
 
     ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, 
@@ -145,8 +144,8 @@ public class DOMTestCase extends TestCas
         new SunReflectFilter(), new JunitTestRunnerFilter()
       });
 
-    assertTrue(Compare.compare(FILTERED_A1 + ".4", FILE_PREFIX + "witness/dom.A1.4"));
-    assertTrue(Compare.compare(FILTERED_A2 + ".4", FILE_PREFIX + "witness/dom.A2.4"));
+    assertTrue(Compare.compare(FILTERED_A1 + ".4", ResourceHelper.witnessFullpath("/dom.A1.4")));
+    assertTrue(Compare.compare(FILTERED_A2 + ".4", ResourceHelper.witnessFullpath("/dom.A2.4")));
   }
 
   void common() {
@@ -252,7 +251,7 @@ public class DOMTestCase extends TestCas
      *    use the specified categoryFactory.  See bug 33708.
      */
   public void testCategoryFactory1() {
-      DOMConfigurator.configure(FILE_PREFIX + "input/xml/categoryfactory1.xml");
+      DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/categoryfactory1.xml"));
       //
       //   logger explicitly mentioned in configuration,
       //         should be a CustomLogger
@@ -270,7 +269,7 @@ public class DOMTestCase extends TestCas
      *    use the specified categoryFactory.  See bug 33708.
      */
     public void testCategoryFactory2() {
-        DOMConfigurator.configure(FILE_PREFIX + "input/xml/categoryfactory2.xml");
+        DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/categoryfactory2.xml"));
         //
         //   logger explicitly mentioned in configuration,
         //         should be a CustomLogger
@@ -288,7 +287,7 @@ public class DOMTestCase extends TestCas
      *    use the specified loggerFactory.  See bug 33708.
      */
   public void testLoggerFactory1() {
-      DOMConfigurator.configure(FILE_PREFIX + "input/xml/loggerfactory1.xml");
+      DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/loggerfactory1.xml"));
       //
       //   logger explicitly mentioned in configuration,
       //         should be a CustomLogger
@@ -310,7 +309,7 @@ public class DOMTestCase extends TestCas
       VectorAppender appender = new VectorAppender();
       appender.setName("V1");
       Logger.getRootLogger().addAppender(appender);
-      DOMConfigurator.configure(FILE_PREFIX + "input/xml/testReset.xml");
+      DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/testReset.xml"));
       assertNull(Logger.getRootLogger().getAppender("V1"));
   }
 
@@ -320,7 +319,7 @@ public class DOMTestCase extends TestCas
       * @throws Exception if IO error.
      */
   public void testConfigureAndWatch() throws Exception {
-    DOMConfigurator.configureAndWatch(FILE_PREFIX + "input/xml/DOMTestCase1.xml");
+    DOMConfigurator.configureAndWatch(ResourceHelper.inputFullpath("/xml/DOMTestCase1.xml"));
     assertNotNull(Logger.getRootLogger().getAppender("A1"));
   }
 
@@ -339,7 +338,7 @@ public class DOMTestCase extends TestCas
               return value;
           }
       };
-      configurator.doConfigure(FILE_PREFIX + "input/xml/DOMTestCase1.xml", LogManager.getLoggerRepository());
+      configurator.doConfigure(ResourceHelper.inputFullpath("/xml/DOMTestCase1.xml"), LogManager.getLoggerRepository());
       FileAppender a1 = (FileAppender) Logger.getRootLogger().getAppender("A1");
       String file = a1.getFile();
       assertEquals("output/subst-test.A1", file);
@@ -380,7 +379,7 @@ public class DOMTestCase extends TestCas
      * Test of log4j.throwableRenderer support.  See bug 45721.
      */
     public void testThrowableRenderer1() {
-        DOMConfigurator.configure(FILE_PREFIX + "input/xml/throwableRenderer1.xml");
+        DOMConfigurator.configure(ResourceHelper.inputFullpath("/xml/throwableRenderer1.xml"));
         ThrowableRendererSupport repo = (ThrowableRendererSupport) LogManager.getLoggerRepository();
         MockThrowableRenderer renderer = (MockThrowableRenderer) repo.getThrowableRenderer();
         LogManager.resetConfiguration();
@@ -395,7 +394,7 @@ public class DOMTestCase extends TestCas
      * @throws IOException if IOException creating properties jar.
      */
     public void testJarURL() throws IOException {
-        File input = new File(FILE_PREFIX + "input/xml/defaultInit.xml");
+        File input = new File(ResourceHelper.inputFullpath("/xml/defaultInit.xml"));
         System.out.println(input.getAbsolutePath());
         InputStream is = new FileInputStream(input);
         File dir = new File("output");

Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/XMLLayoutTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/XMLLayoutTestCase.java?rev=1352876&r1=1352875&r2=1352876&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/XMLLayoutTestCase.java
(original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/xml/XMLLayoutTestCase.java
Fri Jun 22 13:24:11 2012
@@ -24,6 +24,7 @@ import org.apache.log4j.FileAppender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.log4j.MDC;
+import org.apache.log4j.ResourceHelper;
 import org.apache.log4j.util.Compare;
 import org.apache.log4j.util.Filter;
 import org.apache.log4j.util.JunitTestRunnerFilter;
@@ -36,11 +37,6 @@ import org.apache.log4j.util.XMLTimestam
 import java.util.Hashtable;
 
 public class XMLLayoutTestCase extends TestCase {
-
-  static final String FILE_PREFIX = "target/test-classes";
-  static final String INPUT_DIR = FILE_PREFIX + "/input";
-  static final String WITNESS_DIR = FILE_PREFIX + "/witness";
-  
   static String TEMP = "output/temp";
   static String FILTERED = "output/filtered";
 
@@ -74,7 +70,7 @@ public class XMLLayoutTestCase extends T
         new JunitTestRunnerFilter(),
         new SunReflectFilter()
       });
-    assertTrue(Compare.compare(FILTERED, WITNESS_DIR + "/xmlLayout.1"));
+    assertTrue(Compare.compare(FILTERED, ResourceHelper.witnessFullpath("/xmlLayout.1")));
   }
 
   public void locationInfo() throws Exception {
@@ -91,7 +87,7 @@ public class XMLLayoutTestCase extends T
         new JunitTestRunnerFilter(),
         new SunReflectFilter()
       });
-    assertTrue(Compare.compare(FILTERED, WITNESS_DIR + "/xmlLayout.2"));
+    assertTrue(Compare.compare(FILTERED, ResourceHelper.witnessFullpath("/xmlLayout.2")));
   }
 
   public void testCDATA() throws Exception {
@@ -120,7 +116,7 @@ public class XMLLayoutTestCase extends T
     Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(),
     						  new XMLTimestampFilter(),
     						  new XMLLineAttributeFilter()});
-    assertTrue(Compare.compare(FILTERED, WITNESS_DIR + "/xmlLayout.3"));
+    assertTrue(Compare.compare(FILTERED, ResourceHelper.witnessFullpath("/xmlLayout.3")));
   }
 
   public void testNull() throws Exception {
@@ -143,7 +139,7 @@ public class XMLLayoutTestCase extends T
           new XMLTimestampFilter(),  
           new JunitTestRunnerFilter(),
           new SunReflectFilter()});
-    assertTrue(Compare.compare(FILTERED, WITNESS_DIR + "/xmlLayout.null"));
+    assertTrue(Compare.compare(FILTERED, ResourceHelper.witnessFullpath("/xmlLayout.null")));
   }
 
     /**
@@ -169,7 +165,7 @@ public class XMLLayoutTestCase extends T
         new Filter[] { new LineNumberFilter(),
             new JunitTestRunnerFilter(),
             new XMLTimestampFilter()});
-      assertTrue(Compare.compare(FILTERED, WITNESS_DIR + "/xmlLayout.mdc.1"));
+      assertTrue(Compare.compare(FILTERED, ResourceHelper.witnessFullpath("/xmlLayout.mdc.1")));
     }
 
     public void testMDCEscaped() throws Exception {
@@ -190,7 +186,7 @@ public class XMLLayoutTestCase extends T
         new Filter[] { new LineNumberFilter(),
             new JunitTestRunnerFilter(),
             new XMLTimestampFilter() });
-      assertTrue(Compare.compare(FILTERED, WITNESS_DIR + "/xmlLayout.mdc.2"));
+      assertTrue(Compare.compare(FILTERED, ResourceHelper.witnessFullpath("/xmlLayout.mdc.2")));
     }
 
   

Added: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.log
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.log?rev=1352876&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.log (added)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.log Fri
Jun 22 13:24:11 2012
@@ -0,0 +1,3 @@
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1: p2: Message 0
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hello p2:World {p1=Hello, p2=World,
x1=Mundo}
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hello p2:World Message 1

Added: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.xml?rev=1352876&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.xml (added)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.xml Fri
Jun 22 13:24:11 2012
@@ -0,0 +1,38 @@
+<!--
+ 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.
+
+-->
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
+    <appender name="F1" class="org.apache.log4j.FileAppender">
+        <param name="file"   value="./output/RewriteAppenderTest-map-out.log"/>
+        <param name="append" value="false"/>
+        <layout class="org.apache.log4j.PatternLayout">
+           <param name="ConversionPattern" value="%p %c - p1:%X{p1} p2:%X{p2} %m%n"/>
+        </layout>
+    </appender>
+
+
+  <appender name="A1" class="org.apache.log4j.rewrite.RewriteAppender">
+      <appender-ref ref="F1"/>
+      <rewritePolicy class="org.apache.log4j.rewrite.MapRewritePolicy"/>
+  </appender>
+
+  <root>
+    <level value ="debug" />
+    <appender-ref ref="A1" />
+  </root>
+
+</log4j:configuration>

Propchange: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/map.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.log
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.log?rev=1352876&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.log
(added)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.log
Fri Jun 22 13:24:11 2012
@@ -0,0 +1,2 @@
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hello p2:World Message 0
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hola p2:World Message 1

Added: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.xml?rev=1352876&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.xml
(added)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.xml
Fri Jun 22 13:24:11 2012
@@ -0,0 +1,40 @@
+<!--
+ 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.
+
+-->
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
+    <appender name="F1" class="org.apache.log4j.FileAppender">
+        <param name="file"   value="output/RewriteAppenderTest-property-out.log"/>
+        <param name="append" value="false"/>
+        <layout class="org.apache.log4j.PatternLayout">
+           <param name="ConversionPattern" value="%p %c - p1:%X{p1} p2:%X{p2} %m%n"/>
+        </layout>
+    </appender>
+
+
+  <appender name="A1" class="org.apache.log4j.rewrite.RewriteAppender">
+      <appender-ref ref="F1"/>
+      <rewritePolicy class="org.apache.log4j.rewrite.PropertyRewritePolicy">
+          <param name="properties" value="p1=Hello,p2=World,x1=3.1415"/>
+      </rewritePolicy>
+  </appender>
+
+  <root>
+    <level value ="debug" />
+    <appender-ref ref="A1" />
+  </root>
+
+</log4j:configuration>

Propchange: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/property.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.log
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.log?rev=1352876&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.log
(added)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.log
Fri Jun 22 13:24:11 2012
@@ -0,0 +1,3 @@
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1: p2: Message 0
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1: p2:Hello I am bean.
+INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hola p2:Hello Welcome to The Hub

Added: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.xml?rev=1352876&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.xml
(added)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.xml
Fri Jun 22 13:24:11 2012
@@ -0,0 +1,38 @@
+<!--
+ 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.
+
+-->
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
+    <appender name="F1" class="org.apache.log4j.FileAppender">
+        <param name="file"   value="output/RewriteAppenderTest-reflection-out.log"/>
+        <param name="append" value="false"/>
+        <layout class="org.apache.log4j.PatternLayout">
+           <param name="ConversionPattern" value="%p %c - p1:%X{p1} p2:%X{p2} %m%n"/>
+        </layout>
+    </appender>
+
+
+  <appender name="A1" class="org.apache.log4j.rewrite.RewriteAppender">
+      <appender-ref ref="F1"/>
+      <rewritePolicy class="org.apache.log4j.rewrite.ReflectionRewritePolicy"/>
+  </appender>
+
+  <root>
+    <level value ="debug" />
+    <appender-ref ref="A1" />
+  </root>
+
+</log4j:configuration>

Propchange: logging/log4j/branches/log4j12-bz53299/core/src/test/resources/input/rewrite/reflection.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message