diff --git a/src/test/java/org/apache/commons/mail/AbstractEmailTest.java b/src/test/java/org/apache/commons/mail/AbstractEmailTest.java index ac8e81ec1..74f2a49f3 100644 --- a/src/test/java/org/apache/commons/mail/AbstractEmailTest.java +++ b/src/test/java/org/apache/commons/mail/AbstractEmailTest.java @@ -16,7 +16,10 @@ */ package org.apache.commons.mail; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; @@ -96,8 +99,7 @@ public abstract class AbstractEmailTest { private static int fileNameCounter; @BeforeEach - public void setUpAbstractEmailTest() - { + public void setUpAbstractEmailTest() { emailOutputDir = new File("target/test-emails"); if (!emailOutputDir.exists()) { emailOutputDir.mkdirs(); @@ -105,11 +107,9 @@ public void setUpAbstractEmailTest() } @AfterEach - public void tearDownEmailTest() - { - //stop the fake email server (if started) - if (this.fakeMailServer != null && !isMailServerStopped(fakeMailServer)) - { + public void tearDownEmailTest() { + // stop the fake email server (if started) + if (this.fakeMailServer != null && !isMailServerStopped(fakeMailServer)) { this.fakeMailServer.stop(); assertTrue(isMailServerStopped(fakeMailServer), "Mail server didn't stop"); } @@ -240,29 +240,6 @@ protected WiserMessage validateSend(final Wiser mailServer, final String strSubj if (!bccAdd.isEmpty()) { assertTrue(bccAdd.toString().contains(mimeMessage.getHeader("Bcc", null)), "got wrong Bcc: address from mail"); } - assertEquals(strSubject, mimeMessage.getHeader("Subject", null), - "got wrong subject from mail"); - - //test from address - assertEquals(fromAdd.toString(), mimeMessage.getHeader("From", null), - "got wrong From: address from mail"); - - //test to address - assertTrue(toAdd.toString().contains(mimeMessage.getHeader("To", null)), "got wrong To: address from mail"); - - //test cc address - if (!ccAdd.isEmpty()) - { - assertTrue(ccAdd.toString().contains(mimeMessage.getHeader("Cc", null)), - "got wrong Cc: address from mail"); - } - - //test bcc address - if (!bccAdd.isEmpty()) - { - assertTrue(bccAdd.toString().contains(mimeMessage.getHeader("Bcc", null)), - "got wrong Bcc: address from mail"); - } } catch (final MessagingException me) { final IllegalStateException ise = new IllegalStateException("caught MessagingException in validateSend()"); ise.initCause(me); diff --git a/src/test/java/org/apache/commons/mail/DefaultAuthenticatorTest.java b/src/test/java/org/apache/commons/mail/DefaultAuthenticatorTest.java index a4b9d0a77..51783cf67 100644 --- a/src/test/java/org/apache/commons/mail/DefaultAuthenticatorTest.java +++ b/src/test/java/org/apache/commons/mail/DefaultAuthenticatorTest.java @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; - /** * JUnit test case for DefaultAuthenticator Class. * diff --git a/src/test/java/org/apache/commons/mail/EmailAttachmentTest.java b/src/test/java/org/apache/commons/mail/EmailAttachmentTest.java index fee5dcf72..7e8cdc2b6 100644 --- a/src/test/java/org/apache/commons/mail/EmailAttachmentTest.java +++ b/src/test/java/org/apache/commons/mail/EmailAttachmentTest.java @@ -23,7 +23,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - /** * JUnit test case for EmailAttachment Class. * @@ -33,8 +32,7 @@ public class EmailAttachmentTest extends AbstractEmailTest { private EmailAttachment attachment; @BeforeEach - public void setUpAttachmentTest() - { + public void setUpAttachmentTest() { attachment = new EmailAttachment(); } diff --git a/src/test/java/org/apache/commons/mail/EmailLiveTest.java b/src/test/java/org/apache/commons/mail/EmailLiveTest.java index 77c4d3839..3f8fa6b84 100644 --- a/src/test/java/org/apache/commons/mail/EmailLiveTest.java +++ b/src/test/java/org/apache/commons/mail/EmailLiveTest.java @@ -43,10 +43,8 @@ * http://martinfowler.com/articles/mocksArentStubs.html#ClassicalAndMockistTesting). */ public class EmailLiveTest extends AbstractEmailTest { - @BeforeEach - public void setUpLiveTest() - { + public void setUpLiveTest() { // enforce a default charset UTF-8 otherwise non-ASCII attachment names will not work System.setProperty("mail.mime.charset", "utf-8"); diff --git a/src/test/java/org/apache/commons/mail/HtmlEmailTest.java b/src/test/java/org/apache/commons/mail/HtmlEmailTest.java index 535ab848b..7ebaee42a 100644 --- a/src/test/java/org/apache/commons/mail/HtmlEmailTest.java +++ b/src/test/java/org/apache/commons/mail/HtmlEmailTest.java @@ -43,8 +43,7 @@ public class HtmlEmailTest extends AbstractEmailTest { private MockHtmlEmailConcrete email; @BeforeEach - public void setUpHtmlEmailTest() - { + public void setUpHtmlEmailTest() { // reusable objects to be used across multiple tests this.email = new MockHtmlEmailConcrete(); } diff --git a/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java b/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java index d1401f539..409a2a6c1 100644 --- a/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java +++ b/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java @@ -41,18 +41,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.activation.DataSource; -import javax.mail.internet.MimeMessage; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.mail.mocks.MockImageHtmlEmailConcrete; -import org.apache.commons.mail.resolver.DataSourceClassPathResolver; -import org.apache.commons.mail.resolver.DataSourceCompositeResolver; -import org.apache.commons.mail.resolver.DataSourceUrlResolver; -import org.apache.commons.mail.util.MimeMessageParser; -import org.apache.commons.mail.util.MimeMessageUtils; - import static org.junit.jupiter.api.Assertions.*; public class ImageHtmlEmailTest extends HtmlEmailTest { diff --git a/src/test/java/org/apache/commons/mail/InvalidAddressTest.java b/src/test/java/org/apache/commons/mail/InvalidAddressTest.java index 4afa40367..514a09b27 100644 --- a/src/test/java/org/apache/commons/mail/InvalidAddressTest.java +++ b/src/test/java/org/apache/commons/mail/InvalidAddressTest.java @@ -16,13 +16,12 @@ */ package org.apache.commons.mail; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.commons.mail.mocks.MockEmailConcrete; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.fail; - /** * JUnit test case for invalid Addresses in Email Class * @@ -45,8 +44,7 @@ public class InvalidAddressTest extends AbstractEmailTest { private MockEmailConcrete email; @BeforeEach - public void setUpInvalidAddressTest() - { + public void setUpInvalidAddressTest() { // reusable objects to be used across multiple tests this.email = new MockEmailConcrete(); } diff --git a/src/test/java/org/apache/commons/mail/InvalidInternetAddressTest.java b/src/test/java/org/apache/commons/mail/InvalidInternetAddressTest.java index 8c9041dbe..3a221f236 100644 --- a/src/test/java/org/apache/commons/mail/InvalidInternetAddressTest.java +++ b/src/test/java/org/apache/commons/mail/InvalidInternetAddressTest.java @@ -16,21 +16,16 @@ */ package org.apache.commons.mail; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - - import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import javax.mail.internet.InternetAddress; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * JUnit test case demonstrating InternetAddress validation. @@ -61,14 +56,10 @@ public class InvalidInternetAddressTest extends AbstractEmailTest { * Setup for a test */ @BeforeEach - public void setUpInvalidInternetAddressTest() - { - try - { + public void setUpInvalidInternetAddressTest() { + try { validateMethod = InternetAddress.class.getMethod("validate"); - } - catch (final Exception e) - { + } catch (final Exception e) { assertEquals(NoSuchMethodException.class, e.getClass(), "Got wrong Exception when looking for validate()"); } } diff --git a/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java b/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java index 5afe43602..2ee52b554 100644 --- a/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java +++ b/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java @@ -35,16 +35,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class MultiPartEmailTest extends AbstractEmailTest -{ +public class MultiPartEmailTest extends AbstractEmailTest { /** */ private MockMultiPartEmailConcrete email; /** File to used to test file attachments (Must be valid) */ private File testFile; @BeforeEach - public void setUpMultiPartEmailTest() throws Exception - { + public void setUpMultiPartEmailTest() throws Exception { // reusable objects to be used across multiple tests this.email = new MockMultiPartEmailConcrete(); testFile = File.createTempFile("testfile", ".txt"); diff --git a/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java b/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java index db589e8ed..0efe4ac3e 100644 --- a/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java +++ b/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java @@ -36,8 +36,7 @@ public class SendWithAttachmentsTest extends AbstractEmailTest { private MockHtmlEmailConcrete email; @BeforeEach - public void setUpSendWithAttachmentsTest() - { + public void setUpSendWithAttachmentsTest() { // reusable objects to be used across multiple tests this.email = new MockHtmlEmailConcrete(); } diff --git a/src/test/java/org/apache/commons/mail/SimpleEmailTest.java b/src/test/java/org/apache/commons/mail/SimpleEmailTest.java index 79cc31089..782e41262 100644 --- a/src/test/java/org/apache/commons/mail/SimpleEmailTest.java +++ b/src/test/java/org/apache/commons/mail/SimpleEmailTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; - /** * JUnit test case for SimpleEmailTest * @@ -37,8 +36,7 @@ public class SimpleEmailTest extends AbstractEmailTest { private MockSimpleEmail email; @BeforeEach - public void setUpSimpleEmailTest() - { + public void setUpSimpleEmailTest() { // reusable objects to be used across multiple tests this.email = new MockSimpleEmail(); } @@ -98,8 +96,7 @@ public void testSend() throws EmailException, IOException { @Test @Disabled - public void testDefaultMimeCharset() throws EmailException, IOException - { + public void testDefaultMimeCharset() throws EmailException, IOException { /* * disabling this test as it is dependent on execution order. MimeUtility.getDefaultMIMECharset does some internal caching and if mail.mime.charset is * not defined, reverts to the default Java charset which is basically the system default file encoding. diff --git a/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java b/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java index ddd21646e..7ac8e2de6 100644 --- a/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java +++ b/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java @@ -26,7 +26,6 @@ import org.apache.commons.mail.DataSourceResolver; import org.junit.jupiter.api.Test; - /** * JUnit test case for DataSourceClassPathResolver. * diff --git a/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java b/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java index a4a4481af..190090f91 100644 --- a/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java +++ b/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java @@ -19,13 +19,13 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.apache.commons.mail.DataSourceResolver; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; +import org.apache.commons.mail.DataSourceResolver; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * JUnit test case for DateSourceResolver. diff --git a/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java b/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java index 7a85102c0..6fc281a66 100644 --- a/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java +++ b/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java @@ -16,6 +16,11 @@ */ package org.apache.commons.mail.resolver; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import java.io.IOException; import java.net.URL; @@ -23,9 +28,6 @@ import org.apache.commons.mail.DataSourceResolver; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - - /** * JUnit test case for DataSourceUrlResolver. *