logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1520772 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverterTest.java
Date Sat, 07 Sep 2013 14:02:01 GMT
Author: ggregory
Date: Sat Sep  7 14:02:01 2013
New Revision: 1520772

URL: http://svn.apache.org/r1520772
Log:
Add "full" option test.

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

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverterTest.java?rev=1520772&r1=1520771&r2=1520772&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverterTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverterTest.java
Sat Sep  7 14:02:01 2013
@@ -40,13 +40,37 @@ public class ThrowablePatternConverterTe
     /**
      * TODO: Needs better a better exception? NumberFormatException is NOT helpful.
      */
-    @Test(expected=Exception.class)
+    @Test(expected = Exception.class)
     public void testBadShortOption() {
         final String[] options = { "short.UNKNOWN" };
         ThrowablePatternConverter.newInstance(options);
     }
 
     @Test
+    public void testFull() {
+        final String[] options = { "full" };
+        final ThrowablePatternConverter converter = ThrowablePatternConverter.newInstance(options);
+        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("Incorrect start of msg", result.startsWith("java.lang.IllegalArgumentException:
IllegalArgument"));
+        assertTrue("Missing nested exception", result.contains("java.lang.NullPointerException:
null pointer"));
+    }
+
+    @Test
     public void testShortClassName() {
         final String packageName = "org.apache.logging.log4j.core.pattern.";
         final String[] options = { "short.className" };
@@ -132,5 +156,5 @@ public class ThrowablePatternConverterTe
         final String result = sb.toString();
         assertEquals("The method names should be same", "testShortMethodName", result);
     }
-    
+
 }



Mime
View raw message