logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject svn commit: r928324 - in /logging/log4j/trunk/tests: src/java/org/apache/log4j/EnhancedPatternLayoutTestCase.java src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java witness/pattern/enhancedPatternLayout.throwable
Date Sun, 28 Mar 2010 03:34:26 GMT
Author: carnold
Date: Sun Mar 28 03:34:26 2010
New Revision: 928324

URL: http://svn.apache.org/viewvc?rev=928324&view=rev
Log:
Add %throwable{n} pattern

Modified:
    logging/log4j/trunk/tests/src/java/org/apache/log4j/EnhancedPatternLayoutTestCase.java
    logging/log4j/trunk/tests/src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
    logging/log4j/trunk/tests/witness/pattern/enhancedPatternLayout.throwable

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/EnhancedPatternLayoutTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/EnhancedPatternLayoutTestCase.java?rev=928324&r1=928323&r2=928324&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/EnhancedPatternLayoutTestCase.java
(original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/EnhancedPatternLayoutTestCase.java
Sun Mar 28 03:34:26 2010
@@ -30,6 +30,7 @@ import org.apache.log4j.util.RelativeTim
 import org.apache.log4j.util.SunReflectFilter;
 import org.apache.log4j.util.Transformer;
 import org.apache.log4j.util.MDCOrderFilter;
+import org.apache.log4j.spi.ThrowableInformation;
 
 import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
@@ -551,6 +552,30 @@ public class EnhancedPatternLayoutTestCa
     root.debug("%throwable{none}, no exception");
     root.debug("%throwable{none}, with exception", ex);
 
+    layout.setConversionPattern("%m%n%throwable{0}");
+    layout.activateOptions();
+    root.debug("%throwable{0}, no exception");
+    root.debug("%throwable{0}, with exception", ex);
+
+    layout.setConversionPattern("%m%n%throwable{1}");
+    layout.activateOptions();
+    root.debug("%throwable{1}, no exception");
+    root.debug("%throwable{1}, with exception", ex);
+
+    layout.setConversionPattern("%m%n%throwable{100}");
+    layout.activateOptions();
+    root.debug("%throwable{100}, no exception");
+    root.debug("%throwable{100}, with exception", ex);
+
+    //
+    //  manufacture a pattern to get just the first two lines
+    //
+    String[] trace = new ThrowableInformation(ex).getThrowableStrRep();
+    layout.setConversionPattern("%m%n%throwable{" + (2 - trace.length) + "}");
+    layout.activateOptions();
+    root.debug("%throwable{-n}, no exception");
+    root.debug("%throwable{-n}, with exception", ex);
+
 
       Transformer.transform(
         OUTPUT_FILE, FILTERED,

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java?rev=928324&r1=928323&r2=928324&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
(original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
Sun Mar 28 03:34:26 2010
@@ -30,7 +30,8 @@ public class EnhancedJunitTestRunnerFilt
           "at java.lang.reflect.Method.invoke",
           "at org.apache.maven.",
           "at org.codehaus.",
-		  "at org.junit.internal.runners."
+		    "at org.junit.internal.runners.",
+		    "at junit.framework.JUnit4TestAdapter"
   };
   private final Pattern[] patterns;
 

Modified: logging/log4j/trunk/tests/witness/pattern/enhancedPatternLayout.throwable
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/witness/pattern/enhancedPatternLayout.throwable?rev=928324&r1=928323&r2=928324&view=diff
==============================================================================
--- logging/log4j/trunk/tests/witness/pattern/enhancedPatternLayout.throwable (original)
+++ logging/log4j/trunk/tests/witness/pattern/enhancedPatternLayout.throwable Sun Mar 28 03:34:26
2010
@@ -30,3 +30,25 @@ java.lang.Exception: Test Exception
 java.lang.Exception: Test Exception
 %throwable{none}, no exception
 %throwable{none}, with exception
+%throwable{0}, no exception
+%throwable{0}, with exception
+%throwable{1}, no exception
+%throwable{1}, with exception
+java.lang.Exception: Test Exception
+%throwable{100}, no exception
+%throwable{100}, with exception
+java.lang.Exception: Test Exception
+	at org.apache.log4j.EnhancedPatternLayoutTestCase.testThrowable(X)
+	at java.lang.reflect.Method.invoke(X)
+	at junit.framework.TestCase.runTest(X)
+	at junit.framework.TestCase.runBare(X)
+	at junit.framework.TestResult$1.protect(X)
+	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)
+%throwable{-n}, no exception
+%throwable{-n}, with exception
+java.lang.Exception: Test Exception
+	at org.apache.log4j.EnhancedPatternLayoutTestCase.testThrowable(X)



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message