From b266073709ab5f3c7d67ddf840797942b6b68db8 Mon Sep 17 00:00:00 2001 From: jmehrens Date: Wed, 31 Jan 2024 21:15:25 -0600 Subject: [PATCH] MailHander should catch ServiceConfigurationError #123 Signed-off-by: jmehrens --- .../angus/mail/util/logging/AbstractLogging.java | 5 ++++- .../angus/mail/util/logging/MailHandlerTest.java | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/AbstractLogging.java b/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/AbstractLogging.java index 1460034..83b75d1 100644 --- a/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/AbstractLogging.java +++ b/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/AbstractLogging.java @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.PrintStream; import java.lang.annotation.Annotation; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; @@ -56,7 +57,9 @@ abstract class AbstractLogging { */ @SuppressWarnings({"CallToThreadDumpStack", "CallToPrintStackTrace"}) static void dump(final Throwable t) { - t.printStackTrace(); + PrintStream err = System.err; + err.print(AbstractLogging.class.getSimpleName() + ": "); + t.printStackTrace(err); } /** diff --git a/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/MailHandlerTest.java b/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/MailHandlerTest.java index c85ef63..22bb865 100644 --- a/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/MailHandlerTest.java +++ b/providers/angus-mail/src/test/java/org/eclipse/angus/mail/util/logging/MailHandlerTest.java @@ -324,15 +324,16 @@ private void testCallingClassLoader(boolean secure, ClassLoader expect) { ((ClassLoaderThread) clt).secure = false; } - assert em != null; + boolean fail = false; for (Exception exception : em.exceptions) { Throwable t = exception; if (t instanceof MessagingException == false) { dump(t); - fail(t.toString()); + fail = true; } } assertFalse(em.exceptions.isEmpty()); + assertFalse(fail); } @Test @@ -413,14 +414,16 @@ private void testVerify(boolean secure, ClassLoader expect) throws Exception { manager.reset(); } - assert em != null; + boolean fail = false; for (Exception exception : em.exceptions) { Throwable t = exception; if (t instanceof MessagingException == false) { dump(t); + fail = true; } } assertFalse(em.exceptions.isEmpty()); + assertFalse(fail); } @Test @@ -477,14 +480,16 @@ private void testSetMailProperties(boolean secure, ClassLoader expect) throws Ex ((ClassLoaderThread) clt).secure = false; } - assert em != null; + boolean fail = false; for (Exception exception : em.exceptions) { Throwable t = exception; if (t instanceof MessagingException == false) { dump(t); + fail = true; } } assertFalse(em.exceptions.isEmpty()); + assertFalse(fail); } @Test