Author: carnold
Date: Tue Sep 6 03:34:28 2011
New Revision: 1165491
URL: http://svn.apache.org/viewvc?rev=1165491&view=rev
Log:
Bug 51766: Relocate o.a.l.rewrite and o.a.l.helpers.UtilLoggingLevel from receivers companion
Added:
logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/UtilLoggingLevel.java
- copied unchanged from r1164943, logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/helpers/UtilLoggingLevel.java
logging/log4j/trunk/src/main/java/org/apache/log4j/rewrite/
- copied from r1164943, logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/rewrite/
logging/log4j/trunk/tests/input/xml/map.xml
- copied unchanged from r1164943, logging/log4j/companions/receivers/trunk/src/test/resources/org/apache/log4j/rewrite/map.xml
logging/log4j/trunk/tests/resources/org/apache/log4j/rewrite/
- copied from r1164943, logging/log4j/companions/receivers/trunk/src/test/resources/org/apache/log4j/rewrite/
logging/log4j/trunk/tests/src/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
- copied unchanged from r1164943, logging/log4j/companions/receivers/trunk/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
logging/log4j/trunk/tests/src/java/org/apache/log4j/rewrite/
- copied from r1164943, logging/log4j/companions/receivers/trunk/src/test/java/org/apache/log4j/rewrite/
Modified:
logging/log4j/trunk/src/changes/changes.xml
logging/log4j/trunk/tests/build.xml
logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java
logging/log4j/trunk/tests/src/java/org/apache/log4j/util/Compare.java
Modified: logging/log4j/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/changes/changes.xml?rev=1165491&r1=1165490&r2=1165491&view=diff
==============================================================================
--- logging/log4j/trunk/src/changes/changes.xml (original)
+++ logging/log4j/trunk/src/changes/changes.xml Tue Sep 6 03:34:28 2011
@@ -26,6 +26,7 @@
DOMConfigurator does not close input stream when configured based on URL.
javadoc.jar was missing NOTICE and LICENSE and contained .svn entries.
Wrong log levels logged with serialized LoggingEvent.
+ Add org.apache.log4j.rewrite.RewriteAppender and org.apache.log4j.util.UtilLoggingLevel from discontinued receivers companion.
Modified: logging/log4j/trunk/tests/build.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/build.xml?rev=1165491&r1=1165490&r2=1165491&view=diff
==============================================================================
--- logging/log4j/trunk/tests/build.xml (original)
+++ logging/log4j/trunk/tests/build.xml Tue Sep 6 03:34:28 2011
@@ -172,7 +172,7 @@
OptionConverter, BoundedFIFO,
CyclicBuffer, OR,
LevelMatchFilter, PatternParser,
- ErrorHandler"/>
+ ErrorHandler,Rewrite"/>
@@ -476,6 +476,14 @@
+
+
+
+
+
+
+
Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java?rev=1165491&r1=1165490&r2=1165491&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/CoreTestSuite.java Tue Sep 6 03:34:28 2011
@@ -60,6 +60,7 @@ public class CoreTestSuite {
s.addTestSuite(org.apache.log4j.pattern.FormattingInfoTest.class);
s.addTestSuite(org.apache.log4j.pattern.NameAbbreviatorTest.class);
s.addTestSuite(org.apache.log4j.pattern.PatternParserTest.class);
+ s.addTestSuite(org.apache.log4j.helpers.UtilLoggingLevelTest.class);
return s;
}
}
Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/util/Compare.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/util/Compare.java?rev=1165491&r1=1165490&r2=1165491&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/util/Compare.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/util/Compare.java Tue Sep 6 03:34:28 2011
@@ -21,6 +21,11 @@ import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.File;
+
public class Compare {
@@ -56,5 +61,112 @@ public class Compare {
return true;
}
+
+private static final InputStream open(
+ final Class testClass,
+ final String fileName) throws IOException {
+ String resourceName = fileName;
+ if (fileName.startsWith("witness/")) {
+ resourceName = fileName.substring(fileName.lastIndexOf('/') + 1);
+ }
+ InputStream is = testClass.getResourceAsStream(resourceName);
+ if (is == null) {
+ File file = new File(fileName);
+ if (file.exists()) {
+ is = new FileInputStream(file);
+ } else {
+ throw new FileNotFoundException("Resource "
+ + resourceName + " not found");
+ }
+ }
+ return is;
+ }
+
+ public static boolean compare(Class testClass,
+ final String file1,
+ final String file2)
+ throws IOException {
+ BufferedReader in1 = new BufferedReader(new FileReader(file1));
+ BufferedReader in2 = new BufferedReader(new InputStreamReader(
+ open(testClass, file2)));
+ try {
+ return compare(testClass, file1, file2, in1, in2);
+ } finally {
+ in1.close();
+ in2.close();
+ }
+ }
+
+ public static boolean compare(
+ Class testClass, String file1, String file2, BufferedReader in1, BufferedReader in2) throws IOException {
+
+ String s1;
+ int lineCounter = 0;
+
+ while ((s1 = in1.readLine()) != null) {
+ lineCounter++;
+
+ String s2 = in2.readLine();
+
+ if (!s1.equals(s2)) {
+ System.out.println(
+ "Files [" + file1 + "] and [" + file2 + "] differ on line "
+ + lineCounter);
+ System.out.println("One reads: [" + s1 + "].");
+ System.out.println("Other reads:[" + s2 + "].");
+ outputFile(testClass, file1);
+ outputFile(testClass, file2);
+
+ return false;
+ }
+ }
+
+ // the second file is longer
+ if (in2.read() != -1) {
+ System.out.println(
+ "File [" + file2 + "] longer than file [" + file1 + "].");
+ outputFile(testClass, file1);
+ outputFile(testClass, file2);
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ * Prints file on the console.
+ *
+ */
+ private static void outputFile(Class testClass, String file)
+ throws IOException {
+ InputStream is = open(testClass, file);
+ BufferedReader in1 = new BufferedReader(new InputStreamReader(is));
+
+ String s1;
+ int lineCounter = 0;
+ System.out.println("--------------------------------");
+ System.out.println("Contents of " + file + ":");
+
+ while ((s1 = in1.readLine()) != null) {
+ lineCounter++;
+ System.out.print(lineCounter);
+
+ if (lineCounter < 10) {
+ System.out.print(" : ");
+ } else if (lineCounter < 100) {
+ System.out.print(" : ");
+ } else if (lineCounter < 1000) {
+ System.out.print(" : ");
+ } else {
+ System.out.print(": ");
+ }
+
+ System.out.println(s1);
+ }
+ in1.close();
+ }
+
}