logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1520768 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java
Date Sat, 07 Sep 2013 13:54:48 GMT
Author: ggregory
Date: Sat Sep  7 13:54:47 2013
New Revision: 1520768

URL: http://svn.apache.org/r1520768
Log:
Sanity check.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java?rev=1520768&r1=1520767&r2=1520768&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java
Sat Sep  7 13:54:47 2013
@@ -30,18 +30,46 @@ import org.junit.Test;
 public class RootThrowablePatternConverterTest {
 
     @Test
-    public void testFull() {
+    public void testFull1() {
         final RootThrowablePatternConverter converter = RootThrowablePatternConverter.newInstance(null);
         final Throwable cause = new NullPointerException("null pointer");
         final Throwable parent = new IllegalArgumentException("IllegalArgument", cause);
         final LogEvent event = new Log4jLogEvent("testLogger", null, this.getClass().getName(),
Level.DEBUG,
-            new SimpleMessage("test exception"), parent);
+                new SimpleMessage("test exception"), parent);
         final StringBuilder sb = new StringBuilder();
         converter.format(event, sb);
         final String result = sb.toString();
-        //System.out.print(result);
+        // System.out.print(result);
         assertTrue("Missing Exception",
-            result.contains("Wrapped by: java.lang.IllegalArgumentException: IllegalArgument"));
+                result.contains("Wrapped by: java.lang.IllegalArgumentException: IllegalArgument"));
+        assertTrue("Incorrect start of msg", result.startsWith("java.lang.NullPointerException:
null pointer"));
+    }
+
+    /**
+     * Sanity check for testFull1() above, makes sure that the way testFull1 is written matches
actually throwing
+     * exceptions.
+     */
+    @Test
+    public void testFull2() {
+        final RootThrowablePatternConverter converter = RootThrowablePatternConverter.newInstance(null);
+        Throwable parent;
+        try {
+            try {
+                throw new NullPointerException("null pointer");
+            } catch (NullPointerException e) {
+                throw new IllegalArgumentException("IllegalArgument", e);
+            }
+        } catch (IllegalArgumentException e) {
+            parent = e;
+        }
+        final LogEvent event = new Log4jLogEvent("testLogger", null, this.getClass().getName(),
Level.DEBUG,
+                new SimpleMessage("test exception"), parent);
+        final StringBuilder sb = new StringBuilder();
+        converter.format(event, sb);
+        final String result = sb.toString();
+        // System.out.print(result);
+        assertTrue("Missing Exception",
+                result.contains("Wrapped by: java.lang.IllegalArgumentException: IllegalArgument"));
         assertTrue("Incorrect start of msg", result.startsWith("java.lang.NullPointerException:
null pointer"));
     }
 }



Mime
View raw message