You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gr...@apache.org on 2012/06/23 07:56:25 UTC
svn commit: r1353070 - in
/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j:
./ helpers/ pattern/ util/
Author: grobmeier
Date: Sat Jun 23 05:56:23 2012
New Revision: 1353070
URL: http://svn.apache.org/viewvc?rev=1353070&view=rev
Log:
removed some console writing, a little code formatting
Modified:
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/DRFATestCase.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/HierarchyThresholdTestCase.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/VectorAppender.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/Compare.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/ControlFilter.java
logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/AsyncAppenderTestCase.java Sat Jun 23 05:56:23 2012
@@ -89,9 +89,7 @@ public class AsyncAppenderTestCase exten
for(int i = 0; i < LEN; i++) {
root.debug("message"+i);
}
-
- System.out.println("Done loop.");
- System.out.flush();
+
asyncAppender.close();
root.debug("m2");
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/DRFATestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/DRFATestCase.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/DRFATestCase.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/DRFATestCase.java Sat Jun 23 05:56:23 2012
@@ -144,7 +144,6 @@ public class DRFATestCase extends TestCa
int [] M31 = {0,2,4,6,7,9,11};
for(int i = 0; i < M31.length; i ++) {
- System.out.println("Month = "+(M31[i]+1));
for(int d = 1; d <= 31; d++) {
for(int h = 0; h < 23; h++) {
for(int m = 0; m <= 59; m++) {
@@ -216,7 +215,6 @@ public class DRFATestCase extends TestCa
int [] M31 = {2,9,0,4,6,7,11};
for(int i = 0; i < M31.length; i ++) {
- System.out.println("Month = "+(M31[i]+1));
for(int d = 1; d <= 31; d++) {
for(int h = 0; h < 23; h++) {
for(int m = 0; m < M.length; m++) {
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/HierarchyThresholdTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/HierarchyThresholdTestCase.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/HierarchyThresholdTestCase.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/HierarchyThresholdTestCase.java Sat Jun 23 05:56:23 2012
@@ -42,7 +42,6 @@ public class HierarchyThresholdTestCase
}
public void tearDown() {
- System.out.println("Tearing down test case.");
logger.getLoggerRepository().resetConfiguration();
}
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/VectorAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/VectorAppender.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/VectorAppender.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/VectorAppender.java Sat Jun 23 05:56:23 2012
@@ -45,8 +45,6 @@ public class VectorAppender extends Appe
*/
public void append(LoggingEvent event) {
- //System.out.println("---Vector appender called with message ["+event.getRenderedMessage()+"].");
- //System.out.flush();
try {
Thread.sleep(100);
} catch(Exception e) {
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java Sat Jun 23 05:56:23 2012
@@ -82,23 +82,19 @@ public class BoundedFIFOTestCase extends
for(i = 1; i < 2*size; i++) {
for(j = 0; j < i; j++) {
- //System.out.println("Putting "+e[j]);
bf.put(e[j]); assertEquals(bf.length(), j < size ? j+1 : size);
}
int max = size < j ? size : j;
j--;
for(k = 0; k <= j; k++) {
- //System.out.println("max="+max+", j="+j+", k="+k);
- assertEquals(bf.length(), max - k > 0 ? max - k : 0);
+ assertEquals(bf.length(), max - k > 0 ? max - k : 0);
Object r = bf.get();
- //System.out.println("Got "+r);
- if(k >= size)
+ if(k >= size)
assertNull(r);
else
assertEquals(r, e[k]);
}
}
- //System.out.println("Passed size="+size);
}
}
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java Sat Jun 23 05:56:23 2012
@@ -111,10 +111,7 @@ public class CyclicBufferTestCase extend
cb.add(e[i]);
int limit = i < size-1 ? i : size-1;
- //System.out.println("\nLimit is " + limit + ", i="+i);
-
for(int j = limit; j >= 0; j--) {
- //System.out.println("i= "+i+", j="+j);
assertEquals(cb.get(j), e[i-(limit-j)]);
}
assertNull(cb.get(-1));
@@ -133,8 +130,6 @@ public class CyclicBufferTestCase extend
}
void doTestResize(int initialSize, int numberOfAdds, int newSize) {
- //System.out.println("initialSize = "+initialSize+", numberOfAdds="
- // +numberOfAdds+", newSize="+newSize);
CyclicBuffer cb = new CyclicBuffer(initialSize);
for(int i = 0; i < numberOfAdds; i++) {
cb.add(e[i]);
@@ -147,7 +142,7 @@ public class CyclicBufferTestCase extend
int len = newSize < numberOfAdds ? newSize : numberOfAdds;
len = len < initialSize ? len : initialSize;
- //System.out.println("Len = "+len+", offset="+offset);
+
for(int j = 0; j < len; j++) {
assertEquals(cb.get(j), e[offset+j]);
}
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java Sat Jun 23 05:56:23 2012
@@ -161,21 +161,17 @@ public final class CachedDateFormatTest
String sx;
Date jul1 = new Date(ticks);
sx = cachedFormat.format(jul1);
- System.out.println(baseFormat.format(jul1));
- System.out.println(sx);
+
assertEquals(baseFormat.format(jul1), sx);
sx = cachedFormat.format(jul1);
- System.out.println(baseFormat.format(jul1));
- System.out.println(sx);
+
assertEquals(baseFormat.format(jul1), sx);
Date plus8ms = new Date(ticks + 8);
sx = cachedFormat.format(plus8ms);
- System.out.println(baseFormat.format(plus8ms));
- System.out.println(sx);
-
+
assertEquals(baseFormat.format(plus8ms), sx);
Date plus17ms = new Date(ticks + 17);
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/Compare.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/Compare.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/Compare.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/Compare.java Sat Jun 23 05:56:23 2012
@@ -29,144 +29,140 @@ import java.io.File;
public class Compare {
- static final int B1_NULL = -1;
- static final int B2_NULL = -2;
-
- static
- public
- boolean compare(String file1, String file2) throws FileNotFoundException,
- IOException {
- BufferedReader in1 = new BufferedReader(new FileReader(file1));
- BufferedReader in2 = new BufferedReader(new FileReader(file2));
-
- 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+"].");
- return false;
- }
- }
-
- // the second file is longer
- if(in2.read() != -1) {
- System.out.println("File ["+file2+"] longer than file ["+file1+"].");
- return false;
- }
-
- 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);
+ static final int B1_NULL = -1;
+ static final int B2_NULL = -2;
- return false;
- }
+ static public boolean compare(String file1, String file2) throws FileNotFoundException,
+ IOException {
+ BufferedReader in1 = new BufferedReader(new FileReader(file1));
+ BufferedReader in2 = new BufferedReader(new FileReader(file2));
+
+ 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 + "].");
+ return false;
+ }
+ }
+
+ // the second file is longer
+ if (in2.read() != -1) {
+ System.out.println("File [" + file2 + "] longer than file [" + file1 + "].");
+ return false;
+ }
+
+ 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();
}
- // 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();
- }
-
}
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/ControlFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/ControlFilter.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/ControlFilter.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/ControlFilter.java Sat Jun 23 05:56:23 2012
@@ -21,25 +21,24 @@ import org.apache.oro.text.perl.Perl5Uti
public class ControlFilter implements Filter {
- Perl5Util util = new Perl5Util();
+ Perl5Util util = new Perl5Util();
- String[] allowedPatterns;
+ String[] allowedPatterns;
- public ControlFilter(String[] allowedPatterns) {
- this.allowedPatterns = allowedPatterns;
- }
-
- public
- String filter(String in) throws UnexpectedFormatException{
- int len = allowedPatterns.length;
- for(int i = 0; i < len; i++) {
- //System.out.println("["+allowedPatterns[i]+"]");
- if(util.match("/"+allowedPatterns[i]+"/", in)) {
- //System.out.println("["+in+"] matched ["+allowedPatterns[i]);
- return in;
- }
+ public ControlFilter(String[] allowedPatterns) {
+ this.allowedPatterns = allowedPatterns;
}
- throw new UnexpectedFormatException("["+in+"]");
- }
+ public String filter(String in) throws UnexpectedFormatException {
+ int len = allowedPatterns.length;
+ for (int i = 0; i < len; i++) {
+
+ if (util.match("/" + allowedPatterns[i] + "/", in)) {
+
+ return in;
+ }
+ }
+
+ throw new UnexpectedFormatException("[" + in + "]");
+ }
}
Modified: logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java?rev=1353070&r1=1353069&r2=1353070&view=diff
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java (original)
+++ logging/log4j/branches/log4j12-bz53299/core/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java Sat Jun 23 05:56:23 2012
@@ -21,17 +21,15 @@ import org.apache.oro.text.perl.Perl5Uti
public class RelativeTimeFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- public
- String filter(String in) {
- String pat = "/"+Filter.RELATIVE_TIME_PAT+"/";
+ Perl5Util util = new Perl5Util();
- if(util.match(pat, in)) {
- //System.out.println("Removing relative time from line ["+in+"]");
- return util.substitute("s/"+Filter.RELATIVE_TIME_PAT+"//", in);
- } else {
- return in;
+ public String filter(String in) {
+ String pat = "/" + Filter.RELATIVE_TIME_PAT + "/";
+
+ if (util.match(pat, in)) {
+ return util.substitute("s/" + Filter.RELATIVE_TIME_PAT + "//", in);
+ } else {
+ return in;
+ }
}
- }
}