diff options
author | Gary Gregory <garydgregory@gmail.com> | 2022-06-18 13:41:40 -0400 |
---|---|---|
committer | Gary Gregory <garydgregory@gmail.com> | 2022-06-18 13:41:40 -0400 |
commit | 911fbb9352f029dd02971eebdbf7d9cffc7f9175 (patch) | |
tree | 2b370169e2ce2f52f4999e3ed7b4b8d6328af652 /src/test/java/org/apache | |
parent | 01f8edc18b1941dfa79d23c9a63724b1595a84f6 (diff) | |
download | apache-commons-lang-911fbb9352f029dd02971eebdbf7d9cffc7f9175.tar.gz |
Add ExceptionUtils.getRootCauseStackTraceList(Throwable)
Diffstat (limited to 'src/test/java/org/apache')
-rw-r--r-- | src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
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 47ff55750..ffe83c625 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -344,6 +344,32 @@ public class ExceptionUtilsTest { } @Test + public void testGetRootCauseStackTraceList_Throwable() { + assertEquals(0, ExceptionUtils.getRootCauseStackTraceList(null).size()); + + final Throwable cause = createExceptionWithCause(); + List<String> stackTrace = ExceptionUtils.getRootCauseStackTraceList(cause); + boolean match = false; + for (final String element : stackTrace) { + if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) { + match = true; + break; + } + } + assertTrue(match); + + stackTrace = ExceptionUtils.getRootCauseStackTraceList(withoutCause); + match = false; + for (final String element : stackTrace) { + if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) { + match = true; + break; + } + } + assertFalse(match); + } + + @Test @DisplayName("getStackFrames returns empty string array when the argument is null") public void testgetStackFramesHappyPath() { final String[] actual = ExceptionUtils.getStackFrames(new Throwable() { |