This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new 473c050  Exceptionutilstest to 100p (#486)
473c050 is described below

commit 473c050cc9e52931dfbb1c8430a4093454147ebb
Author: Peter Verhas <[email protected]>
AuthorDate: Mon Feb 17 16:13:27 2020 +0100

    Exceptionutilstest to 100p (#486)
    
    * unit tests were added to top up the test coverage of ExceptionUtils to 
100%
    
    * unit tests were added to top up the test coverage of ExceptionUtils to 
100%
    
    * unit tests were added to top up the test coverage of ExceptionUtils to 
100%
    
    * unit tests were added to top up the test coverage of ExceptionUtils to 
100%
    
    * unit tests were added to top up the test coverage of ExceptionUtils to 
100%
---
 .../lang3/exception/ExceptionUtilsTest.java        | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git 
a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index fb7a9fb..68354a4 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.lang3.exception;
 
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -35,6 +36,7 @@ import java.util.List;
 import org.apache.commons.lang3.test.NotVisibleExceptionFactory;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -699,4 +701,34 @@ public class ExceptionUtilsTest {
         final Throwable t = assertThrows(Throwable.class, () -> 
ExceptionUtils.wrapAndThrow(new TestThrowable()));
         assertTrue(ExceptionUtils.hasCause(t, TestThrowable.class));
     }
+
+    @Test
+    @DisplayName("getStackFrames returns the string array of the stack frames 
when there is a real exception")
+    public void testgetStackFramesNullArg() {
+        final String[] actual = ExceptionUtils.getStackFrames((Throwable) 
null);
+        assertEquals(0, actual.length);
+    }
+
+    @Test
+    @DisplayName("getStackFrames returns empty string array when the argument 
is null")
+    public void testgetStackFramesHappyPath() {
+        final String[] actual = ExceptionUtils.getStackFrames(new Throwable() {
+            // provide static stack trace to make test stable
+            public void printStackTrace(PrintWriter s) {
+                
s.write("org.apache.commons.lang3.exception.ExceptionUtilsTest$1\n" +
+                    "\tat 
org.apache.commons.lang3.exception.ExceptionUtilsTest.testgetStackFramesGappyPath(ExceptionUtilsTest.java:706)\n"
 +
+                    "\tat 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)\n" +
+                    "\tat 
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)\n"
 +
+                    "\tat 
com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)\n");
+            }
+        });
+
+        assertArrayEquals(new String[]{
+            "org.apache.commons.lang3.exception.ExceptionUtilsTest$1",
+            "\tat 
org.apache.commons.lang3.exception.ExceptionUtilsTest.testgetStackFramesGappyPath(ExceptionUtilsTest.java:706)",
+            "\tat 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
+            "\tat 
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)",
+            "\tat 
com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)"
+        }, actual);
+    }
 }

Reply via email to