(geronimo-mail) 02/02: Migrate tests from JUnit 3/4 to JUnit 5 and switch to org.apache parent
[email protected] Fri, 17 Jul 2026 20:18:22 +0000
| Newsgroups | gmane.comp.java.geronimo.cvs |
|---|---|
| Message-ID | <[email protected]> |
This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/geronimo-mail.git commit 4cc73d00aff0515f96b1bf4ad07fef425036a50b Author: Richard Zowalla <[email protected]> AuthorDate: Fri Jul 17 22:18:00 2026 +0200 Migrate tests from JUnit 3/4 to JUnit 5 and switch to org.apache parent - Apply OpenRewrite JUnit4to5Migration to all test sources; drop obsolete JUnit 3 AllTests suite classes - Use junit-jupiter 5.12.2 with junit-bom to align the JUnit platform pulled in transitively by James test dependencies - Manage maven-surefire-plugin 3.5.6 at the root so all modules run JUnit 5 tests - Replace genesis-java8-flava parent with org.apache:apache:39; declare maven-bundle-plugin as build extension for bundle packaging --- .../geronimo-mail_2.1_mail/pom.xml | 1 + .../geronimo-mail_2.1_provider/pom.xml | 10 ++- .../geronimo/mail/handlers/AbstractHandler.java | 8 +- .../geronimo/mail/issues/GERONIMO6480Test.java | 19 +++-- .../apache/geronimo/mail/issues/IssuesTest.java | 31 ++++---- .../mail/store/imap/AuthenticationTest.java | 20 +++-- .../geronimo/mail/store/imap/IMAPStoreTest.java | 7 +- .../imap/connection/IMAPBodyStructureTest.java | 8 +- .../geronimo/mail/store/pop3/POP3StoreTest.java | 85 +++++++++++++--------- .../mail/testserver/AbstractProtocolTest.java | 26 ++++--- .../mail/transport/smtp/SMTPTransportTest.java | 2 + geronimo-mail_2.1_impl/pom.xml | 14 ++-- geronimo-mail_2.1_spec/pom.xml | 7 +- .../src/test/java/jakarta/mail/AllTests.java | 45 ------------ .../src/test/java/jakarta/mail/EventQueueTest.java | 25 ++++--- .../src/test/java/jakarta/mail/FlagsTest.java | 41 ++++++++--- .../src/test/java/jakarta/mail/HeaderTest.java | 11 +-- .../test/java/jakarta/mail/MessageContextTest.java | 5 +- .../java/jakarta/mail/MessagingExceptionTest.java | 40 +++++----- .../jakarta/mail/PasswordAuthenticationTest.java | 13 ++-- .../src/test/java/jakarta/mail/QuotaTest.java | 10 ++- .../src/test/java/jakarta/mail/SessionTest.java | 7 +- .../src/test/java/jakarta/mail/URLNameTest.java | 19 +++-- .../java/jakarta/mail/event/AllEventTests.java | 41 ----------- .../jakarta/mail/event/ConnectionEventTest.java | 14 ++-- .../java/jakarta/mail/event/FolderEventTest.java | 14 ++-- .../mail/event/MessageChangedEventTest.java | 14 ++-- .../jakarta/mail/event/MessageCountEventTest.java | 14 ++-- .../java/jakarta/mail/event/StoreEventTest.java | 14 ++-- .../jakarta/mail/event/TransportEventTest.java | 14 ++-- .../jakarta/mail/internet/AllInternetTests.java | 38 ---------- .../mail/internet/ContentDispositionTest.java | 12 +-- .../jakarta/mail/internet/ContentTypeTest.java | 44 +++++++++-- .../jakarta/mail/internet/HeaderTokenizerTest.java | 34 ++++++--- .../jakarta/mail/internet/InternetAddressTest.java | 82 ++++++++++++++------- .../jakarta/mail/internet/InternetHeadersTest.java | 19 ++++- .../jakarta/mail/internet/MailDateFormatTest.java | 7 +- .../jakarta/mail/internet/MimeBodyPartTest.java | 25 ++++++- .../jakarta/mail/internet/MimeMessageTest.java | 49 ++++++++++--- .../jakarta/mail/internet/MimeMultipartTest.java | 37 +++++++--- .../test/java/jakarta/mail/internet/MimeTest.java | 9 ++- .../jakarta/mail/internet/MimeUtilityTest.java | 12 ++- .../jakarta/mail/internet/NewsAddressTest.java | 7 +- .../jakarta/mail/internet/ParameterListTest.java | 37 ++++++---- .../mail/internet/PreencodedMimeBodyPartTest.java | 15 ++-- .../jakarta/mail/util/ByteArrayDataSourceTest.java | 11 +-- .../mail/util/SharedByteArrayInputStreamTest.java | 11 +-- .../mail/util/SharedFileInputStreamTest.java | 14 ++-- pom.xml | 19 ++++- 49 files changed, 629 insertions(+), 432 deletions(-) diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_mail/pom.xml b/geronimo-mail_2.1_impl/geronimo-mail_2.1_mail/pom.xml index 61eda0f..8958c41 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_mail/pom.xml +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_mail/pom.xml @@ -123,6 +123,7 @@ <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton=true</Bundle-SymbolicName> diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/pom.xml b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/pom.xml index 79efd23..a26a8f0 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/pom.xml +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/pom.xml @@ -50,8 +50,9 @@ </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <version>5.12.2</version> <scope>test</scope> </dependency> @@ -357,6 +358,10 @@ <groupId>org.eclipse.angus</groupId> <artifactId>angus-mail</artifactId> </exclusion> + <exclusion> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </exclusion> </exclusions> </dependency> @@ -404,6 +409,7 @@ <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton=true</Bundle-SymbolicName> diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/handlers/AbstractHandler.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/handlers/AbstractHandler.java index 65ef406..bcb89c5 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/handlers/AbstractHandler.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/handlers/AbstractHandler.java @@ -23,15 +23,18 @@ import java.io.ByteArrayOutputStream; import jakarta.activation.DataContentHandler; import jakarta.activation.DataSource; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public abstract class AbstractHandler extends TestCase { +public abstract class AbstractHandler { protected DataContentHandler dch; protected String mimeType; + @Test public void testGetContent() throws Exception { final byte[] bytes = "Hello World".getBytes(); DataSource ds = new DataSource() { @@ -55,6 +58,7 @@ public abstract class AbstractHandler extends TestCase { assertEquals("Hello World", o); } + @Test public void testWriteTo() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); dch.writeTo("Hello World", mimeType, baos); diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/GERONIMO6480Test.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/GERONIMO6480Test.java index 7298984..c0b1b69 100755 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/GERONIMO6480Test.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/GERONIMO6480Test.java @@ -18,7 +18,7 @@ package org.apache.geronimo.mail.issues; import java.io.File; import java.util.Properties; - +import org.junit.jupiter.api.Assertions; import jakarta.activation.DataHandler; import jakarta.activation.FileDataSource; import jakarta.mail.BodyPart; @@ -32,22 +32,24 @@ import jakarta.mail.internet.MimeBodyPart; import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimeMultipart; -import junit.framework.Assert; +import org.junit.jupiter.api.Test; import org.apache.geronimo.mail.testserver.AbstractProtocolTest; public class GERONIMO6480Test extends AbstractProtocolTest { + @Test public void testGERONIMO6480_0() throws Exception { System.setProperty("mail.mime.setcontenttypefilename", "false"); BodyPart attachmentPart = new MimeBodyPart(); attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf")))); attachmentPart.setFileName("test.pdf"); String contentType = getSendedAttachmentContentType(attachmentPart); - Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); + Assertions.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); // "text/plain; name=test.pdf" with Geronimo because setFileName force it to 'text/plain' when adding the 'name=' part instead of keeping it null System.clearProperty("mail.mime.setcontenttypefilename"); } + @Test public void testGERONIMO6480_1() throws Exception { System.setProperty("mail.mime.setcontenttypefilename", "false"); BodyPart attachmentPart = new MimeBodyPart(); @@ -56,20 +58,22 @@ public class GERONIMO6480Test extends AbstractProtocolTest { attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf")))); attachmentPart.setFileName("test.pdf"); String contentType = getSendedAttachmentContentType(attachmentPart); - Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); + Assertions.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); // "text/plain; name=test.pdf" with Geronimo because setFileName force it to 'text/plain' when adding the 'name=' part instead of keeping it null System.clearProperty("mail.mime.setcontenttypefilename"); } + @Test public void testGERONIMO6480_2() throws Exception { BodyPart attachmentPart = new MimeBodyPart(); attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf")))); attachmentPart.addHeader("Content-Type", "aplication/pdf"); attachmentPart.setFileName("test.pdf"); String contentType = getSendedAttachmentContentType(attachmentPart); - Assert.assertEquals("aplication/pdf; name=test.pdf".toLowerCase(), contentType.toLowerCase()); + Assertions.assertEquals("aplication/pdf; name=test.pdf".toLowerCase(), contentType.toLowerCase()); } + @Test public void testGERONIMO6480_3() throws Exception { System.setProperty("mail.mime.setcontenttypefilename", Boolean.FALSE.toString()); try { @@ -77,18 +81,19 @@ public class GERONIMO6480Test extends AbstractProtocolTest { attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf")))); attachmentPart.setFileName("test.pdf"); String contentType = getSendedAttachmentContentType(attachmentPart); - Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); + Assertions.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); } finally { System.setProperty("mail.mime.setcontenttypefilename", Boolean.TRUE.toString()); } } + @Test public void testGERONIMO6480_4() throws Exception { BodyPart attachmentPart = new MimeBodyPart(); attachmentPart.setFileName("test.pdf"); attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf")))); String contentType = getSendedAttachmentContentType(attachmentPart); - Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); + Assertions.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase()); } private File getAbsoluteFilePathFromClassPath(String filename) throws Exception { diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/IssuesTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/IssuesTest.java index a0d25ef..71f4049 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/IssuesTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/issues/IssuesTest.java @@ -20,7 +20,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; import java.util.Properties; - +import org.junit.jupiter.api.Assertions; import jakarta.activation.DataHandler; import jakarta.activation.DataSource; import jakarta.activation.FileDataSource; @@ -35,13 +35,14 @@ import jakarta.mail.internet.MimeBodyPart; import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimeMultipart; -import junit.framework.Assert; +import org.junit.jupiter.api.Test; import org.apache.geronimo.mail.testserver.AbstractProtocolTest; import org.apache.geronimo.mail.testserver.MailServer; public class IssuesTest extends AbstractProtocolTest { + @Test public void testGERONIMO6519() throws Exception { PrintStream original = System.out; @@ -65,28 +66,32 @@ public class IssuesTest extends AbstractProtocolTest { message.setText("test"); Transport.send(message); - Assert.assertTrue(baos.toString().contains("EHLO some.full.qualified.name.com")); + Assertions.assertTrue(baos.toString().contains("EHLO some.full.qualified.name.com")); } finally { System.setOut(original); } } - + + @Test public void testGERONIMO4594() throws Exception { - Assert.assertTrue(doGERONIMO4594(true, true)); + Assertions.assertTrue(doGERONIMO4594(true, true)); } - + + @Test public void testGERONIMO4594Fail0() throws Exception { - Assert.assertFalse(doGERONIMO4594(false, true)); + Assertions.assertFalse(doGERONIMO4594(false, true)); } - + + @Test public void testGERONIMO4594Fail1() throws Exception { - Assert.assertFalse(doGERONIMO4594(false, false)); + Assertions.assertFalse(doGERONIMO4594(false, false)); } - + + @Test public void testGERONIMO4594Fail2() throws Exception { - Assert.assertFalse(doGERONIMO4594(true, false)); + Assertions.assertFalse(doGERONIMO4594(true, false)); } private boolean doGERONIMO4594(boolean decode, boolean encode) throws Exception { @@ -120,7 +125,7 @@ public class IssuesTest extends AbstractProtocolTest { Multipart multipart = new MimeMultipart(); messageBodyPart.setText("This is message body"); File file = MailServer.getAbsoluteFilePathFromClassPath("pdf-test.pdf"); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); DataSource source = new FileDataSource(file.getAbsoluteFile()); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(specialFileName); @@ -134,7 +139,7 @@ public class IssuesTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(1, f.getMessageCount()); + Assertions.assertEquals(1, f.getMessageCount()); Message[] messages = new Message[2]; messages[0] = f.getMessage(1); boolean match = specialFileName.equals(((Multipart) messages[0].getContent()).getBodyPart(0).getFileName()); diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/AuthenticationTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/AuthenticationTest.java index 6f9776c..274c620 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/AuthenticationTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/AuthenticationTest.java @@ -24,29 +24,35 @@ import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.Properties; +import org.junit.jupiter.api.Assertions; import jakarta.mail.MessagingException; import jakarta.mail.Session; import jakarta.mail.Store; -import junit.framework.Assert; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import org.apache.geronimo.mail.util.Base64; import org.apache.geronimo.mail.testserver.MailServer; -public class AuthenticationTest extends TestCase { +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +public class AuthenticationTest { + + @Test public void testImplUsage() throws Exception { //check that we load our mail impl Properties props = new Properties(); props.setProperty("mail.store.protocol", "imap"); Session jmsession = Session.getInstance(props); - Assert.assertEquals(IMAPStore.class, jmsession.getStore().getClass()); + Assertions.assertEquals(IMAPStore.class, jmsession.getStore().getClass()); } - + + @Test public void testAuthenticatePlain() throws Exception { final int listenerPort = MailServer.acquirePort(); @@ -67,6 +73,7 @@ public class AuthenticationTest extends TestCase { assertNull(fs.exception); } + @Test public void testAuthenticatePlainFail() throws Exception { final int listenerPort = MailServer.acquirePort(); @@ -90,6 +97,7 @@ public class AuthenticationTest extends TestCase { } } + @Test public void testAuthenticatePlainAuthzid() throws Exception { final int listenerPort = MailServer.acquirePort(); @@ -112,6 +120,7 @@ public class AuthenticationTest extends TestCase { } + @Test public void testAuthenticateOAuth2() throws Exception { final int listenerPort = MailServer.acquirePort(); FakeImapAuthPlainServer fs = new FakeImapAuthPlainServer("", "user", "token"); @@ -139,6 +148,7 @@ public class AuthenticationTest extends TestCase { } + @Test public void testAuthenticateOAuth2Fail() throws Exception { final int listenerPort = MailServer.acquirePort(); FakeImapAuthPlainServer fs = new FakeImapAuthPlainServer("", "user", "token"); diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/IMAPStoreTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/IMAPStoreTest.java index 9f0143d..bbee4c6 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/IMAPStoreTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/IMAPStoreTest.java @@ -19,6 +19,7 @@ package org.apache.geronimo.mail.store.imap; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Properties; +import org.junit.jupiter.api.Test; import jakarta.mail.Folder; import jakarta.mail.Message; @@ -29,9 +30,13 @@ import jakarta.mail.internet.MimeMultipart; import org.apache.geronimo.mail.testserver.AbstractProtocolTest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class IMAPStoreTest extends AbstractProtocolTest { - + + @Test public void testSimple() throws Exception { start(); diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/connection/IMAPBodyStructureTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/connection/IMAPBodyStructureTest.java index ad05b2b..17a5409 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/connection/IMAPBodyStructureTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/imap/connection/IMAPBodyStructureTest.java @@ -22,11 +22,15 @@ import java.io.BufferedReader; import jakarta.mail.internet.MimeMessage; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + import org.apache.geronimo.mail.store.imap.IMAPStoreTest; -public class IMAPBodyStructureTest extends TestCase { +import static org.junit.jupiter.api.Assertions.assertNull; + +public class IMAPBodyStructureTest { + @Test public void testMultipart() throws Exception { InputStream in = IMAPStoreTest.class.getResourceAsStream("/imap/multipart.bodystructure"); BufferedReader r = new BufferedReader(new InputStreamReader(in)); diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/pop3/POP3StoreTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/pop3/POP3StoreTest.java index 72a3a8a..79167e8 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/pop3/POP3StoreTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/store/pop3/POP3StoreTest.java @@ -19,6 +19,7 @@ package org.apache.geronimo.mail.store.pop3; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Properties; +import org.junit.jupiter.api.Assertions; import jakarta.mail.Address; import jakarta.mail.FetchProfile; @@ -35,16 +36,19 @@ import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimeMultipart; -import junit.framework.Assert; +import org.junit.jupiter.api.Test; import org.apache.geronimo.mail.testserver.AbstractProtocolTest; import org.apache.geronimo.mail.testserver.MailServer.DummySocketFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + public class POP3StoreTest extends AbstractProtocolTest { - - - + + @Test public void testSendRetrieve() throws Exception { start(); @@ -69,7 +73,7 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); Message[] messages = new Message[2]; messages[0] = f.getMessage(1); messages[1] = f.getMessage(2); @@ -109,8 +113,9 @@ public class POP3StoreTest extends AbstractProtocolTest { assertEquals(input.getContentType().toLowerCase(), output.getContentType().toLowerCase()); } - + + @Test public void testStartTLS() throws Exception { pop3Conf.enableSSL(true, false); @@ -131,12 +136,13 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); f.close(false); store.close(); } + @Test public void testAPOP() throws Exception { pop3Conf.enableSSL(true, false); @@ -155,12 +161,13 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); f.close(false); store.close(); } + @Test public void testFetch() throws Exception { @@ -185,30 +192,30 @@ public class POP3StoreTest extends AbstractProtocolTest { Message[] msgs = f.getMessages(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); - Assert.assertEquals(2, msgs.length); + Assertions.assertEquals(2, msgs.length); f.fetch(msgs, fp); - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); for (int i = 0; i < msgs.length; i++) { Message message = msgs[i]; message.writeTo(bout); String msg = bout.toString(); - Assert.assertNotNull(msg); + Assertions.assertNotNull(msg); int num = message.getMessageNumber(); - Assert.assertTrue(num > 0); + Assertions.assertTrue(num > 0); String uid = ((POP3Folder) f).getUID(message); - Assert.assertNotNull(uid); - Assert.assertTrue(!uid.isEmpty()); + Assertions.assertNotNull(uid); + Assertions.assertTrue(!uid.isEmpty()); } f.close(false); store.close(); } - - - + + + @Test public void testDelete() throws Exception { @@ -227,21 +234,21 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_WRITE); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); Message[] msgs = f.getMessages(); f.setFlags(msgs, new Flags(Flag.DELETED), true); - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); f.getMessage(1).getSubject(); //should fail //Assert.assertEquals(2, f.expunge()); f.close(false); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(0, f.getMessageCount()); + Assertions.assertEquals(0, f.getMessageCount()); store.close(); } - - - + + + @Test public void testStartTLSFail() throws Exception { @@ -267,6 +274,7 @@ public class POP3StoreTest extends AbstractProtocolTest { } } + @Test public void testSSLEnable() throws Exception { @@ -287,12 +295,13 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); f.close(false); store.close(); } + @Test public void testSSLPop3s() throws Exception { @@ -312,12 +321,13 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); f.close(false); store.close(); } - + + @Test public void testSSLPop3sFactoryClass() throws Exception { @@ -340,7 +350,7 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); fail(); } catch (MessagingException e) { - Assert.assertEquals("dummy socket factory", e.getCause().getCause().getMessage()); + Assertions.assertEquals("dummy socket factory", e.getCause().getCause().getMessage()); //Expected } @@ -349,6 +359,7 @@ public class POP3StoreTest extends AbstractProtocolTest { } + @Test public void testSSLPop3sFactoryInstance() throws Exception { @@ -371,13 +382,14 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); fail(); } catch (MessagingException e) { - Assert.assertEquals("dummy socket factory", e.getCause().getMessage()); + Assertions.assertEquals("dummy socket factory", e.getCause().getMessage()); //Expected } } - + + @Test public void testSSLPop3sNotEnabled() throws Exception { @@ -398,12 +410,13 @@ public class POP3StoreTest extends AbstractProtocolTest { store.connect("127.0.0.1", "serveruser", "serverpass"); Folder f = store.getFolder("INBOX"); f.open(Folder.READ_ONLY); //TODO STAT only when folder open??? - Assert.assertEquals(2, f.getMessageCount()); + Assertions.assertEquals(2, f.getMessageCount()); f.close(false); store.close(); } - + + @Test public void testPop3GetMsgs() throws Exception { @@ -426,18 +439,18 @@ public class POP3StoreTest extends AbstractProtocolTest { Message[] msgs = f.getMessages(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); - Assert.assertEquals(2, msgs.length); + Assertions.assertEquals(2, msgs.length); for (int i = 0; i < msgs.length; i++) { Message message = msgs[i]; message.writeTo(bout); String msg = bout.toString(); - Assert.assertNotNull(msg); + Assertions.assertNotNull(msg); int num = message.getMessageNumber(); - Assert.assertTrue(num > 0); + Assertions.assertTrue(num > 0); String uid = ((POP3Folder) f).getUID(message); - Assert.assertNotNull(uid); - Assert.assertTrue(!uid.isEmpty()); + Assertions.assertNotNull(uid); + Assertions.assertTrue(!uid.isEmpty()); } f.close(false); diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/testserver/AbstractProtocolTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/testserver/AbstractProtocolTest.java index 19a02f6..b7dcedd 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/testserver/AbstractProtocolTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/testserver/AbstractProtocolTest.java @@ -25,21 +25,22 @@ import jakarta.mail.Transport; import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; -import junit.framework.Assert; -import junit.framework.TestCase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.apache.geronimo.mail.store.pop3.POP3StoreTest; -public abstract class AbstractProtocolTest extends TestCase { +public abstract class AbstractProtocolTest { protected MailServer server = new MailServer(); protected MailServer.Pop3TestConfiguration pop3Conf; protected MailServer.SmtpTestConfiguration smtpConf; protected MailServer.ImapTestConfiguration imapConf; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + public void setUp() throws Exception { pop3Conf = new MailServer.Pop3TestConfiguration(); smtpConf = new MailServer.SmtpTestConfiguration(); imapConf = new MailServer.ImapTestConfiguration(); @@ -52,33 +53,36 @@ public abstract class AbstractProtocolTest extends TestCase { } + @Test public void testImplUsageImap() throws Exception { //check that we load our mail impl final Properties props = new Properties(); props.setProperty("mail.store.protocol", "imap"); final Session jmsession = Session.getInstance(props); - Assert.assertEquals(org.apache.geronimo.mail.store.imap.IMAPStore.class, jmsession.getStore().getClass()); + Assertions.assertEquals(org.apache.geronimo.mail.store.imap.IMAPStore.class, jmsession.getStore().getClass()); } + @Test public void testImplUsagePop3() throws Exception { //check that we load our mail impl final Properties props = new Properties(); props.setProperty("mail.store.protocol", "pop3"); final Session jmsession = Session.getInstance(props); - Assert.assertEquals(org.apache.geronimo.mail.store.pop3.POP3Store.class, jmsession.getStore().getClass()); + Assertions.assertEquals(org.apache.geronimo.mail.store.pop3.POP3Store.class, jmsession.getStore().getClass()); } + @Test public void testImplUsageSmtp() throws Exception { //check that we load our mail impl final Properties props = new Properties(); props.setProperty("mail.transport.protocol", "smtp"); final Session jmsession = Session.getInstance(props); - Assert.assertEquals(org.apache.geronimo.mail.transport.smtp.SMTPTransport.class, jmsession.getTransport().getClass()); + Assertions.assertEquals(org.apache.geronimo.mail.transport.smtp.SMTPTransport.class, jmsession.getTransport().getClass()); } @@ -107,8 +111,8 @@ public abstract class AbstractProtocolTest extends TestCase { Transport.send(message, new Address[] { new InternetAddress("serveruser@localhost") }); } - @Override - protected void tearDown() throws Exception { + @AfterEach + public void tearDown() throws Exception { server.stop(); } diff --git a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/transport/smtp/SMTPTransportTest.java b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/transport/smtp/SMTPTransportTest.java index d3369ca..3927961 100644 --- a/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/transport/smtp/SMTPTransportTest.java +++ b/geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/test/java/org/apache/geronimo/mail/transport/smtp/SMTPTransportTest.java @@ -17,6 +17,7 @@ package org.apache.geronimo.mail.transport.smtp; import java.util.Properties; +import org.junit.jupiter.api.Test; import jakarta.mail.Session; import jakarta.mail.Transport; @@ -27,6 +28,7 @@ import org.apache.geronimo.mail.testserver.AbstractProtocolTest; public class SMTPTransportTest extends AbstractProtocolTest { + @Test public void testSSLEnable() throws Exception { diff --git a/geronimo-mail_2.1_impl/pom.xml b/geronimo-mail_2.1_impl/pom.xml index 151d6e9..e491889 100644 --- a/geronimo-mail_2.1_impl/pom.xml +++ b/geronimo-mail_2.1_impl/pom.xml @@ -56,9 +56,11 @@ </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.13.2</version> + <groupId>org.junit</groupId> + <artifactId>junit-bom</artifactId> + <version>5.12.2</version> + <type>pom</type> + <scope>import</scope> </dependency> <!-- INTERNAL --> @@ -86,12 +88,6 @@ <version>2.3</version> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.18</version> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> diff --git a/geronimo-mail_2.1_spec/pom.xml b/geronimo-mail_2.1_spec/pom.xml index df202a8..95da4a8 100644 --- a/geronimo-mail_2.1_spec/pom.xml +++ b/geronimo-mail_2.1_spec/pom.xml @@ -82,9 +82,9 @@ <version>0.8.14</version> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.13.2</version> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <version>5.12.2</version> <scope>test</scope> </dependency> </dependencies> @@ -144,6 +144,7 @@ <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> <version>5.1.9</version> <configuration> <instructions> diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/AllTests.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/AllTests.java deleted file mode 100644 index 478f605..0000000 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/AllTests.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package jakarta.mail; - -import jakarta.mail.event.AllEventTests; -import jakarta.mail.internet.AllInternetTests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @version $Revision $ $Date$ - */ -public class AllTests { - public static Test suite() { - final TestSuite suite = new TestSuite("Test for jakarta.mail"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(FlagsTest.class)); - suite.addTest(new TestSuite(HeaderTest.class)); - suite.addTest(new TestSuite(MessagingExceptionTest.class)); - suite.addTest(new TestSuite(URLNameTest.class)); - suite.addTest(new TestSuite(PasswordAuthenticationTest.class)); - suite.addTest(AllEventTests.suite()); - suite.addTest(AllInternetTests.suite()); - //$JUnit-END$ - return suite; - } -} diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/EventQueueTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/EventQueueTest.java index 1425d85..824a3bd 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/EventQueueTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/EventQueueTest.java @@ -22,26 +22,33 @@ package jakarta.mail; import java.util.Vector; import jakarta.mail.event.FolderEvent; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.mail.event.FolderListener; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class EventQueueTest extends TestCase { - protected EventQueue queue; - - @Override +public class EventQueueTest { + protected EventQueue queue; + + @BeforeEach public void setUp() throws Exception { queue = new EventQueue(); } - - @Override + + @AfterEach public void tearDown() throws Exception { queue.stop(); } - + + @Test public void testEvent() { doEventTests(FolderEvent.CREATED); doEventTests(FolderEvent.RENAMED); @@ -67,7 +74,7 @@ public class EventQueueTest extends TestCase { Thread.sleep(1000); } catch (final InterruptedException e ) { } - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } public static class FolderListenerTest implements FolderListener { diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java index d1bf7e6..fced105 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java @@ -21,27 +21,29 @@ package jakarta.mail; import java.util.*; -import junit.framework.TestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @version $Rev$ $Date$ */ -public class FlagsTest extends TestCase { +public class FlagsTest { private List flagtypes; private Flags flags; /** * Constructor for FlagsTest. * @param arg0 */ - public FlagsTest(final String name) { - super(name); - } + /* * @see TestCase#setUp() */ - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + public void setUp() throws Exception { flags = new Flags(); flagtypes = new LinkedList(); flagtypes.add(Flags.Flag.ANSWERED); @@ -52,17 +54,21 @@ public class FlagsTest extends TestCase { flagtypes.add(Flags.Flag.SEEN); Collections.shuffle(flagtypes); } + + @Test public void testHashCode() { final int before = flags.hashCode(); flags.add("Test"); assertTrue( - "Before: " + before + ", now " + flags.hashCode(), - flags.hashCode() != before); + flags.hashCode() != before, + "Before: " + before + ", now " + flags.hashCode()); assertTrue(flags.hashCode() != 0); } + /* * Test for void add(Flag) */ + @Test public void testAddAndRemoveFlag() { Iterator it = flagtypes.iterator(); while (it.hasNext()) { @@ -78,9 +84,11 @@ public class FlagsTest extends TestCase { assertFalse(flags.contains(flag)); } } + /* * Test for void add(String) */ + @Test public void testAddString() { assertFalse(flags.contains("Frog")); flags.add("Frog"); @@ -88,9 +96,11 @@ public class FlagsTest extends TestCase { flags.remove("Frog"); assertFalse(flags.contains("Frog")); } + /* * Test for void add(Flags) */ + @Test public void testAddFlags() { final Flags other = new Flags(); other.add("Stuff"); @@ -108,9 +118,11 @@ public class FlagsTest extends TestCase { assertFalse(flags.contains(other)); assertTrue(flags.contains("Thing")); } + /* * Test for boolean equals(Object) */ + @Test public void testEqualsObject() { final Flags other = new Flags(); other.add("Stuff"); @@ -118,6 +130,8 @@ public class FlagsTest extends TestCase { flags.add(other); assertEquals(flags, other); } + + @Test public void testGetSystemFlags() { flags.add("Stuff"); flags.add("Another"); @@ -130,6 +144,8 @@ public class FlagsTest extends TestCase { || (array[0] == Flags.Flag.RECENT && array[1] == Flags.Flag.FLAGGED)); } + + @Test public void testGetUserFlags() { final String stuff = "Stuff"; final String another = "Another"; @@ -143,6 +159,8 @@ public class FlagsTest extends TestCase { (array[0] == stuff && array[1] == another) || (array[0] == another && array[1] == stuff)); } + + @Test public void testClone() throws CloneNotSupportedException { flags.add("Thing"); flags.add(Flags.Flag.RECENT); @@ -151,6 +169,7 @@ public class FlagsTest extends TestCase { assertEquals(other, flags); } + @Test public void testClearSystemFlags() { Flags f = new Flags(); f.add(Flags.Flag.ANSWERED); @@ -168,6 +187,7 @@ public class FlagsTest extends TestCase { assertEquals("TEST", f.getUserFlags()[0]); } + @Test public void testClearuserFlags() { Flags f = new Flags(); f.add(Flags.Flag.ANSWERED); @@ -190,6 +210,7 @@ public class FlagsTest extends TestCase { assertEquals(0, f.getUserFlags().length); } + @Test public void testRetainAllFlags() { Flags f = new Flags(); f.add(Flags.Flag.ANSWERED); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java index 442b9c8..2df4ecc 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java @@ -19,15 +19,16 @@ package jakarta.mail; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class HeaderTest extends TestCase { - public HeaderTest(final String name) { - super(name); - } +public class HeaderTest { + + @Test public void testHeader() { final Header header = new Header("One", "Two"); assertEquals("One", header.getName()); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java index 9bc603c..7fd8121 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java @@ -19,12 +19,13 @@ package jakarta.mail; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; /** * @version $Rev$ $Date$ */ -public class MessageContextTest extends TestCase { +public class MessageContextTest { + @Test public void testNothing() { } /* diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java index 0f15234..8c63d0e 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java @@ -19,24 +19,25 @@ package jakarta.mail; -import junit.framework.TestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @version $Revision $ $Date$ */ -public class MessagingExceptionTest extends TestCase { +public class MessagingExceptionTest { private RuntimeException e; private MessagingException d; private MessagingException c; private MessagingException b; private MessagingException a; - public MessagingExceptionTest(final String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + + @BeforeEach + public void setUp() throws Exception { //Initialize cause with null, make sure the getCause will not be affected a = new MessagingException("A", null); @@ -45,11 +46,13 @@ public class MessagingExceptionTest extends TestCase { d = new MessagingException("D"); e = new RuntimeException("E"); } - + + @Test public void testMessagingExceptionString() { assertEquals("A", a.getMessage()); } - + + @Test public void testNextException() { assertTrue(a.setNextException(b)); assertEquals(b, a.getNextException()); @@ -75,21 +78,24 @@ public class MessagingExceptionTest extends TestCase { final int ap = message.indexOf("A"); final int bp = message.indexOf("B"); final int cp = message.indexOf("C"); - assertTrue("A does not contain 'A'", ap != -1); - assertTrue("B does not contain 'B'", bp != -1); - assertTrue("C does not contain 'C'", cp != -1); + assertTrue(ap != -1, "A does not contain 'A'"); + assertTrue(bp != -1, "B does not contain 'B'"); + assertTrue(cp != -1, "C does not contain 'C'"); } - + + @Test public void testNextExceptionWrong() { assertTrue(a.setNextException(e)); assertFalse(a.setNextException(b)); } - + + @Test public void testNextExceptionWrong2() { assertTrue(a.setNextException(e)); assertFalse(a.setNextException(b)); } - + + @Test public void testMessagingExceptionStringException() { final MessagingException x = new MessagingException("X", a); assertEquals("X (jakarta.mail.MessagingException: A)", x.getMessage()); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java index debb373..e8bfff0 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java @@ -19,15 +19,16 @@ package jakarta.mail; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class PasswordAuthenticationTest extends TestCase { - public PasswordAuthenticationTest(final String name) { - super(name); - } +public class PasswordAuthenticationTest { + + @Test public void testPA() { final String user = String.valueOf(System.currentTimeMillis()); final String password = "JobbyJobbyJobby" + user; @@ -35,6 +36,8 @@ public class PasswordAuthenticationTest extends TestCase { assertEquals(user, pa.getUserName()); assertEquals(password, pa.getPassword()); } + + @Test public void testPasswordAuthentication() { final PasswordAuthentication pa = new PasswordAuthentication("Alex", "xelA"); assertEquals("Alex", pa.getUserName()); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java index 7ac4b23..c8dbd4a 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java @@ -19,13 +19,19 @@ package jakarta.mail; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @version $Rev$ $Date$ */ -public class QuotaTest extends TestCase { +public class QuotaTest { + @Test public void testQuota() throws MessagingException { final Quota quota = new Quota("Fred"); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java index 5406315..0cda873 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java @@ -21,12 +21,15 @@ package jakarta.mail; import java.util.Properties; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @version $Rev$ $Date$ */ -public class SessionTest extends TestCase { +public class SessionTest { + @Test public void testAddProvider() throws MessagingException { final Properties props = System.getProperties(); // Get a Session object diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java index 182da5d..6c59b73 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java @@ -22,16 +22,19 @@ package jakarta.mail; import java.net.MalformedURLException; import java.net.URL; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class URLNameTest extends TestCase { - public URLNameTest(final String name) { - super(name); - } +public class URLNameTest { + @Test public void testURLNameString() { String s; URLName name; @@ -179,6 +182,7 @@ public class URLNameTest extends TestCase { } } + @Test public void testURLNameAll() { URLName name; name = new URLName(null, null, -1, null, null, null); @@ -317,6 +321,7 @@ public class URLNameTest extends TestCase { } } + @Test public void testURLNameURL() throws MalformedURLException { URL url; URLName name; @@ -337,6 +342,7 @@ public class URLNameTest extends TestCase { } } + @Test public void testEquals() throws MalformedURLException { URLName name1 = new URLName("http://www.apache.org"); assertEquals(name1, new URLName("http://www.apache.org")); @@ -358,6 +364,7 @@ public class URLNameTest extends TestCase { assertEquals(new URLName("http://www.apache.org"), new URLName("http", "www.apache.org", -1, null, null, "doe")); } + @Test public void testHashCode() { final URLName name1 = new URLName("http://www.apache.org/file"); final URLName name2 = new URLName("http://www.apache.org/file#ref"); @@ -365,12 +372,14 @@ public class URLNameTest extends TestCase { assertTrue(name1.hashCode() == name2.hashCode()); } + @Test public void testNullProtocol() { final URLName name1 = new URLName(null, "www.apache.org", -1, null, null, null); final URLName name2 = new URLName(null, "www.apache.org", -1, null, null, null); assertTrue(!name2.equals(name1)); } + @Test public void testOpaqueSchemes() { String s; URLName name; diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java deleted file mode 100644 index 2f0e39d..0000000 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package jakarta.mail.event; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @version $Rev$ $Date$ - */ -public class AllEventTests { - public static Test suite() { - final TestSuite suite = new TestSuite("Test for jakarta.mail.event"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(ConnectionEventTest.class)); - suite.addTest(new TestSuite(FolderEventTest.class)); - suite.addTest(new TestSuite(MessageChangedEventTest.class)); - suite.addTest(new TestSuite(StoreEventTest.class)); - suite.addTest(new TestSuite(MessageCountEventTest.class)); - suite.addTest(new TestSuite(TransportEventTest.class)); - //$JUnit-END$ - return suite; - } -} diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java index f53a1af..9a96fc3 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java @@ -19,12 +19,15 @@ package jakarta.mail.event; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class ConnectionEventTest extends TestCase { +public class ConnectionEventTest { public static class ConnectionListenerTest implements ConnectionListener { private int state = 0; public void closed(final ConnectionEvent event) { @@ -49,17 +52,16 @@ public class ConnectionEventTest extends TestCase { state = ConnectionEvent.OPENED; } } - public ConnectionEventTest(final String name) { - super(name); - } private void doEventTests(final int type) { final ConnectionEvent event = new ConnectionEvent(this, type); assertEquals(this, event.getSource()); assertEquals(type, event.getType()); final ConnectionListenerTest listener = new ConnectionListenerTest(); event.dispatch(listener); - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } + + @Test public void testEvent() { doEventTests(ConnectionEvent.CLOSED); doEventTests(ConnectionEvent.OPENED); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java index 8fdc812..ac6e1cc 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java @@ -19,15 +19,17 @@ package jakarta.mail.event; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class FolderEventTest extends TestCase { - public FolderEventTest(final String name) { - super(name); - } +public class FolderEventTest { + + @Test public void testEvent() { doEventTests(FolderEvent.CREATED); doEventTests(FolderEvent.RENAMED); @@ -39,7 +41,7 @@ public class FolderEventTest extends TestCase { assertEquals(type, event.getType()); final FolderListenerTest listener = new FolderListenerTest(); event.dispatch(listener); - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } public static class FolderListenerTest implements FolderListener { private int state = 0; diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java index 1b2830d..1c5f6eb 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java @@ -19,15 +19,17 @@ package jakarta.mail.event; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class MessageChangedEventTest extends TestCase { - public MessageChangedEventTest(final String name) { - super(name); - } +public class MessageChangedEventTest { + + @Test public void testEvent() { doEventTests(MessageChangedEvent.ENVELOPE_CHANGED); doEventTests(MessageChangedEvent.FLAGS_CHANGED); @@ -38,7 +40,7 @@ public class MessageChangedEventTest extends TestCase { assertEquals(type, event.getMessageChangeType()); final MessageChangedListenerTest listener = new MessageChangedListenerTest(); event.dispatch(listener); - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } public static class MessageChangedListenerTest implements MessageChangedListener { diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java index 07d1cd0..f326417 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java @@ -19,18 +19,20 @@ package jakarta.mail.event; +import org.junit.jupiter.api.Test; + import jakarta.mail.Folder; import jakarta.mail.TestData; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class MessageCountEventTest extends TestCase { - public MessageCountEventTest(final String name) { - super(name); - } +public class MessageCountEventTest { + + @Test public void testEvent() { doEventTests(MessageCountEvent.ADDED); doEventTests(MessageCountEvent.REMOVED); @@ -48,7 +50,7 @@ public class MessageCountEventTest extends TestCase { assertEquals(type, event.getType()); final MessageCountListenerTest listener = new MessageCountListenerTest(); event.dispatch(listener); - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } public static class MessageCountListenerTest implements MessageCountListener { diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/StoreEventTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/StoreEventTest.java index 283c3bf..64fc864 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/StoreEventTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/StoreEventTest.java @@ -19,18 +19,20 @@ package jakarta.mail.event; +import org.junit.jupiter.api.Test; + import jakarta.mail.Store; import jakarta.mail.TestData; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class StoreEventTest extends TestCase { - public StoreEventTest(final String name) { - super(name); - } +public class StoreEventTest { + + @Test public void testEvent() { doEventTests(StoreEvent.ALERT); doEventTests(StoreEvent.NOTICE); @@ -50,7 +52,7 @@ public class StoreEventTest extends TestCase { assertEquals(type, event.getMessageType()); final StoreListenerTest listener = new StoreListenerTest(); event.dispatch(listener); - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } public static class StoreListenerTest implements StoreListener { private int state = 0; diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/TransportEventTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/TransportEventTest.java index f4caabb..86eddd4 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/TransportEventTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/event/TransportEventTest.java @@ -19,6 +19,8 @@ package jakarta.mail.event; +import org.junit.jupiter.api.Test; + import jakarta.mail.Address; import jakarta.mail.Folder; import jakarta.mail.Message; @@ -27,15 +29,15 @@ import jakarta.mail.Transport; import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class TransportEventTest extends TestCase { - public TransportEventTest(final String name) { - super(name); - } +public class TransportEventTest { + + @Test public void testEvent() throws AddressException { doEventTests(TransportEvent.MESSAGE_DELIVERED); doEventTests(TransportEvent.MESSAGE_PARTIALLY_DELIVERED); @@ -53,7 +55,7 @@ public class TransportEventTest extends TestCase { assertEquals(type, event.getType()); final TransportListenerTest listener = new TransportListenerTest(); event.dispatch(listener); - assertEquals("Unexpcted method dispatched", type, listener.getState()); + assertEquals(type, listener.getState(), "Unexpcted method dispatched"); } public static class TransportListenerTest implements TransportListener { private int state = 0; diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/AllInternetTests.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/AllInternetTests.java deleted file mode 100644 index da275bd..0000000 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/AllInternetTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package jakarta.mail.internet; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @version $Rev$ $Date$ - */ -public class AllInternetTests { - public static Test suite() { - final TestSuite suite = new TestSuite("Test for jakarta.mail.internet"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(ContentTypeTest.class)); - suite.addTest(new TestSuite(ParameterListTest.class)); - suite.addTest(new TestSuite(InternetAddressTest.class)); - //$JUnit-END$ - return suite; - } -} diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentDispositionTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentDispositionTest.java index b4c25f6..a8d8df1 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentDispositionTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentDispositionTest.java @@ -19,17 +19,19 @@ package jakarta.mail.internet; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @version $Rev$ $Date$ */ -public class ContentDispositionTest extends TestCase { +public class ContentDispositionTest { - public ContentDispositionTest(final String name) { - super(name); - } + @Test public void testContentDisposition() throws ParseException { ContentDisposition c; c = new ContentDisposition(); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentTypeTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentTypeTest.java index e3713c6..4fb4a34 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentTypeTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ContentTypeTest.java @@ -22,15 +22,20 @@ package jakarta.mail.internet; import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @version $Rev$ $Date$ */ -public class ContentTypeTest extends TestCase { - public ContentTypeTest(final String arg0) { - super(arg0); - } +public class ContentTypeTest { + + @Test public void testContentType() throws ParseException { final ContentType type = new ContentType(); assertNull(type.getPrimaryType()); @@ -38,6 +43,7 @@ public class ContentTypeTest extends TestCase { assertNull(type.getParameter("charset")); } + @Test public void testContentTypeStringStringParameterList() throws ParseException { ContentType type; final ParameterList list = new ParameterList(";charset=us-ascii"); @@ -51,6 +57,7 @@ public class ContentTypeTest extends TestCase { } + @Test public void testContentTypeString() throws ParseException { ContentType type; type = new ContentType("text/plain"); @@ -67,16 +74,28 @@ public class ContentTypeTest extends TestCase { assertEquals("us-ascii", parameterList.get("charset")); assertEquals("us-ascii", type.getParameter("charset")); } + + @Test public void testGetPrimaryType() throws ParseException { } + + @Test public void testGetSubType() throws ParseException { } + + @Test public void testGetBaseType() throws ParseException { } + + @Test public void testGetParameter() throws ParseException { } + + @Test public void testGetParameterList() throws ParseException { } + + @Test public void testSetPrimaryType() throws ParseException { final ContentType type = new ContentType("text/plain"); type.setPrimaryType("binary"); @@ -84,6 +103,8 @@ public class ContentTypeTest extends TestCase { assertEquals("plain", type.getSubType()); assertEquals("binary/plain", type.getBaseType()); } + + @Test public void testSetSubType() throws ParseException { final ContentType type = new ContentType("text/plain"); type.setSubType("html"); @@ -91,10 +112,16 @@ public class ContentTypeTest extends TestCase { assertEquals("html", type.getSubType()); assertEquals("text/html", type.getBaseType()); } + + @Test public void testSetParameter() throws ParseException { } + + @Test public void testSetParameterList() throws ParseException { } + + @Test public void testToString() throws ParseException { final ContentType type = new ContentType("text/plain"); assertEquals("text/plain", type.toString()); @@ -113,6 +140,8 @@ public class ContentTypeTest extends TestCase { assertTrue(parameters.contains("foo=bar")); assertTrue(parameters.contains("bar=\"[email protected]\"")); } + + @Test public void testMatchContentType() throws ParseException { final ContentType type = new ContentType("text/plain"); @@ -144,6 +173,8 @@ public class ContentTypeTest extends TestCase { assertFalse(type.match(test)); assertFalse(test.match(type)); } + + @Test public void testMatchString() throws ParseException { final ContentType type = new ContentType("text/plain"); assertTrue(type.match("text/plain")); @@ -158,7 +189,8 @@ public class ContentTypeTest extends TestCase { assertFalse(type.match("")); assertFalse(type.match("text/plain/yada")); } - + + @Test public void testSOAP12ContentType() throws ParseException { final ContentType type = new ContentType("multipart/related; type=\"application/xop+xml\"; start=\"<[email protected]>\"; start-info=\"application/soap+xml; action=\\\"urn:upload\\\"\"; boundary=\"----=_Part_10_5804917.1223557742343\""); assertEquals("multipart/related", type.getBaseType()); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/HeaderTokenizerTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/HeaderTokenizerTest.java index a4f1465..719cb5d 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/HeaderTokenizerTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/HeaderTokenizerTest.java @@ -19,12 +19,16 @@ package jakarta.mail.internet; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class HeaderTokenizerTest extends TestCase { +public class HeaderTokenizerTest { + @Test public void testTokenizer() throws ParseException { HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\" <[email protected]>, \n\r Geronimo User <[email protected]>"); @@ -66,6 +70,7 @@ public class HeaderTokenizerTest extends TestCase { doComment(false); } + @Test public void testErrors() throws ParseException { checkParseError("(Geronimo"); checkParseError("((Geronimo)"); @@ -74,6 +79,7 @@ public class HeaderTokenizerTest extends TestCase { } + @Test public void testQuotedLiteral() throws ParseException { checkTokenParse("\"\"", HeaderTokenizer.Token.QUOTEDSTRING, ""); checkTokenParse("\"\\\"\"", HeaderTokenizer.Token.QUOTEDSTRING, "\""); @@ -83,6 +89,7 @@ public class HeaderTokenizerTest extends TestCase { } + @Test public void testComment() throws ParseException { checkTokenParse("()", HeaderTokenizer.Token.COMMENT, ""); checkTokenParse("(())", HeaderTokenizer.Token.COMMENT, "()"); @@ -92,26 +99,30 @@ public class HeaderTokenizerTest extends TestCase { checkTokenParse("(Foo \r\n Bar)", HeaderTokenizer.Token.COMMENT, "Foo Bar"); checkTokenParse("(Foo \n Bar)", HeaderTokenizer.Token.COMMENT, "Foo \n Bar"); } - - public void testJavaMail15NextMethod() throws ParseException{ + + @Test + public void testJavaMail15NextMethod() throws ParseException { HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\\\" <[email protected]>, \n\r Geronimo User <[email protected]>"); validateToken(ht.next('>', false), HeaderTokenizer.Token.QUOTEDSTRING, "To: \"Geronimo List\" <[email protected]"); } - - public void testJavaMail15NextMethodEscapes() throws ParseException{ + + @Test + public void testJavaMail15NextMethodEscapes() throws ParseException { HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\\\" <[email protected]>, \n\r Geronimo User <[email protected]>"); validateToken(ht.next('<', true), HeaderTokenizer.Token.QUOTEDSTRING, "To: \"Geronimo List\\\" "); } - - public void testJavaMail15NextMethodEscapes2() throws ParseException{ + + @Test + public void testJavaMail15NextMethodEscapes2() throws ParseException { HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\" <geronimo-dev@apac\\he.org>, \n\r Geronimo User <[email protected]>"); ht.next(); ht.next(); ht.next(); validateToken(ht.next(',', false), HeaderTokenizer.Token.QUOTEDSTRING, "<[email protected]>"); } - - public void testJavaMail15NextMethodEscapes3() throws ParseException{ + + @Test + public void testJavaMail15NextMethodEscapes3() throws ParseException { HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\" <geronimo-dev@apac\\he.org>, \n\r Geronimo User <[email protected]>"); ht.next(); ht.next(); @@ -193,6 +204,7 @@ public class HeaderTokenizerTest extends TestCase { new TestCase(';', "a=b c; d=e f", "b c"), new TestCase(';', "a=\"b \\c\"; d=e f", "b \\c") }; + @Test public void testNext() throws Exception { final String value = "ggere, /tmp/mail.out, +mailbox, ~user/mailbox, ~/mailbox, /PN=x400.address/PRMD=ibmmail/ADMD=ibmx400/C=us/@mhs-mci.ebay, " + @@ -215,6 +227,7 @@ public class HeaderTokenizerTest extends TestCase { } } + @Test public void testNext2() throws Exception { // Create HeaderTokenizer object @@ -244,6 +257,7 @@ public class HeaderTokenizerTest extends TestCase { } } + @Test public void testNext3() throws Exception { // Create HeaderTokenizer object diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetAddressTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetAddressTest.java index 2d8d239..c280322 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetAddressTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetAddressTest.java @@ -25,14 +25,22 @@ import java.util.Properties; import jakarta.mail.Session; -import junit.framework.TestCase; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.Test; /** * @version $Rev$ $Date$ */ -public class InternetAddressTest extends TestCase { +public class InternetAddressTest { private InternetAddress address; + @Test public void testQuotedLiterals() throws Exception { parseHeaderTest("\"Foo\t\n\\\\\\\"\" <[email protected]>", true, "[email protected]", "Foo\t\n\\\"", "\"Foo\t\n\\\\\\\"\" <[email protected]>", false); parseHeaderTest("<\"@,:;<>.[]()\"@apache.org>", true, "\"@,:;<>.[]()\"@apache.org", null, "<\"@,:;<>.[]()\"@apache.org>", false); @@ -41,6 +49,7 @@ public class InternetAddressTest extends TestCase { parseHeaderErrorTest("\"Foo\r\" <[email protected]>", true); } + @Test public void testDomainLiterals() throws Exception { parseHeaderTest("<foo@[apache].org>", true, "foo@[apache].org", null, "<foo@[apache].org>", false); parseHeaderTest("<foo@[@()<>.,:;\"\\\\].org>", true, "foo@[@()<>.,:;\"\\\\].org", null, "<foo@[@()<>.,:;\"\\\\].org>", false); @@ -50,6 +59,7 @@ public class InternetAddressTest extends TestCase { parseHeaderErrorTest("<foo@[\r].org>", true); } + @Test public void testComments() throws Exception { parseHeaderTest("Foo Bar (Fred) <[email protected]>", true, "[email protected]", "Foo Bar (Fred)", "\"Foo Bar (Fred)\" <[email protected]>", false); parseHeaderTest("(Fred) [email protected]", true, "[email protected]", "Fred", "Fred <[email protected]>", false); @@ -59,6 +69,7 @@ public class InternetAddressTest extends TestCase { parseHeaderErrorTest("(Fred\r) [email protected]", true); } + @Test public void testParseHeader() throws Exception { parseHeaderTest("<@apache.org,@apache.net:[email protected]>", false, "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); parseHeaderTest("<@apache.org:[email protected]>", false, "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -82,6 +93,7 @@ public class InternetAddressTest extends TestCase { parseHeaderTest("apache.org", false, "apache.org", null, "apache.org", false); } + @Test public void testValidate() throws Exception { validateTest("@apache.org,@apache.net:[email protected]"); validateTest("@apache.org:[email protected]"); @@ -96,6 +108,7 @@ public class InternetAddressTest extends TestCase { validateTest("foo@[apache].[org]"); } + @Test public void testStrictParseHeader() throws Exception { parseHeaderTest("<@apache.org,@apache.net:[email protected]>", true, "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); parseHeaderTest("<@apache.org:[email protected]>", true, "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -119,6 +132,7 @@ public class InternetAddressTest extends TestCase { parseHeaderTest("apache.org", true, "apache.org", null, "apache.org", false); } + @Test public void testParse() throws Exception { parseTest("<@apache.org,@apache.net:[email protected]>", false, "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); parseTest("<@apache.org:[email protected]>", false, "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -142,6 +156,7 @@ public class InternetAddressTest extends TestCase { parseTest("apache.org", false, "apache.org", null, "apache.org", false); } + @Test public void testDefaultParse() throws Exception { parseDefaultTest("<@apache.org,@apache.net:[email protected]>", "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); parseDefaultTest("<@apache.org:[email protected]>", "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -165,6 +180,7 @@ public class InternetAddressTest extends TestCase { parseDefaultTest("apache.org", "apache.org", null, "apache.org", false); } + @Test public void testStrictParse() throws Exception { parseTest("<@apache.org,@apache.net:[email protected]>", true, "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); parseTest("<@apache.org:[email protected]>", true, "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -188,6 +204,7 @@ public class InternetAddressTest extends TestCase { parseTest("apache.org", true, "apache.org", null, "apache.org", false); } + @Test public void testConstructor() throws Exception { constructorTest("(Foo) (Bar) [email protected]", false, "[email protected]", "Foo", "Foo <[email protected]>", false); constructorTest("<@apache.org,@apache.net:[email protected]>", false, "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); @@ -211,6 +228,7 @@ public class InternetAddressTest extends TestCase { constructorTest("apache.org", false, "apache.org", null, "apache.org", false); } + @Test public void testDefaultConstructor() throws Exception { constructorDefaultTest("<@apache.org,@apache.net:[email protected]>", "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); constructorDefaultTest("<@apache.org:[email protected]>", "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -234,6 +252,7 @@ public class InternetAddressTest extends TestCase { constructorDefaultTest("apache.org", "apache.org", null, "apache.org", false); } + @Test public void testStrictConstructor() throws Exception { constructorTest("<@apache.org,@apache.net:[email protected]>", true, "@apache.org,@apache.net:[email protected]", null, "<@apache.org,@apache.net:[email protected]>", false); constructorTest("<@apache.org:[email protected]>", true, "@apache.org:[email protected]", null, "<@apache.org:[email protected]>", false); @@ -257,35 +276,37 @@ public class InternetAddressTest extends TestCase { constructorTest("apache.org", true, "apache.org", null, "apache.org", false); } + @Test public void testParseHeaderList() throws Exception { InternetAddress[] addresses = InternetAddress.parseHeader("[email protected],[email protected]", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = InternetAddress.parseHeader("Foo <[email protected]>,,Bar <[email protected]>", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", "Foo", "Foo <[email protected]>", false); validateAddress(addresses[1], "[email protected]", "Bar", "Bar <[email protected]>", false); addresses = InternetAddress.parseHeader("[email protected], [email protected]", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = InternetAddress.parseHeader("Foo <[email protected]>, Bar <[email protected]>", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", "Foo", "Foo <[email protected]>", false); validateAddress(addresses[1], "[email protected]", "Bar", "Bar <[email protected]>", false); addresses = InternetAddress.parseHeader("Foo <[email protected]>,(yada),Bar <[email protected]>", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", "Foo", "Foo <[email protected]>", false); validateAddress(addresses[1], "[email protected]", "Bar", "Bar <[email protected]>", false); } + @Test public void testParseHeaderErrors() throws Exception { parseHeaderErrorTest("[email protected] [email protected]", true); parseHeaderErrorTest("Foo [email protected]", true); @@ -296,6 +317,7 @@ public class InternetAddressTest extends TestCase { parseHeaderErrorTest("foo@[apache.org", true); } + @Test public void testValidateErrors() throws Exception { validateErrorTest("[email protected] [email protected]"); validateErrorTest("Foo [email protected]"); @@ -306,6 +328,7 @@ public class InternetAddressTest extends TestCase { validateErrorTest("foo@[apache.org"); } + @Test public void testGroup() throws Exception { parseHeaderTest("Foo:[email protected];", true, "Foo:[email protected];", null, "Foo:[email protected];", true); parseHeaderTest("Foo:[email protected],[email protected];", true, "Foo:[email protected],[email protected];", null, "Foo:[email protected],[email protected];", true); @@ -322,75 +345,77 @@ public class InternetAddressTest extends TestCase { parseHeaderErrorTest("Foo Bar:<[email protected],[email protected];", true); } + @Test public void testGetGroup() throws Exception { InternetAddress[] addresses = getGroup("Foo:[email protected];", true); - assertTrue("Expecting 1 address", addresses.length == 1); + assertTrue(addresses.length == 1, "Expecting 1 address"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:[email protected],[email protected];", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:<[email protected]>,[email protected];", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:<[email protected]>,,[email protected];", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:Foo <[email protected]>,[email protected];", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", "Foo", "Foo <[email protected]>", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:Foo <@apache.org:[email protected]>,[email protected];", true); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "@apache.org:[email protected]", "Foo", "Foo <@apache.org:[email protected]>", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:;", true); - assertTrue("Expecting 0 addresses", addresses.length == 0); + assertTrue(addresses.length == 0, "Expecting 0 addresses"); addresses = getGroup("Foo:[email protected];", false); - assertTrue("Expecting 1 address", addresses.length == 1); + assertTrue(addresses.length == 1, "Expecting 1 address"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:[email protected],[email protected];", false); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:<[email protected]>,[email protected];", false); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:<[email protected]>,,[email protected];", false); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", null, "[email protected]", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:Foo <[email protected]>,[email protected];", false); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "[email protected]", "Foo", "Foo <[email protected]>", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:Foo <@apache.org:[email protected]>,[email protected];", false); - assertTrue("Expecting 2 addresses", addresses.length == 2); + assertTrue(addresses.length == 2, "Expecting 2 addresses"); validateAddress(addresses[0], "@apache.org:[email protected]", "Foo", "Foo <@apache.org:[email protected]>", false); validateAddress(addresses[1], "[email protected]", null, "[email protected]", false); addresses = getGroup("Foo:;", false); - assertTrue("Expecting 0 addresses", addresses.length == 0); + assertTrue(addresses.length == 0, "Expecting 0 addresses"); } + @Test public void testLocalAddress() throws Exception { System.getProperties().remove("user.name"); @@ -442,6 +467,7 @@ public class InternetAddressTest extends TestCase { assertEquals(InternetAddress.getLocalAddress(session), new InternetAddress("[email protected]")); } + @Test public void testToStringStaticHelper() throws AddressException { final InternetAddress[] addresses = new InternetAddress[]{ new InternetAddress("test1ofaveryveryverylongemailaddressover71charwhichseemscrazyatfirstglance@example.com"), @@ -472,8 +498,8 @@ public class InternetAddressTest extends TestCase { } - @Override - protected void setUp() throws Exception { + @BeforeEach + public void setUp() throws Exception { address = new InternetAddress(); } @@ -563,14 +589,14 @@ public class InternetAddressTest extends TestCase { private void validateAddress(final InternetAddress a, final String address, final String personal, final String toString, final boolean group) { - assertEquals("Invalid address:", a.getAddress(), address); + assertEquals(a.getAddress(), address, "Invalid address:"); if (personal == null) { - assertNull("Personal must be null", a.getPersonal()); + assertNull(a.getPersonal(), "Personal must be null"); } else { - assertEquals("Invalid Personal:", a.getPersonal(), personal); + assertEquals(a.getPersonal(), personal, "Invalid Personal:"); } - assertEquals("Invalid string value:", a.toString(), toString); - assertTrue("Incorrect group value:", group == a.isGroup()); + assertEquals(a.toString(), toString, "Invalid string value:"); + assertTrue(group == a.isGroup(), "Incorrect group value:"); } } diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetHeadersTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetHeadersTest.java index 443dee7..653bee6 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetHeadersTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/InternetHeadersTest.java @@ -23,14 +23,21 @@ import java.io.ByteArrayInputStream; import jakarta.mail.MessagingException; -import junit.framework.TestCase; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.Test; /** * @version $Rev$ $Date$ */ -public class InternetHeadersTest extends TestCase { +public class InternetHeadersTest { private InternetHeaders headers; + @Test public void testLoadSingleHeader() throws MessagingException { final String stream = "content-type: text/plain\r\n\r\n"; headers.load(new ByteArrayInputStream(stream.getBytes())); @@ -39,26 +46,30 @@ public class InternetHeadersTest extends TestCase { assertEquals("text/plain", header[0]); } - @Override - protected void setUp() throws Exception { + @BeforeEach + public void setUp() throws Exception { headers = new InternetHeaders(); } + @Test public void testReturnPathHeaderIgnored() throws MessagingException { headers.addHeader("Return-Path", "first"); headers.addHeader("Return-Path", "second"); } + @Test public void testReceivedHeaderIgnored() throws MessagingException { headers.addHeader("Received", "first"); headers.addHeader("Received", "second"); } + @Test public void testOtherHeaderNotDuplicated() throws MessagingException { headers.addHeader("Other", "first"); } + @Test public void testActuallyDuplicatedHeader() throws MessagingException { headers.addHeader("Other", "first"); try { diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MailDateFormatTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MailDateFormatTest.java index 71eebcb..1f871de 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MailDateFormatTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MailDateFormatTest.java @@ -25,12 +25,15 @@ import java.util.Date; import java.util.Locale; import java.util.SimpleTimeZone; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class MailDateFormatTest extends TestCase { +public class MailDateFormatTest { + @Test public void testMailDateFormat() throws ParseException { final MailDateFormat mdf = new MailDateFormat(); Date date = mdf.parse("Wed, 27 Aug 2003 13:43:38 +0100 (BST)"); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeBodyPartTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeBodyPartTest.java index 91a861b..5a114f8 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeBodyPartTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeBodyPartTest.java @@ -21,9 +21,15 @@ package jakarta.mail.internet; import jakarta.mail.MessagingException; import jakarta.mail.Part; -import junit.framework.TestCase; import jakarta.activation.DataHandler; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -34,11 +40,12 @@ import java.io.UnsupportedEncodingException; /** * @version $Rev$ $Date$ */ -public class MimeBodyPartTest extends TestCase { +public class MimeBodyPartTest { File basedir = new File(System.getProperty("basedir", ".")); File testInput = new File(basedir, "src/test/resources/test.dat"); + @Test public void testGetSize() throws MessagingException { MimeBodyPart part = new MimeBodyPart(); assertEquals(part.getSize(), -1); @@ -47,6 +54,7 @@ public class MimeBodyPartTest extends TestCase { assertEquals(part.getSize(), 3); } + @Test public void testGetLineCount() throws MessagingException { MimeBodyPart part = new MimeBodyPart(); assertEquals(part.getLineCount(), -1); @@ -56,6 +64,7 @@ public class MimeBodyPartTest extends TestCase { } + @Test public void testGetContentType() throws MessagingException { MimeBodyPart part = new MimeBodyPart(); assertEquals(part.getContentType(), "text/plain"); @@ -69,6 +78,7 @@ public class MimeBodyPartTest extends TestCase { } + @Test public void testIsMimeType() throws MessagingException { final MimeBodyPart part = new MimeBodyPart(); assertTrue(part.isMimeType("text/plain")); @@ -80,6 +90,7 @@ public class MimeBodyPartTest extends TestCase { } + @Test public void testGetDisposition() throws MessagingException { final MimeBodyPart part = new MimeBodyPart(); assertNull(part.getDisposition()); @@ -87,7 +98,8 @@ public class MimeBodyPartTest extends TestCase { part.setDisposition("inline"); assertEquals(part.getDisposition(), "inline"); } - + + @Test public void testJavaMail15AttachmentDisposition() throws MessagingException, IOException { final MimeBodyPart part = new MimeBodyPart(); assertNull(part.getDisposition()); @@ -95,7 +107,8 @@ public class MimeBodyPartTest extends TestCase { part.attachFile(testInput); assertEquals(Part.ATTACHMENT, part.getDisposition()); } - + + @Test public void testJavaMail15EncodingAware() throws MessagingException, IOException { final File testInput = new File(basedir, "src/test/resources/test.dat"); final MimeBodyPart part = new MimeBodyPart(); @@ -112,6 +125,7 @@ public class MimeBodyPartTest extends TestCase { } + @Test public void testSetDescription() throws MessagingException, UnsupportedEncodingException { final MimeBodyPart part = new MimeBodyPart(); @@ -132,6 +146,7 @@ public class MimeBodyPartTest extends TestCase { assertNull(part.getDescription()); } + @Test public void testSetFileName() throws Exception { final MimeBodyPart part = new MimeBodyPart(); part.setFileName("test.dat"); @@ -155,6 +170,7 @@ public class MimeBodyPartTest extends TestCase { } + @Test public void testAttachments() throws Exception { MimeBodyPart part = new MimeBodyPart(); @@ -226,6 +242,7 @@ public class MimeBodyPartTest extends TestCase { compareFileData(testData, tempData); } + @Test public void testSetTextSubtype() throws Exception { final MimeBodyPart part = new MimeBodyPart(); part.setText("<html>", "utf-8", "html"); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMessageTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMessageTest.java index 5f1ee48..5eba07a 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMessageTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMessageTest.java @@ -29,21 +29,31 @@ import java.util.Properties; import jakarta.activation.CommandMap; import jakarta.activation.MailcapCommandMap; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.mail.Address; import jakarta.mail.Message; import jakarta.mail.MessagingException; import jakarta.mail.Session; import jakarta.mail.*; -import junit.framework.TestCase; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @version $Rev$ $Date$ */ -public class MimeMessageTest extends TestCase { +public class MimeMessageTest { private CommandMap defaultMap; private Session session; + @Test public void testNoDuplicateTo() throws MessagingException, IOException { final InternetAddress[] addresses = new InternetAddress[]{ new InternetAddress("test1ofaveryveryverylongemailaddressover71charwhichseemscrazyatfirstglance@example.com"), @@ -58,10 +68,10 @@ public class MimeMessageTest extends TestCase { msg.writeTo(out); final String textMessage = new String(out.toByteArray()); - assertTrue(textMessage, textMessage.contains( + assertTrue(textMessage.contains( "To: \r\n" + " test1ofaveryveryverylongemailaddressover71charwhichseemscrazyatfirstglance@example.com,\r\n" + - " [email protected], [email protected]")); + " [email protected], [email protected]"), textMessage); } { @@ -73,6 +83,7 @@ public class MimeMessageTest extends TestCase { } } + @Test public void testWriteTo() throws MessagingException, IOException { final MimeMessage msg = new MimeMessage(session); msg.setSender(new InternetAddress("foo")); @@ -108,6 +119,7 @@ public class MimeMessageTest extends TestCase { } + @Test public void testFrom() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -150,6 +162,7 @@ public class MimeMessageTest extends TestCase { } + @Test public void testSender() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -167,7 +180,8 @@ public class MimeMessageTest extends TestCase { msg.setSender(null); assertNull(msg.getSender()); } - + + @Test public void testJavaMail15GetSession() throws MessagingException { final MimeMessage msg = new MimeMessage(session); assertTrue(session == msg.getSession()); @@ -175,7 +189,8 @@ public class MimeMessageTest extends TestCase { final MimeMessage msg2 = new MimeMessage((Session) null); assertTrue(null == msg2.getSession()); } - + + @Test public void testJava15From() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -197,6 +212,7 @@ public class MimeMessageTest extends TestCase { assertEquals(from[0], new InternetAddress("[email protected]")); } + @Test public void testGetAllRecipients() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -252,6 +268,7 @@ public class MimeMessageTest extends TestCase { assertEquals(recipients[2], group); } + @Test public void testGetRecipients() throws MessagingException { doRecipientTest(Message.RecipientType.TO); doRecipientTest(Message.RecipientType.CC); @@ -362,6 +379,7 @@ public class MimeMessageTest extends TestCase { assertEquals(recipients[1], user); } + @Test public void testReplyTo() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -386,7 +404,8 @@ public class MimeMessageTest extends TestCase { recipients = msg.getReplyTo(); assertNull(recipients); } - + + @Test public void testJavaMail15Reply() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("[email protected]"); @@ -399,7 +418,8 @@ public class MimeMessageTest extends TestCase { assertTrue(msg.isSet(Flags.Flag.ANSWERED)); assertEquals(new InternetAddress("[email protected]"), replyMsg.getRecipients(Message.RecipientType.TO)[0]); } - + + @Test public void testJavaMail15Reply2() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("[email protected]"); @@ -414,6 +434,7 @@ public class MimeMessageTest extends TestCase { } + @Test public void testSetSubject() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -434,6 +455,7 @@ public class MimeMessageTest extends TestCase { } + @Test public void testSetDescription() throws MessagingException { final MimeMessage msg = new MimeMessage(session); @@ -454,6 +476,7 @@ public class MimeMessageTest extends TestCase { } + @Test public void testGetContentType() throws MessagingException { final MimeMessage msg = new MimeMessage(session); assertEquals(msg.getContentType(), "text/plain"); @@ -463,6 +486,7 @@ public class MimeMessageTest extends TestCase { } + @Test public void testSetText() throws MessagingException { MimeMessage msg = new MimeMessage(session); @@ -486,6 +510,7 @@ public class MimeMessageTest extends TestCase { assertEquals(type.getParameter("charset"), "UTF-8"); } + @Test public void testAddDateinUpdateHeaders() throws MessagingException, ParseException { final MimeMessage msg = new MimeMessage(session); msg.updateHeaders(); @@ -502,8 +527,8 @@ public class MimeMessageTest extends TestCase { } - @Override - protected void setUp() throws Exception { + @BeforeEach + public void setUp() throws Exception { defaultMap = CommandMap.getDefaultCommandMap(); final MailcapCommandMap myMap = new MailcapCommandMap(); myMap.addMailcap("text/plain;; x-java-content-handler=" + MimeMultipartTest.DummyTextHandler.class.getName()); @@ -516,8 +541,8 @@ public class MimeMessageTest extends TestCase { session = Session.getInstance(props); } - @Override - protected void tearDown() throws Exception { + @AfterEach + public void tearDown() throws Exception { CommandMap.setDefaultCommandMap(defaultMap); } } diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMultipartTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMultipartTest.java index f6a01eb..06e1046 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMultipartTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeMultipartTest.java @@ -31,19 +31,26 @@ import java.io.OutputStream; import java.util.Properties; import jakarta.activation.*; +import org.junit.jupiter.api.Test; + import jakarta.mail.BodyPart; import jakarta.mail.Message; import jakarta.mail.MessagingException; import jakarta.mail.Session; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class MimeMultipartTest extends TestCase { +public class MimeMultipartTest { private CommandMap defaultMap; + @Test public void testWriteTo() throws MessagingException, IOException, Exception { writeToSetUp(); @@ -60,6 +67,7 @@ public class MimeMultipartTest extends TestCase { writeToTearDown(); } + @Test public void testPreamble() throws MessagingException, IOException { final Properties props = new Properties(); final Session session = Session.getDefaultInstance(props); @@ -93,6 +101,7 @@ public class MimeMultipartTest extends TestCase { assertEquals("This is a preamble\r\n", ((MimeMultipart)newMessage.getContent()).getPreamble()); } + @Test public void testMIMEWriting() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final File testInput = new File(basedir, "src/test/resources/wmtom.bin"); @@ -111,7 +120,8 @@ public class MimeMultipartTest extends TestCase { assertNotNull(object1); assertEquals(multiPart.getCount(), 2); } - + + @Test public void testJavaMail15NewConstrucor() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final File testInput = new File(basedir, "src/test/resources/wmtom.bin"); @@ -128,7 +138,8 @@ public class MimeMultipartTest extends TestCase { assertEquals(multiPart.getCount(), 2); assertTrue(multiPart.getContentType().startsWith("multipart/mixed")); } - + + @Test public void testJavaMail15NewConstrucor2() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final File testInput = new File(basedir, "src/test/resources/wmtom.bin"); @@ -145,7 +156,8 @@ public class MimeMultipartTest extends TestCase { assertEquals(multiPart.getCount(), 2); assertTrue(multiPart.getContentType().startsWith("multipart/alternative")); } - + + @Test public void testJavaMail15CachedContent() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final InputStream source = new FileInputStream(new File(basedir, "src/test/resources/multipart_msg_normal.eml")); @@ -163,7 +175,8 @@ public class MimeMultipartTest extends TestCase { message.setDataHandler(new DataHandler("","text/plain")); assertNull(message.cachedContent); } - + + @Test public void testJavaMail15MultipartParsingNormal() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); @@ -175,7 +188,8 @@ public class MimeMultipartTest extends TestCase { } } - + + @Test public void testJavaMail15MultipartParsingEmpty() throws IOException, MessagingException { /* @@ -212,7 +226,8 @@ public class MimeMultipartTest extends TestCase { setMultipartSystemPropsToDefault(); } } - + + @Test public void testJavaMail1MultipartParsingMissingBoundaryParameter() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); @@ -223,7 +238,8 @@ public class MimeMultipartTest extends TestCase { setMultipartSystemPropsToDefault(); } } - + + @Test public void testJavaMail1MultipartParsingMissingEndBoundary() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); @@ -235,7 +251,8 @@ public class MimeMultipartTest extends TestCase { setMultipartSystemPropsToDefault(); } } - + + @Test public void testJavaMail15MultipartParsingWrongBoundary() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeTest.java index a78baa7..322a124 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeTest.java @@ -30,12 +30,15 @@ import jakarta.activation.DataHandler; import jakarta.activation.DataSource; import jakarta.mail.Session; -import junit.framework.TestCase; - import org.apache.geronimo.mail.util.Base64; -public class MimeTest extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; + +public class MimeTest { + @Test public void testWriteRead() throws Exception { System.setProperty("mail.mime.decodefilename", "true"); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeUtilityTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeUtilityTest.java index e5f5eec..cfaaaf5 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeUtilityTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/MimeUtilityTest.java @@ -26,12 +26,15 @@ import java.io.OutputStream; import jakarta.mail.util.ByteArrayDataSource; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class MimeUtilityTest extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class MimeUtilityTest { private final byte[] encodeBytes = new byte[] { 32, 104, -61, -87, 33, 32, -61, -96, -61, -88, -61, -76, 117, 32, 33, 33, 33 }; + @Test public void testEncodeDecode() throws Exception { final byte [] data = new byte[256]; @@ -59,6 +62,7 @@ public class MimeUtilityTest extends TestCase { } + @Test public void testFoldUnfold() throws Exception { doFoldTest(0, "This is a short string", "This is a short string"); doFoldTest(0, "The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.", @@ -104,6 +108,7 @@ public class MimeUtilityTest extends TestCase { } + @Test public void testEncodeWord() throws Exception { assertEquals("abc", MimeUtility.encodeWord("abc")); @@ -123,6 +128,7 @@ public class MimeUtilityTest extends TestCase { } + @Test public void testEncodeText() throws Exception { assertEquals("abc", MimeUtility.encodeWord("abc")); @@ -151,6 +157,7 @@ public class MimeUtilityTest extends TestCase { } + @Test public void testGetEncoding() throws Exception { ByteArrayDataSource source = new ByteArrayDataSource(new byte[] { 'a', 'b', 'c'}, "text/plain"); @@ -179,6 +186,7 @@ public class MimeUtilityTest extends TestCase { } + @Test public void testQuote() throws Exception { assertEquals("abc", MimeUtility.quote("abc", "&*%")); assertEquals("\"abc&\"", MimeUtility.quote("abc&", "&*%")); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/NewsAddressTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/NewsAddressTest.java index ad4c80f..5c1d665 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/NewsAddressTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/NewsAddressTest.java @@ -19,12 +19,15 @@ package jakarta.mail.internet; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class NewsAddressTest extends TestCase { +public class NewsAddressTest { + @Test public void testNewsAddress() throws AddressException { final NewsAddress na = new NewsAddress("geronimo-dev", "news.apache.org"); assertEquals("geronimo-dev", na.getNewsgroup()); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ParameterListTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ParameterListTest.java index cc8cefb..0bb4681 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ParameterListTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/ParameterListTest.java @@ -19,15 +19,16 @@ package jakarta.mail.internet; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class ParameterListTest extends TestCase { - public ParameterListTest(final String arg0) { - super(arg0); - } +public class ParameterListTest { + + @Test public void testParameters() throws ParseException { final ParameterList list = new ParameterList(";thing=value;thong=vulue;thung=git"); @@ -36,12 +37,14 @@ public class ParameterListTest extends TestCase { assertEquals("git", list.get("thung")); } + @Test public void testQuotedParameter() throws ParseException { final ParameterList list = new ParameterList(";foo=one;bar=\"two\""); assertEquals("one", list.get("foo")); assertEquals("two", list.get("bar")); } - + + @Test public void testQuotedParameterSet() throws ParseException { final ParameterList list = new ParameterList(); list.set("foo", "one"); @@ -49,12 +52,14 @@ public class ParameterListTest extends TestCase { assertEquals("one", list.get("foo")); assertEquals("\"two\"", list.get("bar")); } - + + @Test public void testMultisegmentParameter() throws ParseException { final ParameterList list = new ParameterList(";foo*0=one;foo*1=\"two\""); assertEquals("onetwo", list.get("foo")); } + @Test public void testMultisegmentParameterSet() throws ParseException { final ParameterList list = new ParameterList(); list.set("foo*0", "one"); @@ -62,7 +67,8 @@ public class ParameterListTest extends TestCase { list.combineSegments(); assertEquals("one\"two\"", list.get("foo")); } - + + @Test public void testMultisegmentParameterMoreSet() throws ParseException { final ParameterList list = new ParameterList(); list.set("foo*0", "one"); @@ -78,7 +84,8 @@ public class ParameterListTest extends TestCase { assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } - + + @Test public void testMultisegmentParameterMore() throws ParseException { final ParameterList list = new ParameterList(";foo*0=one;foo*1=two;foo*2=three;bar=four;test2*0=seven;test*1=six;test*0=five"); assertEquals("onetwothree", list.get("foo")); @@ -86,7 +93,8 @@ public class ParameterListTest extends TestCase { assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } - + + @Test public void testMultisegmentParameterEncodedMore() throws ParseException { final String value = " '*% abc \u0081\u0082\r\n\t"; final String encodedTest = "UTF-8''%20%27%2A%25%20abc%20%C2%81%C2%82%0D%0A%09"; @@ -96,7 +104,8 @@ public class ParameterListTest extends TestCase { assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } - + + @Test public void testMultisegmentParameterEncodedMoreFail() throws ParseException { //final String value = " '*% abc \u0081\u0082\r\n\t"; final String encodedTest = "UTF-8''%20%27%2A%25%20abc%20%C2%81%C2%82%0D%0A%09"; @@ -106,7 +115,8 @@ public class ParameterListTest extends TestCase { assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } - + + @Test public void testMultisegmentParameterMoreMixedEncodedSet() throws ParseException { final String value = " '*% abc \u0081\u0082\r\n\t"; @@ -133,7 +143,8 @@ public class ParameterListTest extends TestCase { final ParameterList list = new ParameterList(""); assertEquals(0, list.size()); } - + + @Test public void testEncodeDecode() throws Exception { //since JavaMail 1.5 encodeparameters/decodeparameters are enabled by default diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/PreencodedMimeBodyPartTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/PreencodedMimeBodyPartTest.java index 1803c08..457f02b 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/PreencodedMimeBodyPartTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/internet/PreencodedMimeBodyPartTest.java @@ -23,19 +23,23 @@ import java.io.ByteArrayOutputStream; import jakarta.mail.MessagingException; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class PreencodedMimeBodyPartTest extends TestCase { +public class PreencodedMimeBodyPartTest { - public void testEncoding() throws Exception { + @Test + public void testEncoding() throws Exception { final PreencodedMimeBodyPart part = new PreencodedMimeBodyPart("base64"); assertEquals("base64", part.getEncoding()); } - public void testUpdateHeaders() throws Exception { + @Test + public void testUpdateHeaders() throws Exception { final TestBodyPart part = new TestBodyPart("base64"); part.updateHeaders(); @@ -43,7 +47,8 @@ public class PreencodedMimeBodyPartTest extends TestCase { assertEquals("base64", part.getHeader("Content-Transfer-Encoding", null)); } - public void testWriteTo() throws Exception { + @Test + public void testWriteTo() throws Exception { final PreencodedMimeBodyPart part = new PreencodedMimeBodyPart("binary"); final byte[] content = new byte[] { 81, 82, 83, 84, 85, 86 }; diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/ByteArrayDataSourceTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/ByteArrayDataSourceTest.java index bd16715..2617e70 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/ByteArrayDataSourceTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/ByteArrayDataSourceTest.java @@ -23,16 +23,17 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class ByteArrayDataSourceTest extends TestCase { - public ByteArrayDataSourceTest(final String arg0) { - super(arg0); - } +public class ByteArrayDataSourceTest { + @Test public void testByteArray() throws Exception { doDataSourceTest(new ByteArrayDataSource("0123456789", "text/plain"), "text/plain"); doDataSourceTest(new ByteArrayDataSource("0123456789".getBytes(), "text/xml"), "text/xml"); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedByteArrayInputStreamTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedByteArrayInputStreamTest.java index 2aa7271..1bd9694 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedByteArrayInputStreamTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedByteArrayInputStreamTest.java @@ -19,21 +19,21 @@ package jakarta.mail.util; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @version $Rev$ $Date$ */ -public class SharedByteArrayInputStreamTest extends TestCase { +public class SharedByteArrayInputStreamTest { private final String testString = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; private final byte[] testData = testString.getBytes(); - public SharedByteArrayInputStreamTest(final String arg0) { - super(arg0); - } + @Test public void testInput() throws Exception { final SharedByteArrayInputStream in = new SharedByteArrayInputStream(testData); @@ -62,6 +62,7 @@ public class SharedByteArrayInputStreamTest extends TestCase { } + @Test public void testNewStream() throws Exception { final SharedByteArrayInputStream in = new SharedByteArrayInputStream(testData); diff --git a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedFileInputStreamTest.java b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedFileInputStreamTest.java index fa0fe34..84dd5c7 100644 --- a/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedFileInputStreamTest.java +++ b/geronimo-mail_2.1_spec/src/test/java/jakarta/mail/util/SharedFileInputStreamTest.java @@ -22,20 +22,22 @@ package jakarta.mail.util; import java.io.File; import java.io.IOException; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @version $Rev$ $Date$ */ -public class SharedFileInputStreamTest extends TestCase { +public class SharedFileInputStreamTest { File basedir = new File(System.getProperty("basedir", ".")); File testInput = new File(basedir, "src/test/resources/test.dat"); - public SharedFileInputStreamTest(final String arg0) { - super(arg0); - } + @Test public void testInput() throws Exception { doTestInput(new SharedFileInputStream(testInput)); doTestInput(new SharedFileInputStream(testInput.getPath())); @@ -73,6 +75,7 @@ public class SharedFileInputStreamTest extends TestCase { } + @Test public void testNewStream() throws Exception { final SharedFileInputStream in = new SharedFileInputStream(testInput); @@ -108,6 +111,7 @@ public class SharedFileInputStreamTest extends TestCase { } + @Test public void testMark() throws Exception { doMarkTest(new SharedFileInputStream(testInput, 10)); diff --git a/pom.xml b/pom.xml index ca16811..9f724f3 100644 --- a/pom.xml +++ b/pom.xml @@ -25,9 +25,10 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.apache.geronimo.genesis</groupId> - <artifactId>genesis-java8-flava</artifactId> - <version>2.4</version> + <groupId>org.apache</groupId> + <artifactId>apache</artifactId> + <version>39</version> + <relativePath><!--Resolve on repository--></relativePath> </parent> <groupId>org.apache.geronimo</groupId> @@ -75,6 +76,18 @@ </mailingList> </mailingLists> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.5.6</version> + </plugin> + </plugins> + </pluginManagement> + </build> + <modules> <module>geronimo-mail_2.1_spec</module> <module>geronimo-mail_2.1_impl</module>