You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/07/15 17:11:38 UTC
[camel] 09/14: [CAMEL-11807] Upgrade camel-mail to junit5
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e099d0b8820655ef4aa49c63c96a4baa351502bf
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Jul 15 15:47:10 2020 +0200
[CAMEL-11807] Upgrade camel-mail to junit5
---
components/camel-mail/pom.xml | 8 +-
.../mail/AdditionalMailPropertiesTest.java | 6 +-
.../camel/component/mail/AuthenticatorTest.java | 8 +-
.../mail/DetermineContentTypeIssueTest.java | 6 +-
.../camel/component/mail/FromFileSendMailTest.java | 6 +-
.../component/mail/InvalidConfigurationTest.java | 6 +-
.../mail/MailAttachmentDuplicateNamesTest.java | 14 +-
.../mail/MailAttachmentRedeliveryTest.java | 16 +-
.../camel/component/mail/MailAttachmentTest.java | 16 +-
.../mail/MailAttachmentsUmlautIssueTest.java | 20 +-
.../component/mail/MailBatchConsumerTest.java | 11 +-
.../mail/MailBindingAttachmentFileTest.java | 16 +-
.../component/mail/MailCollectionHeaderTest.java | 8 +-
.../component/mail/MailCommitOnCompletionTest.java | 10 +-
.../mail/MailComponentRecipientSetTest.java | 6 +-
.../camel/component/mail/MailComponentTest.java | 298 +++++++++++----------
.../mail/MailConsumerAuthenticatorTest.java | 8 +-
.../mail/MailConsumerIdleMessageTest.java | 6 +-
.../mail/MailConsumerUnsupportedCharsetTest.java | 8 +-
.../mail/MailContentTypeResolverTest.java | 14 +-
.../camel/component/mail/MailContentTypeTest.java | 7 +-
.../camel/component/mail/MailConvertersTest.java | 18 +-
.../camel/component/mail/MailCopyToTest.java | 10 +-
.../component/mail/MailCustomContentTypeTest.java | 7 +-
.../component/mail/MailCustomMailSenderTest.java | 8 +-
.../mail/MailDefaultDelayForMailConsumeTest.java | 8 +-
.../camel/component/mail/MailDisconnectTest.java | 4 +-
.../mail/MailDoNotDeleteIfProcessFailsTest.java | 10 +-
.../camel/component/mail/MailEndpointTest.java | 8 +-
.../camel/component/mail/MailEndpointTlsTest.java | 32 +--
.../camel/component/mail/MailFetchSizeTest.java | 10 +-
.../component/mail/MailFetchSizeZeroTest.java | 10 +-
...aderOverrulePreConfigurationRecipientsTest.java | 4 +-
.../component/mail/MailHtmlAttachmentTest.java | 18 +-
...IdempotentRepositoryDuplicateNotRemoveTest.java | 4 +-
.../MailIdempotentRepositoryDuplicateTest.java | 10 +-
.../mail/MailIdempotentRepositoryTest.java | 10 +-
.../component/mail/MailMaxMessagesPerPollTest.java | 8 +-
.../camel/component/mail/MailMessageTest.java | 18 +-
.../component/mail/MailMimeDecodeHeadersTest.java | 4 +-
.../camel/component/mail/MailMoveToTest.java | 33 +--
.../component/mail/MailMultipleRecipientsTest.java | 4 +-
.../MailMultipleRecipientsUsingHeadersTest.java | 6 +-
.../mail/MailNameAndEmailInRecipientTest.java | 4 +-
.../camel/component/mail/MailNoRecipientsTest.java | 8 +-
.../component/mail/MailPollEnrichNoMailTest.java | 8 +-
.../camel/component/mail/MailPollEnrichTest.java | 10 +-
.../component/mail/MailPostProcessActionTest.java | 10 +-
.../mail/MailProcessOnlyUnseenMessagesTest.java | 8 +-
.../component/mail/MailProducerConcurrentTest.java | 10 +-
.../camel/component/mail/MailProducerTest.java | 11 +-
.../mail/MailProducerUnsupportedCharsetTest.java | 7 +-
.../mail/MailRecipientsPipeIssueTest.java | 6 +-
.../camel/component/mail/MailRecipientsTest.java | 7 +-
.../camel/component/mail/MailReplyToTest.java | 6 +-
.../apache/camel/component/mail/MailRouteTest.java | 17 +-
.../component/mail/MailSearchTermNotSpamTest.java | 3 +-
.../camel/component/mail/MailSearchTermTest.java | 9 +-
.../MailSearchTermUriConfigLast24HoursTest.java | 10 +-
.../mail/MailSearchTermUriConfigTest.java | 10 +-
.../mail/MailShutdownCompleteAllTasksTest.java | 12 +-
.../MailShutdownCompleteCurrentTaskOnlyTest.java | 12 +-
.../camel/component/mail/MailSortTermTest.java | 10 +-
.../component/mail/MailSortTermThreeTest.java | 10 +-
.../camel/component/mail/MailSortTermTwoTest.java | 10 +-
.../camel/component/mail/MailSorterTest.java | 5 +-
.../component/mail/MailSplitAttachmentsTest.java | 13 +-
.../camel/component/mail/MailSubjectTest.java | 8 +-
.../mail/MailToMultipleEndpointsTest.java | 6 +-
.../component/mail/MailUsernameWithAtSignTest.java | 4 +-
.../component/mail/MailUsingCustomSessionTest.java | 13 +-
.../camel/component/mail/MailUsingHeadersTest.java | 11 +-
.../component/mail/MailUsingOwnComponentTest.java | 6 +-
.../component/mail/MimeMessageConsumeTest.java | 13 +-
.../mail/MimeMultipartAlternativeTest.java | 18 +-
...imeMultipartAlternativeWithContentTypeTest.java | 13 +-
...MultipartAlternativeWithLongerFilenameTest.java | 16 +-
.../mail/MultipleDestinationConsumeTest.java | 20 +-
.../mail/NestedMimeMessageConsumeTest.java | 11 +-
.../camel/component/mail/RawMailMessageTest.java | 17 +-
.../component/mail/SearchTermBuilderTest.java | 21 +-
.../mail/SpringMailSplitAttachmentsTest.java | 13 +-
.../SslContextParametersMailRouteTest.java | 11 +-
.../multipart/MimeMultipartDataFormatTest.java | 19 +-
84 files changed, 687 insertions(+), 491 deletions(-)
diff --git a/components/camel-mail/pom.xml b/components/camel-mail/pom.xml
index 7a9a73b..7f5f25e 100644
--- a/components/camel-mail/pom.xml
+++ b/components/camel-mail/pom.xml
@@ -62,7 +62,7 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -78,8 +78,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -89,7 +89,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
+ <artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/AdditionalMailPropertiesTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/AdditionalMailPropertiesTest.java
index 66df506..4e3da91 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/AdditionalMailPropertiesTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/AdditionalMailPropertiesTest.java
@@ -20,10 +20,12 @@ import java.util.Properties;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test allowing end users to set additional mail.xxx properties.
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/AuthenticatorTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/AuthenticatorTest.java
index 31dfbeb..04a003d 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/AuthenticatorTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/AuthenticatorTest.java
@@ -31,10 +31,12 @@ import javax.mail.internet.MimeMultipart;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class AuthenticatorTest extends CamelTestSupport {
/**
@@ -63,7 +65,7 @@ public class AuthenticatorTest extends CamelTestSupport {
Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
String text = exchange.getIn().getBody(String.class);
- assertEquals("mail body", body, text);
+ assertEquals(body, text, "mail body");
return body;
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/DetermineContentTypeIssueTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/DetermineContentTypeIssueTest.java
index 7e7634f..d836d4f 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/DetermineContentTypeIssueTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/DetermineContentTypeIssueTest.java
@@ -17,8 +17,10 @@
package org.apache.camel.component.mail;
import org.apache.camel.Exchange;
-import org.apache.camel.test.junit4.ExchangeTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/FromFileSendMailTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/FromFileSendMailTest.java
index 97d67f5..c243adc 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/FromFileSendMailTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/FromFileSendMailTest.java
@@ -20,10 +20,12 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class FromFileSendMailTest extends CamelTestSupport {
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
index bd7b643..88b2901 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
@@ -18,8 +18,10 @@ package org.apache.camel.component.mail;
import org.apache.camel.Endpoint;
import org.apache.camel.PollingConsumer;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit test for various invalid configurations etc.
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java
index b25e5d2..9eb6f15 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java
@@ -27,10 +27,14 @@ import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for Camel attachments and Mail attachments.
*/
@@ -72,16 +76,16 @@ public class MailAttachmentDuplicateNamesTest extends CamelTestSupport {
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should have attachments", attachments);
+ assertNotNull(attachments, "Should have attachments");
assertEquals(1, attachments.size());
DataHandler handler = out.getIn(AttachmentMessage.class).getAttachment("logo.jpeg");
- assertNotNull("The logo should be there", handler);
+ assertNotNull(handler, "The logo should be there");
// content type should match
boolean match1 = "image/jpeg; name=logo.jpeg".equals(handler.getContentType());
boolean match2 = "application/octet-stream; name=logo.jpeg".equals(handler.getContentType());
- assertTrue("Should match 1 or 2", match1 || match2);
+ assertTrue(match1 || match2, "Should match 1 or 2");
producer.stop();
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentRedeliveryTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentRedeliveryTest.java
index 4fa17c8..ab52671 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentRedeliveryTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentRedeliveryTest.java
@@ -30,10 +30,14 @@ import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for Camel attachments and Mail attachments.
*/
@@ -72,18 +76,18 @@ public class MailAttachmentRedeliveryTest extends CamelTestSupport {
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should have attachments", attachments);
+ assertNotNull(attachments, "Should have attachments");
assertEquals(1, attachments.size());
DataHandler handler = out.getIn(AttachmentMessage.class).getAttachment("logo.jpeg");
- assertNotNull("The logo should be there", handler);
+ assertNotNull(handler, "The logo should be there");
// content type should match
boolean match1 = "image/jpeg; name=logo.jpeg".equals(handler.getContentType());
boolean match2 = "application/octet-stream; name=logo.jpeg".equals(handler.getContentType());
- assertTrue("Should match 1 or 2", match1 || match2);
+ assertTrue(match1 || match2, "Should match 1 or 2");
- assertEquals("Handler name should be the file name", "logo.jpeg", handler.getName());
+ assertEquals("logo.jpeg", handler.getName(), "Handler name should be the file name");
producer.stop();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentTest.java
index 9096885..74192d5 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentTest.java
@@ -29,10 +29,14 @@ import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.attachment.DefaultAttachment;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for Camel attachments and Mail attachments.
*/
@@ -75,19 +79,19 @@ public class MailAttachmentTest extends CamelTestSupport {
// attachment
Map<String, Attachment> attachments = out.getIn(AttachmentMessage.class).getAttachmentObjects();
- assertNotNull("Should have attachments", attachments);
+ assertNotNull(attachments, "Should have attachments");
assertEquals(1, attachments.size());
Attachment attachment = out.getIn(AttachmentMessage.class).getAttachmentObject("logo.jpeg");
DataHandler handler = attachment.getDataHandler();
- assertNotNull("The logo should be there", handler);
+ assertNotNull(handler, "The logo should be there");
// content type should match
boolean match1 = "image/jpeg; name=logo.jpeg".equals(handler.getContentType());
boolean match2 = "application/octet-stream; name=logo.jpeg".equals(handler.getContentType());
- assertTrue("Should match 1 or 2", match1 || match2);
+ assertTrue(match1 || match2, "Should match 1 or 2");
- assertEquals("Handler name should be the file name", "logo.jpeg", handler.getName());
+ assertEquals("logo.jpeg", handler.getName(), "Handler name should be the file name");
assertEquals("some sample content", attachment.getHeader("content-description"));
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java
index afb61b4..31225ef 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java
@@ -29,15 +29,19 @@ import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for Camel attachments and Mail attachments.
*/
-@Ignore("Fails on CI servers and some platforms - maybe due locale or something")
+@Disabled("Fails on CI servers and some platforms - maybe due locale or something")
public class MailAttachmentsUmlautIssueTest extends CamelTestSupport {
@Test
@@ -77,16 +81,16 @@ public class MailAttachmentsUmlautIssueTest extends CamelTestSupport {
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should have attachments", attachments);
+ assertNotNull(attachments, "Should have attachments");
assertEquals(1, attachments.size());
DataHandler handler = out.getIn(AttachmentMessage.class).getAttachment(name);
- assertNotNull("The " + name + " should be there", handler);
+ assertNotNull(handler, "The " + name + " should be there");
String nameURLEncoded = URLEncoder.encode(name, Charset.defaultCharset().name());
- assertTrue("Handler content type should end with URL-encoded name", handler.getContentType().endsWith(nameURLEncoded));
+ assertTrue(handler.getContentType().endsWith(nameURLEncoded), "Handler content type should end with URL-encoded name");
- assertEquals("Handler name should be the file name", name, handler.getName());
+ assertEquals(name, handler.getName(), "Handler name should be the file name");
producer.stop();
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBatchConsumerTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBatchConsumerTest.java
index b641ea0..399822b 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBatchConsumerTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBatchConsumerTest.java
@@ -24,18 +24,21 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.apache.camel.test.junit5.TestSupport.body;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for batch consumer.
*/
public class MailBatchConsumerTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBindingAttachmentFileTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBindingAttachmentFileTest.java
index 24efa85..eb05d40 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBindingAttachmentFileTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailBindingAttachmentFileTest.java
@@ -32,24 +32,17 @@ import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import org.apache.camel.attachment.Attachment;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(Parameterized.class)
public class MailBindingAttachmentFileTest {
- @Parameter
- public String name;
-
private final MailBinding binding = new MailBinding();
- @Test
- public void shouldSanitizeAttachmentFileNames() throws MessagingException, IOException {
+ @ParameterizedTest @MethodSource("fileNames")
+ public void shouldSanitizeAttachmentFileNames(String name) throws MessagingException, IOException {
final Session session = Session.getInstance(new Properties());
final Message message = new MimeMessage(session);
@@ -68,7 +61,6 @@ public class MailBindingAttachmentFileTest {
assertThat(dataHandler.getName()).isEqualTo("file.txt");
}
- @Parameters(name = "{0}")
public static Iterable<String> fileNames() {
return Arrays.asList("file.txt", "../file.txt", "..\\file.txt", "/absolute/file.txt", "c:\\absolute\\file.txt");
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
index baf376f..1783905 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCollectionHeaderTest.java
@@ -20,10 +20,14 @@ import java.util.List;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class MailCollectionHeaderTest extends CamelTestSupport {
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCommitOnCompletionTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCommitOnCompletionTest.java
index 2d54e629..e57492a 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCommitOnCompletionTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCommitOnCompletionTest.java
@@ -23,18 +23,20 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for delete mail runs as an onCompletion.
*/
public class MailCommitOnCompletionTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentRecipientSetTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentRecipientSetTest.java
index c478cc5..1f15002 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentRecipientSetTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentRecipientSetTest.java
@@ -19,10 +19,12 @@ package org.apache.camel.component.mail;
import javax.mail.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class MailComponentRecipientSetTest extends CamelTestSupport {
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
index b4c2663..c559fb5 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
@@ -19,8 +19,16 @@ package org.apache.camel.component.mail;
import javax.mail.Message;
import org.apache.camel.Endpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class MailComponentTest extends CamelTestSupport {
@@ -28,61 +36,61 @@ public class MailComponentTest extends CamelTestSupport {
public void testMailEndpointsAreConfiguredProperlyWhenUsingSmtp() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://james@myhost:25/subject");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 25, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(25, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertFalse(config.isDebugMode());
}
@Test
public void testMailEndpointsAreConfiguredProperlyWhenUsingImap() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("imap://james@myhost:143/subject");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "imap", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 143, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals(false, config.isDebugMode());
+ assertEquals("imap", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(143, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertFalse(config.isDebugMode());
}
@Test
public void testMailEndpointsAreConfiguredProperlyWhenUsingPop() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("pop3://james@myhost:110/subject");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "pop3", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 110, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals(false, config.isDebugMode());
+ assertEquals("pop3", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(110, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertFalse(config.isDebugMode());
}
@Test
public void testDefaultSMTPConfiguration() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://james@myhost?password=secret");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", MailUtils.DEFAULT_PORT_SMTP, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals("contentType", "text/plain", config.getContentType());
- assertEquals("unseen", true, config.isUnseen());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(MailUtils.DEFAULT_PORT_SMTP, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertEquals("text/plain", config.getContentType(), "contentType");
+ assertEquals(true, config.isUnseen(), "unseen");
+ assertFalse(config.isDebugMode());
assertEquals(MailConstants.MAIL_DEFAULT_CONNECTION_TIMEOUT, config.getConnectionTimeout());
- assertEquals(false, config.isSecureProtocol());
+ assertFalse(config.isSecureProtocol());
assertEquals("smtp://myhost:25, folder=INBOX", config.getMailStoreLogInformation());
}
@@ -90,20 +98,20 @@ public class MailComponentTest extends CamelTestSupport {
public void testDefaultSMTPSConfiguration() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("smtps://james@myhost?password=secret");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtps", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", MailUtils.DEFAULT_PORT_SMTPS, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals("contentType", "text/plain", config.getContentType());
- assertEquals("unseen", true, config.isUnseen());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtps", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(MailUtils.DEFAULT_PORT_SMTPS, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertEquals("text/plain", config.getContentType(), "contentType");
+ assertEquals(true, config.isUnseen(), "unseen");
+ assertFalse(config.isDebugMode());
assertEquals(MailConstants.MAIL_DEFAULT_CONNECTION_TIMEOUT, config.getConnectionTimeout());
assertEquals(true, config.isSecureProtocol());
assertEquals("smtps://myhost:465 (SSL enabled), folder=INBOX", config.getMailStoreLogInformation());
@@ -127,40 +135,40 @@ public class MailComponentTest extends CamelTestSupport {
public void testDefaultPOP3Configuration() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("pop3://james@myhost?password=secret");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "pop3", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", MailUtils.DEFAULT_PORT_POP3, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals("contentType", "text/plain", config.getContentType());
- assertEquals("unseen", true, config.isUnseen());
- assertEquals(false, config.isDebugMode());
+ assertEquals("pop3", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(MailUtils.DEFAULT_PORT_POP3, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertEquals("text/plain", config.getContentType(), "contentType");
+ assertEquals(true, config.isUnseen(), "unseen");
+ assertFalse(config.isDebugMode());
}
@Test
public void testDefaultIMAPConfiguration() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("imap://james@myhost?password=secret");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "imap", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", MailUtils.DEFAULT_PORT_IMAP, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals("contentType", "text/plain", config.getContentType());
- assertEquals("unseen", true, config.isUnseen());
- assertEquals(false, config.isDebugMode());
+ assertEquals("imap", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(MailUtils.DEFAULT_PORT_IMAP, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertEquals("text/plain", config.getContentType(), "contentType");
+ assertEquals(true, config.isUnseen(), "unseen");
+ assertFalse(config.isDebugMode());
}
@Test
@@ -169,56 +177,56 @@ public class MailComponentTest extends CamelTestSupport {
+ "&from=me@camelriders.org&delete=true&folderName=riders"
+ "&contentType=text/html&unseen=false");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 30, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "riders", config.getFolderName());
- assertEquals("from", "me@camelriders.org", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(30, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("riders", config.getFolderName(), "folder");
+ assertEquals("me@camelriders.org", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
assertEquals(true, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals("unseen", false, config.isUnseen());
- assertEquals("contentType", "text/html", config.getContentType());
- assertEquals(false, config.isDebugMode());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertFalse(config.isUnseen(), "unseen");
+ assertEquals("text/html", config.getContentType(), "contentType");
+ assertFalse(config.isDebugMode());
}
@Test
public void testTo() {
MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://james@myhost:25/?password=secret&to=someone@outthere.com&folderName=XXX");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 25, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "someone@outthere.com", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "XXX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(25, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("someone@outthere.com", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("XXX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertFalse(config.isDebugMode());
}
@Test
public void testNoUserInfoButUsername() {
MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://myhost:25/?password=secret&username=james");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 25, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", "secret", config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(25, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals("secret", config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertFalse(config.isDebugMode());
}
@Test
@@ -227,46 +235,46 @@ public class MailComponentTest extends CamelTestSupport {
context.getRegistry().bind("auth1", auth1);
MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://myhost:25/?authenticator=#auth1&to=james%40myhost");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 25, config.getPort());
- assertEquals("getUsername()", null, config.getUsername());
- assertNotNull("getPasswordAuthentication()", config.getPasswordAuthentication());
- assertEquals("getPasswordAuthentication().getUserName()", "u1", config.getPasswordAuthentication().getUserName());
- assertEquals("getPasswordAuthentication().getUserName()", "p1", config.getPasswordAuthentication().getPassword());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("from", "camel@localhost", config.getFrom());
- assertEquals("password", null, config.getPassword());
- assertEquals(false, config.isDelete());
- assertEquals(false, config.isIgnoreUriScheme());
- assertEquals("fetchSize", -1, config.getFetchSize());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(25, config.getPort(), "getPort()");
+ assertEquals(null, config.getUsername(), "getUsername()");
+ assertNotNull(config.getPasswordAuthentication(), "getPasswordAuthentication()");
+ assertEquals("u1", config.getPasswordAuthentication().getUserName(), "getPasswordAuthentication().getUserName()");
+ assertEquals("p1", config.getPasswordAuthentication().getPassword(), "getPasswordAuthentication().getUserName()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals("camel@localhost", config.getFrom(), "from");
+ assertEquals(null, config.getPassword(), "password");
+ assertFalse(config.isDelete());
+ assertFalse(config.isIgnoreUriScheme());
+ assertEquals(-1, config.getFetchSize(), "fetchSize");
+ assertFalse(config.isDebugMode());
}
@Test
public void testMailEndpointsWithFetchSize() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("pop3://james@myhost?fetchSize=5");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "pop3", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 110, config.getPort());
- assertEquals("getUsername()", "james", config.getUsername());
- assertEquals("getRecipients().get(Message.RecipientType.TO)", "james@myhost", config.getRecipients().get(Message.RecipientType.TO));
- assertEquals("folder", "INBOX", config.getFolderName());
- assertEquals("fetchSize", 5, config.getFetchSize());
- assertEquals(false, config.isDebugMode());
+ assertEquals("pop3", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(110, config.getPort(), "getPort()");
+ assertEquals("james", config.getUsername(), "getUsername()");
+ assertEquals("james@myhost", config.getRecipients().get(Message.RecipientType.TO), "getRecipients().get(Message.RecipientType.TO)");
+ assertEquals("INBOX", config.getFolderName(), "folder");
+ assertEquals(5, config.getFetchSize(), "fetchSize");
+ assertFalse(config.isDebugMode());
}
@Test
public void testSMTPEndpointWithSubjectOption() throws Exception {
MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://myhost:25?subject=hello");
MailConfiguration config = endpoint.getConfiguration();
- assertEquals("getProtocol()", "smtp", config.getProtocol());
- assertEquals("getHost()", "myhost", config.getHost());
- assertEquals("getPort()", 25, config.getPort());
- assertEquals("getSubject()", "hello", config.getSubject());
- assertEquals(false, config.isDebugMode());
+ assertEquals("smtp", config.getProtocol(), "getProtocol()");
+ assertEquals("myhost", config.getHost(), "getHost()");
+ assertEquals(25, config.getPort(), "getPort()");
+ assertEquals("hello", config.getSubject(), "getSubject()");
+ assertFalse(config.isDebugMode());
}
@Override
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java
index 3e56328..e4ea961 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java
@@ -24,11 +24,11 @@ import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import org.apache.camel.Processor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
/**
@@ -76,7 +76,7 @@ public class MailConsumerAuthenticatorTest {
assertEquals("unauthorized", e.getMessage());
exception = true;
}
- assertTrue("MessagingException expected with message 'unauthorized'", exception);
+ assertTrue(exception, "MessagingException expected with message 'unauthorized'");
// poll a second time, this time there should be no exception, because we now provide the correct password
consumer.poll();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java
index 866d827..8c78246 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerIdleMessageTest.java
@@ -18,8 +18,10 @@ package org.apache.camel.component.mail;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test to verify that the polling consumer delivers an empty Exchange when the
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerUnsupportedCharsetTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerUnsupportedCharsetTest.java
index e47edd6..227c9f2 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerUnsupportedCharsetTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerUnsupportedCharsetTest.java
@@ -23,15 +23,15 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
public class MailConsumerUnsupportedCharsetTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java
index bb5742b..d4aa71d 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java
@@ -27,10 +27,14 @@ import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for Camel attachments and Mail attachments.
*/
@@ -67,17 +71,17 @@ public class MailContentTypeResolverTest extends CamelTestSupport {
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should have attachments", attachments);
+ assertNotNull(attachments, "Should have attachments");
assertEquals(1, attachments.size());
DataHandler handler = out.getIn(AttachmentMessage.class).getAttachment("logo.jpeg");
- assertNotNull("The logo should be there", handler);
+ assertNotNull(handler, "The logo should be there");
// as we use a custom content type resolver the content type should then be fixed and correct
// content type should match
boolean match1 = "image/jpeg; name=logo.jpeg".equals(handler.getContentType());
boolean match2 = "application/octet-stream; name=logo.jpeg".equals(handler.getContentType());
- assertTrue("Should match 1 or 2", match1 || match2);
+ assertTrue(match1 || match2, "Should match 1 or 2");
producer.stop();
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
index 53bf081..39e2751 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
@@ -23,10 +23,13 @@ import javax.mail.Message;
import javax.mail.internet.MimeMultipart;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for contentType option.
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConvertersTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConvertersTest.java
index 6968193..7cb4d22 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConvertersTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConvertersTest.java
@@ -25,15 +25,19 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class MailConvertersTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Mailbox.clearAll();
super.setUp();
@@ -69,7 +73,7 @@ public class MailConvertersTest extends CamelTestSupport {
InputStream is = MailConverters.toInputStream(mailMessage);
assertNotNull(is);
- assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, is));
+ assertEquals(context.getTypeConverter().convertTo(String.class, is), "Hello World");
}
@Test
@@ -94,7 +98,7 @@ public class MailConvertersTest extends CamelTestSupport {
InputStream is = mock.getReceivedExchanges().get(0).getIn().getBody(InputStream.class);
assertNotNull(is);
- assertEquals("Alternative World", context.getTypeConverter().convertTo(String.class, is));
+ assertEquals(context.getTypeConverter().convertTo(String.class, is), "Alternative World");
}
@Test
@@ -119,7 +123,7 @@ public class MailConvertersTest extends CamelTestSupport {
byte[] is = mock.getReceivedExchanges().get(0).getIn().getBody(byte[].class);
assertNotNull(is);
- assertEquals("Alternative World", context.getTypeConverter().convertTo(String.class, is));
+ assertEquals(context.getTypeConverter().convertTo(String.class, is), "Alternative World");
}
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCopyToTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCopyToTest.java
index 7b743db..4e2206e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCopyToTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCopyToTest.java
@@ -23,18 +23,20 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for copyTo.
*/
public class MailCopyToTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomContentTypeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomContentTypeTest.java
index bfee264..f5bb0b5 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomContentTypeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomContentTypeTest.java
@@ -20,10 +20,13 @@ import javax.mail.Message;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for contentType option.
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomMailSenderTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomMailSenderTest.java
index e7d2a53..5f54f29 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomMailSenderTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailCustomMailSenderTest.java
@@ -23,8 +23,10 @@ import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import org.apache.camel.BindToRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MailCustomMailSenderTest extends CamelTestSupport {
@@ -37,7 +39,7 @@ public class MailCustomMailSenderTest extends CamelTestSupport {
public void testSendWithCustomMailSender() throws Exception {
sendBody("smtp://claus@localhost?javaMailSender=#mySender", "Hello World");
- assertTrue("Should have used custom mail sender", sent);
+ assertTrue(sent, "Should have used custom mail sender");
}
private static class MySender implements JavaMailSender {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java
index 7d80e7f..838c05e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java
@@ -18,11 +18,13 @@ package org.apache.camel.component.mail;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.util.StopWatch;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for testing mail polling is happening according to the default poll interval.
*/
@@ -54,7 +56,7 @@ public class MailDefaultDelayForMailConsumeTest extends CamelTestSupport {
mock.assertIsSatisfied();
long delta = watch.taken();
- assertTrue("Camel should not default poll the mailbox to often", delta > 1000 - 1000L);
+ assertTrue(delta > 1000 - 1000L, "Camel should not default poll the mailbox to often");
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDisconnectTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDisconnectTest.java
index a2f4ebb..8dc6ccc 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDisconnectTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDisconnectTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.mail;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
/**
* Unit test for batch consumer.
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDoNotDeleteIfProcessFailsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDoNotDeleteIfProcessFailsTest.java
index 2a057bd..9321c62 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDoNotDeleteIfProcessFailsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDoNotDeleteIfProcessFailsTest.java
@@ -25,11 +25,13 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for rollback option.
*/
@@ -38,7 +40,7 @@ public class MailDoNotDeleteIfProcessFailsTest extends CamelTestSupport {
private static int counter;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTest.java
index d721e3f..b18091e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTest.java
@@ -16,8 +16,12 @@
*/
package org.apache.camel.component.mail;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class MailEndpointTest extends CamelTestSupport {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTlsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTlsTest.java
index d54839b..268b3fa 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTlsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailEndpointTlsTest.java
@@ -20,21 +20,17 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Parameterized.class)
-public class MailEndpointTlsTest extends CamelTestSupport {
-
- private final String protocol;
+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;
- public MailEndpointTlsTest(String protocol) {
- this.protocol = protocol;
- }
+public class MailEndpointTlsTest extends CamelTestSupport {
- @Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{"smtp"},
@@ -46,8 +42,8 @@ public class MailEndpointTlsTest extends CamelTestSupport {
});
}
- @Test
- public void testMailEndpointTlsConfig() throws Exception {
+ @ParameterizedTest @MethodSource("data")
+ public void testMailEndpointTlsConfig(String protocol) throws Exception {
Properties properties = new Properties();
properties.setProperty("mail." + protocol + ".starttls.enable", "true");
@@ -66,8 +62,8 @@ public class MailEndpointTlsTest extends CamelTestSupport {
assertNull(javaMailProperties.get("mail." + protocol + ".ssl.socketFactory.port"));
}
- @Test
- public void testMailEndpointNoTlsConfig() throws Exception {
+ @ParameterizedTest @MethodSource("data")
+ public void testMailEndpointNoTlsConfig(String protocol) throws Exception {
MailConfiguration cfg = new MailConfiguration();
cfg.setPort(21);
cfg.configureProtocol(protocol);
@@ -93,8 +89,8 @@ public class MailEndpointTlsTest extends CamelTestSupport {
}
}
- @Test
- public void testMailEndpointTlsSslContextParametersConfig() throws Exception {
+ @ParameterizedTest @MethodSource("data")
+ public void testMailEndpointTlsSslContextParametersConfig(String protocol) throws Exception {
Properties properties = new Properties();
properties.setProperty("mail." + protocol + ".starttls.enable", "true");
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeTest.java
index d170bce..2b747ff 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeTest.java
@@ -23,18 +23,20 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for fetch size.
*/
public class MailFetchSizeTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeZeroTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeZeroTest.java
index 5ad3200..d9a6bc6 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeZeroTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailFetchSizeZeroTest.java
@@ -23,18 +23,20 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for a special corner case with fetchSize=0
*/
public class MailFetchSizeZeroTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHeaderOverrulePreConfigurationRecipientsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHeaderOverrulePreConfigurationRecipientsTest.java
index 9c2e8d8..9bf1d07 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHeaderOverrulePreConfigurationRecipientsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHeaderOverrulePreConfigurationRecipientsTest.java
@@ -21,8 +21,8 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java
index 2eaad5c..493fe57 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java
@@ -27,10 +27,14 @@ import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for Camel html attachments and Mail attachments.
*/
@@ -74,19 +78,19 @@ public class MailHtmlAttachmentTest extends CamelTestSupport {
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should have attachments", attachments);
+ assertNotNull(attachments, "Should have attachments");
assertEquals(1, attachments.size());
DataHandler handler = out.getIn(AttachmentMessage.class).getAttachment("logo.jpeg");
- assertNotNull("The logo should be there", handler);
+ assertNotNull(handler, "The logo should be there");
byte[] bytes = context.getTypeConverter().convertTo(byte[].class, handler.getInputStream());
- assertNotNull("content should be there", bytes);
- assertTrue("logo should be more than 1000 bytes", bytes.length > 1000);
+ assertNotNull(bytes, "content should be there");
+ assertTrue(bytes.length > 1000, "logo should be more than 1000 bytes");
// content type should match
boolean match1 = "image/jpeg; name=logo.jpeg".equals(handler.getContentType());
boolean match2 = "application/octet-stream; name=logo.jpeg".equals(handler.getContentType());
- assertTrue("Should match 1 or 2", match1 || match2);
+ assertTrue(match1 || match2, "Should match 1 or 2");
// save logo for visual inspection
template.sendBodyAndHeader("file://target", bytes, Exchange.FILE_NAME, "maillogo.jpg");
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateNotRemoveTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateNotRemoveTest.java
index 8e49f35..b110b56 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateNotRemoveTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateNotRemoveTest.java
@@ -18,9 +18,11 @@ package org.apache.camel.component.mail;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for idempotent repository.
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateTest.java
index ad2cf36..7d693fc 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryDuplicateTest.java
@@ -25,11 +25,13 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for idempotent repository.
*/
@@ -39,7 +41,7 @@ public class MailIdempotentRepositoryDuplicateTest extends CamelTestSupport {
MemoryIdempotentRepository myRepo = new MemoryIdempotentRepository();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
// lets assume this ID is already done
myRepo.add("myuid-3");
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryTest.java
index 99dbf06..7549a12 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailIdempotentRepositoryTest.java
@@ -25,11 +25,13 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for idempotent repository.
*/
@@ -39,7 +41,7 @@ public class MailIdempotentRepositoryTest extends CamelTestSupport {
private MemoryIdempotentRepository myRepo = new MemoryIdempotentRepository();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
index cd10a94..54487a5 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
@@ -24,9 +24,9 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
@@ -35,7 +35,7 @@ import org.jvnet.mock_javamail.Mailbox;
public class MailMaxMessagesPerPollTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMessageTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMessageTest.java
index 9c53694..85ed08e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMessageTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMessageTest.java
@@ -28,12 +28,16 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.support.ObjectHelper;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.util.CastUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class MailMessageTest extends CamelTestSupport {
private Session mailSession;
private MimeMessage mimeMessage;
@@ -47,7 +51,7 @@ public class MailMessageTest extends CamelTestSupport {
Exchange exchange = endpoint.createExchange(mimeMessage);
MailMessage in = (MailMessage)exchange.getIn();
assertNotNull(in);
- assertEquals("mail body", body, in.getBody());
+ assertEquals(body, in.getBody(), "mail body");
// need to use iterator as some mail impl returns String[] and others a single String with comma as separator
// so we let Camel create an iterator so we can use the same code for the test
@@ -73,13 +77,13 @@ public class MailMessageTest extends CamelTestSupport {
assertNotNull(in);
Object header = in.getHeader("TO");
String value = assertIsInstanceOf(String.class, header);
- assertEquals("value", "frank@localhost", value);
+ assertEquals("frank@localhost", value, "value");
- assertEquals("body", body, in.getBody());
+ assertEquals(body, in.getBody(), "body");
}
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
Mailbox.clearAll();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMimeDecodeHeadersTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMimeDecodeHeadersTest.java
index fb4fd55..a16c76f 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMimeDecodeHeadersTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMimeDecodeHeadersTest.java
@@ -20,8 +20,8 @@ import javax.mail.internet.MimeUtility;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMoveToTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMoveToTest.java
index 83daae5..b41ecce 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMoveToTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMoveToTest.java
@@ -25,19 +25,22 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for moveTo.
*/
public class MailMoveToTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
@@ -55,11 +58,11 @@ public class MailMoveToTest extends CamelTestSupport {
assertEquals(0, Mailbox.get("jones@localhost").getNewMessageCount());
assertEquals(5, Mailbox.get("moveToFolder-jones@localhost").getNewMessageCount());
- Assert.assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(0).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(1).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(2).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(3).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(4).getFlags().contains(Flags.Flag.SEEN));
+ assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(0).getFlags().contains(Flags.Flag.SEEN));
+ assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(1).getFlags().contains(Flags.Flag.SEEN));
+ assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(2).getFlags().contains(Flags.Flag.SEEN));
+ assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(3).getFlags().contains(Flags.Flag.SEEN));
+ assertTrue(Mailbox.get("moveToFolder-jones@localhost").get(4).getFlags().contains(Flags.Flag.SEEN));
}
@Test
@@ -74,11 +77,11 @@ public class MailMoveToTest extends CamelTestSupport {
assertEquals(0, Mailbox.get("jones2@localhost").getNewMessageCount());
assertEquals(5, Mailbox.get("moveToFolder-jones2@localhost").getNewMessageCount());
- Assert.assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(0).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(1).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(2).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(3).getFlags().contains(Flags.Flag.SEEN));
- Assert.assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(4).getFlags().contains(Flags.Flag.SEEN));
+ assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(0).getFlags().contains(Flags.Flag.SEEN));
+ assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(1).getFlags().contains(Flags.Flag.SEEN));
+ assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(2).getFlags().contains(Flags.Flag.SEEN));
+ assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(3).getFlags().contains(Flags.Flag.SEEN));
+ assertFalse(Mailbox.get("moveToFolder-jones2@localhost").get(4).getFlags().contains(Flags.Flag.SEEN));
}
private void prepareMailbox() throws Exception {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsTest.java
index 3def2ff..98b1d12 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsTest.java
@@ -21,8 +21,8 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsUsingHeadersTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsUsingHeadersTest.java
index 7a7a106..db769b0 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsUsingHeadersTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMultipleRecipientsUsingHeadersTest.java
@@ -22,10 +22,12 @@ import java.util.Map;
import javax.mail.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for Mail using camel headers to set recipeient subject.
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNameAndEmailInRecipientTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNameAndEmailInRecipientTest.java
index f07a5a1..ee79701 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNameAndEmailInRecipientTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNameAndEmailInRecipientTest.java
@@ -21,8 +21,8 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
public class MailNameAndEmailInRecipientTest extends CamelTestSupport {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNoRecipientsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNoRecipientsTest.java
index 4b3c901..53924c5 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNoRecipientsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailNoRecipientsTest.java
@@ -18,8 +18,12 @@ package org.apache.camel.component.mail;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit test for no recipients
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichNoMailTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichNoMailTest.java
index d1cdd4f..96ea136 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichNoMailTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichNoMailTest.java
@@ -21,9 +21,9 @@ import javax.mail.Store;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
@@ -32,7 +32,7 @@ import org.jvnet.mock_javamail.Mailbox;
public class MailPollEnrichNoMailTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichTest.java
index fafdc46..f0d614b 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPollEnrichTest.java
@@ -23,18 +23,20 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test with poll enrich
*/
public class MailPollEnrichTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPostProcessActionTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPostProcessActionTest.java
index d411946..ae76822 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPostProcessActionTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailPostProcessActionTest.java
@@ -24,13 +24,15 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Tests if post process action is called if it is set
*/
@@ -41,7 +43,7 @@ public class MailPostProcessActionTest extends CamelTestSupport {
private TestPostProcessAction action = new TestPostProcessAction();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProcessOnlyUnseenMessagesTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProcessOnlyUnseenMessagesTest.java
index 591f1d2..2025a2d 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProcessOnlyUnseenMessagesTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProcessOnlyUnseenMessagesTest.java
@@ -24,9 +24,9 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
@@ -35,7 +35,7 @@ import org.jvnet.mock_javamail.Mailbox;
public class MailProcessOnlyUnseenMessagesTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
index bb763c2..3ce679f 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
@@ -26,10 +26,14 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.apache.camel.test.junit5.TestSupport.body;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Mail producer concurrent test.
*/
@@ -81,7 +85,7 @@ public class MailProducerConcurrentTest extends CamelTestSupport {
bodies.add(box.get(i).getContent());
}
- assertEquals("There should be " + files + " unique mails", files, bodies.size());
+ assertEquals(files, bodies.size(), "There should be " + files + " unique mails");
executor.shutdownNow();
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java
index c111ced..7e3382b 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerTest.java
@@ -24,10 +24,13 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class MailProducerTest extends CamelTestSupport {
@Test
@@ -39,7 +42,7 @@ public class MailProducerTest extends CamelTestSupport {
assertMockEndpointsSatisfied();
// need to check the message header
Exchange exchange = getMockEndpoint("mock:result").getExchanges().get(0);
- assertNotNull("The message id should not be null", exchange.getIn().getHeader(MailConstants.MAIL_MESSAGE_ID));
+ assertNotNull(exchange.getIn().getHeader(MailConstants.MAIL_MESSAGE_ID), "The message id should not be null");
Mailbox box = Mailbox.get("someone@localhost");
assertEquals(1, box.size());
@@ -63,7 +66,7 @@ public class MailProducerTest extends CamelTestSupport {
assertMockEndpointsSatisfied();
// need to check the message header
Exchange exchange = getMockEndpoint("mock:result").getExchanges().get(0);
- assertNotNull("The message id should not be null", exchange.getIn().getHeader(MailConstants.MAIL_MESSAGE_ID));
+ assertNotNull(exchange.getIn().getHeader(MailConstants.MAIL_MESSAGE_ID), "The message id should not be null");
Mailbox box = Mailbox.get("someone@localhost");
assertEquals(0, box.size());
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerUnsupportedCharsetTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerUnsupportedCharsetTest.java
index be6edf0..5201743 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerUnsupportedCharsetTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerUnsupportedCharsetTest.java
@@ -23,10 +23,13 @@ import java.util.Map;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class MailProducerUnsupportedCharsetTest extends CamelTestSupport {
@Override
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsPipeIssueTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsPipeIssueTest.java
index 90d5841..3dd800c 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsPipeIssueTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsPipeIssueTest.java
@@ -19,10 +19,12 @@ package org.apache.camel.component.mail;
import javax.mail.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for recipients using | in email address
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsTest.java
index 4a73ea1..dc20ae6d6 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRecipientsTest.java
@@ -22,10 +22,13 @@ import java.util.Map;
import javax.mail.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
/**
* Unit test for recipients (To, CC, BCC)
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailReplyToTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailReplyToTest.java
index 867e145..82b795c 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailReplyToTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailReplyToTest.java
@@ -20,10 +20,12 @@ import javax.mail.internet.InternetAddress;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for Mail replyTo support.
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
index ff840a7..8a0d5ab 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
@@ -30,10 +30,15 @@ import org.apache.camel.Processor;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+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.assertTrue;
+
public class MailRouteTest extends CamelTestSupport {
@Test
@@ -86,16 +91,16 @@ public class MailRouteTest extends CamelTestSupport {
mock.assertIsSatisfied();
- assertFalse("Should not have attachements", mock.getExchanges().get(0).getIn(AttachmentMessage.class).hasAttachments());
+ assertFalse(mock.getExchanges().get(0).getIn(AttachmentMessage.class).hasAttachments(), "Should not have attachements");
}
protected void assertMailboxReceivedMessages(String name) throws IOException, MessagingException {
Mailbox mailbox = Mailbox.get(name);
- assertEquals(name + " should have received 1 mail", 1, mailbox.size());
+ assertEquals(1, mailbox.size(), name + " should have received 1 mail");
Message message = mailbox.get(0);
- assertNotNull(name + " should have received at least one mail!", message);
+ assertNotNull(message, name + " should have received at least one mail!");
assertEquals("hello world!", message.getContent());
assertEquals("camel@localhost", message.getFrom()[0].toString());
boolean found = false;
@@ -104,7 +109,7 @@ public class MailRouteTest extends CamelTestSupport {
found = true;
}
}
- assertTrue("Should have found the recpient to in the mail: " + name, found);
+ assertTrue(found, "Should have found the recpient to in the mail: " + name);
}
@Override
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermNotSpamTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermNotSpamTest.java
index 8592131..e1fbecc 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermNotSpamTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermNotSpamTest.java
@@ -19,10 +19,11 @@ package org.apache.camel.component.mail;
import javax.mail.search.SearchTerm;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
import static org.apache.camel.component.mail.SearchTermBuilder.Op;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class MailSearchTermNotSpamTest extends MailSearchTermTest {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermTest.java
index 2418169..c7e96bf 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermTest.java
@@ -26,12 +26,13 @@ import javax.mail.search.SearchTerm;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
import static org.apache.camel.component.mail.SearchTermBuilder.Op;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class MailSearchTermTest extends CamelTestSupport {
@@ -39,7 +40,7 @@ public class MailSearchTermTest extends CamelTestSupport {
private SearchTerm term = createSearchTerm();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigLast24HoursTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigLast24HoursTest.java
index 8e103f6..c6bcb79 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigLast24HoursTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigLast24HoursTest.java
@@ -26,15 +26,17 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class MailSearchTermUriConfigLast24HoursTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigTest.java
index 64f546d..ead1a55 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSearchTermUriConfigTest.java
@@ -24,15 +24,17 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class MailSearchTermUriConfigTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteAllTasksTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteAllTasksTest.java
index e103ab4..153d1b8 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteAllTasksTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteAllTasksTest.java
@@ -25,18 +25,20 @@ import org.apache.camel.Exchange;
import org.apache.camel.ShutdownRunningTask;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for shutdown.
*/
public class MailShutdownCompleteAllTasksTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
@@ -73,7 +75,7 @@ public class MailShutdownCompleteAllTasksTest extends CamelTestSupport {
context.stop();
// should route all
- assertEquals("Should complete all messages", batch, bar.getReceivedCounter());
+ assertEquals(batch, bar.getReceivedCounter(), "Should complete all messages");
}
private void prepareMailbox() throws Exception {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteCurrentTaskOnlyTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteCurrentTaskOnlyTest.java
index f121510..d5e6fbb 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteCurrentTaskOnlyTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailShutdownCompleteCurrentTaskOnlyTest.java
@@ -24,18 +24,20 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.ShutdownRunningTask;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Unit test for shutdown.
*/
public class MailShutdownCompleteCurrentTaskOnlyTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
@@ -56,7 +58,7 @@ public class MailShutdownCompleteCurrentTaskOnlyTest extends CamelTestSupport {
context.stop();
// should NOT route all 5
- assertTrue("Should NOT complete all messages, was: " + bar.getReceivedCounter(), bar.getReceivedCounter() < 5);
+ assertTrue(bar.getReceivedCounter() < 5, "Should NOT complete all messages, was: " + bar.getReceivedCounter());
}
private void prepareMailbox() throws Exception {
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTest.java
index 1c6dd96..5735b34 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTest.java
@@ -28,11 +28,13 @@ import com.sun.mail.imap.SortTerm;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* This is a test that checks integration of the sort term in Camel. The actual
* sorting logic is tested in the SortUtilTest.
@@ -49,7 +51,7 @@ public class MailSortTermTest extends CamelTestSupport {
private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermThreeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermThreeTest.java
index a049fe2..d6e8310 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermThreeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermThreeTest.java
@@ -28,11 +28,13 @@ import com.sun.mail.imap.SortTerm;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* This is a test that checks integration of the sort term in Camel. The actual
* sorting logic is tested in the SortUtilTest.
@@ -49,7 +51,7 @@ public class MailSortTermThreeTest extends CamelTestSupport {
private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTwoTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTwoTest.java
index fea18d4..4583f52 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTwoTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSortTermTwoTest.java
@@ -28,11 +28,13 @@ import com.sun.mail.imap.SortTerm;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* This is a test that checks integration of the sort term in Camel. The actual
* sorting logic is tested in the SortUtilTest.
@@ -49,7 +51,7 @@ public class MailSortTermTwoTest extends CamelTestSupport {
private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prepareMailbox();
super.setUp();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSorterTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSorterTest.java
index 377ab1b..162f166 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSorterTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSorterTest.java
@@ -24,10 +24,11 @@ import javax.mail.MessagingException;
import javax.mail.internet.InternetAddress;
import com.sun.mail.imap.SortTerm;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.mockito.Mockito.when;
/**
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSplitAttachmentsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSplitAttachmentsTest.java
index 1357e85..7561e17 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSplitAttachmentsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSplitAttachmentsTest.java
@@ -25,12 +25,15 @@ import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.commons.io.IOUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Tests the {@link SplitAttachmentsExpression}.
*/
@@ -40,12 +43,12 @@ public class MailSplitAttachmentsTest extends CamelTestSupport {
private SplitAttachmentsExpression splitAttachmentsExpression;
private Exchange exchange;
- @Before
+ @BeforeEach
public void clearMailBox() {
Mailbox.clearAll();
}
- @Before
+ @BeforeEach
public void setup() {
// create the exchange with the mail message that is multipart with a file and a Hello World text/plain message.
endpoint = context.getEndpoint("smtp://james@mymailserver.com?password=secret");
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java
index 594bd51..adac38e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailSubjectTest.java
@@ -19,10 +19,12 @@ package org.apache.camel.component.mail;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
/**
* Unit test for Mail subject support.
*/
@@ -44,7 +46,7 @@ public class MailSubjectTest extends CamelTestSupport {
mock.assertIsSatisfied();
- assertFalse("Should not have attachements", mock.getExchanges().get(0).getIn(AttachmentMessage.class).hasAttachments());
+ assertFalse(mock.getExchanges().get(0).getIn(AttachmentMessage.class).hasAttachments(), "Should not have attachements");
}
@Override
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailToMultipleEndpointsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailToMultipleEndpointsTest.java
index 49bae2da..95e148e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailToMultipleEndpointsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailToMultipleEndpointsTest.java
@@ -19,10 +19,12 @@ package org.apache.camel.component.mail;
import javax.mail.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class MailToMultipleEndpointsTest extends CamelTestSupport {
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java
index cbadd91..6985bfe 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsernameWithAtSignTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.mail;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
/**
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingCustomSessionTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingCustomSessionTest.java
index f40c001..6e1229f 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingCustomSessionTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingCustomSessionTest.java
@@ -27,18 +27,21 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
public class MailUsingCustomSessionTest extends CamelTestSupport {
@BindToRegistry("myCustomMailSession")
private Session mailSession = Session.getInstance(new Properties());
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
Mailbox.clearAll();
@@ -63,7 +66,7 @@ public class MailUsingCustomSessionTest extends CamelTestSupport {
mockEndpoint.assertIsSatisfied();
Mailbox mailbox = Mailbox.get("james@localhost");
- assertEquals("Expected one mail for james@localhost", 1, mailbox.size());
+ assertEquals(1, mailbox.size(), "Expected one mail for james@localhost");
Message message = mailbox.get(0);
assertEquals("hello camel!", message.getContent());
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
index 2ef90a0..82d644e 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingHeadersTest.java
@@ -22,10 +22,13 @@ import java.util.Map;
import javax.mail.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
/**
* Unit test for Mail using camel headers to set recipient subject.
*/
@@ -53,8 +56,8 @@ public class MailUsingHeadersTest extends CamelTestSupport {
assertEquals("jstrachan@apache.org", msg.getFrom()[0].toString());
assertEquals("Camel rocks", msg.getSubject());
- assertNull("We should not get the message header here", msg.getHeader("CamelFileName"));
- assertNull("We should not get the message header here", msg.getHeader("org.apache.camel.test"));
+ assertNull(msg.getHeader("CamelFileName"), "We should not get the message header here");
+ assertNull(msg.getHeader("org.apache.camel.test"), "We should not get the message header here");
}
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingOwnComponentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingOwnComponentTest.java
index b82a1d3..38d6b45 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingOwnComponentTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailUsingOwnComponentTest.java
@@ -19,10 +19,12 @@ package org.apache.camel.component.mail;
import javax.mail.Message;
import org.apache.camel.CamelContext;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for CAMEL-1249
*/
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java
index 5150624..acb5b4a 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMessageConsumeTest.java
@@ -39,10 +39,13 @@ import org.apache.camel.Exchange;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class MimeMessageConsumeTest extends CamelTestSupport {
private String body = "hello world!";
@@ -69,13 +72,13 @@ public class MimeMessageConsumeTest extends CamelTestSupport {
Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
String text = exchange.getIn().getBody(String.class);
- assertEquals("mail body", body, text);
+ assertEquals(body, text, "mail body");
- assertNotNull("attachments got lost", exchange.getIn(AttachmentMessage.class).getAttachments());
+ assertNotNull(exchange.getIn(AttachmentMessage.class).getAttachments(), "attachments got lost");
for (String s : exchange.getIn(AttachmentMessage.class).getAttachmentNames()) {
DataHandler dh = exchange.getIn(AttachmentMessage.class).getAttachment(s);
Object content = dh.getContent();
- assertNotNull("Content should not be empty", content);
+ assertNotNull(content, "Content should not be empty");
assertEquals("log4j2.properties", dh.getName());
}
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java
index d0964fe..6d6d8ef 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java
@@ -27,13 +27,19 @@ import org.apache.camel.Exchange;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.apache.camel.component.mail.MailConstants.MAIL_ALTERNATIVE_BODY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MimeMultipartAlternativeTest extends CamelTestSupport {
+ private Logger log = LoggerFactory.getLogger(getClass());
private String alternativeBody = "hello world! (plain text)";
private String htmlBody = "<html><body><h1>Hello</h1>World<img src=\"cid:0001\"></body></html>";
@@ -68,17 +74,17 @@ public class MimeMultipartAlternativeTest extends CamelTestSupport {
ByteArrayOutputStream baos = new ByteArrayOutputStream(((MailMessage)out.getIn()).getMessage().getSize());
((MailMessage)out.getIn()).getMessage().writeTo(baos);
String dumpedMessage = baos.toString();
- assertTrue("There should have the " + expectString, dumpedMessage.indexOf(expectString) > 0);
+ assertTrue(dumpedMessage.indexOf(expectString) > 0, "There should have the " + expectString);
log.trace("multipart alternative: \n{}", dumpedMessage);
-
+
// plain text
assertEquals(alternativeBody, out.getIn().getBody(String.class));
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should not have null attachments", attachments);
+ assertNotNull(attachments, "Should not have null attachments");
assertEquals(1, attachments.size());
- assertEquals("multipart body should have 2 parts", 2, out.getIn().getBody(MimeMultipart.class).getCount());
+ assertEquals(2, out.getIn().getBody(MimeMultipart.class).getCount(), "multipart body should have 2 parts");
}
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithContentTypeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithContentTypeTest.java
index 6cca522..281b8a7 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithContentTypeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithContentTypeTest.java
@@ -24,13 +24,18 @@ import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.apache.camel.component.mail.MailConstants.MAIL_ALTERNATIVE_BODY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MimeMultipartAlternativeWithContentTypeTest extends CamelTestSupport {
+ private Logger log = LoggerFactory.getLogger(getClass());
private String alternativeBody = "hello world! (plain text)";
private String htmlBody = "<html><body><h1>Hello</h1>World</body></html>";
@@ -64,13 +69,13 @@ public class MimeMultipartAlternativeWithContentTypeTest extends CamelTestSuppor
ByteArrayOutputStream baos = new ByteArrayOutputStream(((MailMessage)out.getIn()).getMessage().getSize());
((MailMessage)out.getIn()).getMessage().writeTo(baos);
String dumpedMessage = baos.toString();
- assertTrue("There should have the " + expectString, dumpedMessage.indexOf(expectString) > 0);
+ assertTrue(dumpedMessage.indexOf(expectString) > 0, "There should have the " + expectString);
log.trace("multipart alternative: \n{}", dumpedMessage);
// plain text
assertEquals(alternativeBody, out.getIn().getBody(String.class));
- assertEquals("multipart body should have 2 parts", 2, out.getIn().getBody(MimeMultipart.class).getCount());
+ assertEquals(2, out.getIn().getBody(MimeMultipart.class).getCount(), "multipart body should have 2 parts");
}
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithLongerFilenameTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithLongerFilenameTest.java
index f0323b9..adce91b 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithLongerFilenameTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeWithLongerFilenameTest.java
@@ -27,13 +27,19 @@ import org.apache.camel.Exchange;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.apache.camel.component.mail.MailConstants.MAIL_ALTERNATIVE_BODY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MimeMultipartAlternativeWithLongerFilenameTest extends CamelTestSupport {
+ private Logger log = LoggerFactory.getLogger(getClass());
private String alternativeBody = "hello world! (plain text)";
private String htmlBody = "<html><body><h1>Hello</h1>World<img src=\"cid:myCoolLogo.jpeg\"></body></html>";
@@ -68,7 +74,7 @@ public class MimeMultipartAlternativeWithLongerFilenameTest extends CamelTestSup
ByteArrayOutputStream baos = new ByteArrayOutputStream(((MailMessage)out.getIn()).getMessage().getSize());
((MailMessage)out.getIn()).getMessage().writeTo(baos);
String dumpedMessage = baos.toString();
- assertTrue("There should have the " + expectString, dumpedMessage.indexOf(expectString) > 0);
+ assertTrue(dumpedMessage.indexOf(expectString) > 0, "There should have the " + expectString);
log.trace("multipart alternative: \n{}", dumpedMessage);
// plain text
@@ -76,9 +82,9 @@ public class MimeMultipartAlternativeWithLongerFilenameTest extends CamelTestSup
// attachment
Map<String, DataHandler> attachments = out.getIn(AttachmentMessage.class).getAttachments();
- assertNotNull("Should not have null attachments", attachments);
+ assertNotNull(attachments, "Should not have null attachments");
assertEquals(1, attachments.size());
- assertEquals("multipart body should have 2 parts", 2, out.getIn().getBody(MimeMultipart.class).getCount());
+ assertEquals(2, out.getIn().getBody(MimeMultipart.class).getCount(), "multipart body should have 2 parts");
}
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MultipleDestinationConsumeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MultipleDestinationConsumeTest.java
index fe09d67..bd516d7 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MultipleDestinationConsumeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MultipleDestinationConsumeTest.java
@@ -32,13 +32,19 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.ObjectHelper;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.util.CastUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class MultipleDestinationConsumeTest extends CamelTestSupport {
+ private Logger log = LoggerFactory.getLogger(getClass());
private String body = "hello world!";
private Session mailSession;
@@ -64,14 +70,14 @@ public class MultipleDestinationConsumeTest extends CamelTestSupport {
Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
org.apache.camel.Message in = exchange.getIn();
- assertNotNull("Should have headers", in.getHeaders());
+ assertNotNull(in.getHeaders(), "Should have headers");
MailMessage msg = (MailMessage) exchange.getIn();
Message inMessage = msg != null ? msg.getMessage() : null;
- assertNotNull("In message has no JavaMail message!", inMessage);
+ assertNotNull(inMessage, "In message has no JavaMail message!");
String text = in.getBody(String.class);
- assertEquals("mail body", body, text);
+ assertEquals(body, text, "mail body");
// need to use iterator as some mail impl returns String[] and others a single String with comma as separator
// so we let Camel create an iterator so we can use the same code for the test
@@ -96,7 +102,7 @@ public class MultipleDestinationConsumeTest extends CamelTestSupport {
}
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Properties properties = new Properties();
properties.put("mail.smtp.host", "localhost");
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/NestedMimeMessageConsumeTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/NestedMimeMessageConsumeTest.java
index 5a27ffd..60c9e37 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/NestedMimeMessageConsumeTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/NestedMimeMessageConsumeTest.java
@@ -31,13 +31,16 @@ import org.apache.camel.attachment.Attachment;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.AnyOf.anyOf;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class NestedMimeMessageConsumeTest extends CamelTestSupport {
@@ -58,13 +61,13 @@ public class NestedMimeMessageConsumeTest extends CamelTestSupport {
assertEquals("text/plain; charset=us-ascii", exchange.getIn().getHeader("Content-Type"));
Set<String> attachmentNames = exchange.getIn(AttachmentMessage.class).getAttachmentNames();
- assertNotNull("attachments got lost", attachmentNames);
+ assertNotNull(attachmentNames, "attachments got lost");
assertEquals(2, attachmentNames.size());
for (String s : attachmentNames) {
Attachment att = exchange.getIn(AttachmentMessage.class).getAttachmentObject(s);
DataHandler dh = att.getDataHandler();
Object content = dh.getContent();
- assertNotNull("Content should not be empty", content);
+ assertNotNull(content, "Content should not be empty");
assertThat(dh.getName(), anyOf(equalTo("image001.png"), equalTo("test.txt")));
}
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java
index 3efacdd..e9c8b05 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java
@@ -29,18 +29,23 @@ import javax.mail.internet.MimeMessage;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
+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;
+
/**
* Unit test for Mail using camel headers to set recipient subject.
*/
public class RawMailMessageTest extends CamelTestSupport {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Mailbox.clearAll();
prepareMailbox("jonesPop3", "pop3");
@@ -97,7 +102,7 @@ public class RawMailMessageTest extends CamelTestSupport {
Message mailMessage = mock.getExchanges().get(0).getIn().getBody(Message.class);
assertNotNull("mail subject should not be null", mailMessage.getSubject());
- assertEquals("mail subject should be hurz", "hurz", mailMessage.getSubject());
+ assertEquals("hurz", mailMessage.getSubject(), "mail subject should be hurz");
Map<String, Object> headers = mock.getExchanges().get(0).getIn().getHeaders();
assertNotNull(headers);
@@ -126,7 +131,7 @@ public class RawMailMessageTest extends CamelTestSupport {
String body = mock.getExchanges().get(0).getIn().getBody(String.class);
MimeMessage mm = new MimeMessage(null, new ByteArrayInputStream(body.getBytes()));
String subject = mm.getSubject();
- assertNull("mail subject should not be available", subject);
+ assertNull(subject, "mail subject should not be available");
Map<String, Object> headers = mock.getExchanges().get(0).getIn().getHeaders();
assertNotNull(headers);
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/SearchTermBuilderTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/SearchTermBuilderTest.java
index e701afb..8d1b36d 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/SearchTermBuilderTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/SearchTermBuilderTest.java
@@ -22,17 +22,20 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.search.SearchTerm;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
import static org.apache.camel.component.mail.SearchTermBuilder.Comparison;
import static org.apache.camel.component.mail.SearchTermBuilder.Op.or;
+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.assertTrue;
/**
*
*/
-public class SearchTermBuilderTest extends Assert {
+public class SearchTermBuilderTest {
@Test
public void testSearchTermBuilderFromAndSubject() throws Exception {
@@ -49,13 +52,13 @@ public class SearchTermBuilderTest extends Assert {
msg.setSubject("Yeah Camel rocks");
msg.setText("Apache Camel is a cool project. Have a fun ride.");
msg.setFrom(new InternetAddress("someone@somewhere.com"));
- assertTrue("Should match message", st.match(msg));
+ assertTrue(st.match(msg), "Should match message");
MimeMessage msg2 = new MimeMessage(sender.getSession());
msg2.setSubject("Apache Camel is fantastic");
msg2.setText("I like Camel.");
msg2.setFrom(new InternetAddress("donotreply@somewhere.com"));
- assertFalse("Should not match message, as from doesn't match", st.match(msg2));
+ assertFalse(st.match(msg2), "Should not match message, as from doesn't match");
}
@Test
@@ -73,13 +76,13 @@ public class SearchTermBuilderTest extends Assert {
msg.setSubject("Yeah Camel rocks");
msg.setText("Apache Camel is a cool project. Have a fun ride.");
msg.setFrom(new InternetAddress("someone@somewhere.com"));
- assertTrue("Should match message", st.match(msg));
+ assertTrue(st.match(msg), "Should match message");
MimeMessage msg2 = new MimeMessage(sender.getSession());
msg2.setSubject("Beware");
msg2.setText("This is from the administrator.");
msg2.setFrom(new InternetAddress("admin@apache.org"));
- assertTrue("Should match message, as its from admin", st.match(msg2));
+ assertTrue(st.match(msg2), "Should match message, as its from admin");
}
@Test
@@ -99,7 +102,7 @@ public class SearchTermBuilderTest extends Assert {
msg.setText("Apache Camel is a cool project. Have a fun ride.");
msg.setFrom(new InternetAddress("someone@somewhere.com"));
msg.setSentDate(new Date());
- assertTrue("Should match message", st.match(msg));
+ assertTrue(st.match(msg), "Should match message");
MimeMessage msg2 = new MimeMessage(sender.getSession());
msg2.setSubject("Camel in Action");
@@ -110,7 +113,7 @@ public class SearchTermBuilderTest extends Assert {
long time = new Date().getTime() - twoDays;
msg2.setSentDate(new Date(time));
- assertFalse("Should not match message as its too old", st.match(msg2));
+ assertFalse(st.match(msg2), "Should not match message as its too old");
}
@Test
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/SpringMailSplitAttachmentsTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/SpringMailSplitAttachmentsTest.java
index b9c72a2..c850170 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/SpringMailSplitAttachmentsTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/SpringMailSplitAttachmentsTest.java
@@ -24,14 +24,17 @@ import org.apache.camel.Exchange;
import org.apache.camel.Producer;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
import org.apache.commons.io.IOUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.mock_javamail.Mailbox;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Spring XML version of {@link MailSplitAttachmentsTest}
*/
@@ -45,12 +48,12 @@ public class SpringMailSplitAttachmentsTest extends CamelSpringTestSupport {
return new ClassPathXmlApplicationContext("org/apache/camel/component/mail/SpringMailSplitAttachmentsTest.xml");
}
- @Before
+ @BeforeEach
public void clearMailBox() {
Mailbox.clearAll();
}
- @Before
+ @BeforeEach
public void setup() {
// create the exchange with the mail message that is multipart with a file and a Hello World text/plain message.
endpoint = context.getEndpoint("smtp://james@mymailserver.com?password=secret");
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/SslContextParametersMailRouteTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/SslContextParametersMailRouteTest.java
index 21208ab..e7fd91b 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/SslContextParametersMailRouteTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/SslContextParametersMailRouteTest.java
@@ -27,16 +27,19 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mail.MailTestHelper;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.jsse.SSLContextParameters;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test of integration between the mail component and JSSE Configuration
* Utility. This test does not easily automate. This test is therefore ignored
* and the source is maintained here for easier development in the future.
*/
-@Ignore
+@Disabled
public class SslContextParametersMailRouteTest extends CamelTestSupport {
private String email = "USERNAME@gmail.com";
diff --git a/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java b/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java
index 0b641a8..de52541 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java
@@ -35,18 +35,25 @@ import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.attachment.DefaultAttachment;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.util.IOHelper;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MimeMultipartDataFormatTest extends CamelTestSupport {
private Exchange exchange;
private AttachmentMessage in;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
exchange = new DefaultExchange(context);
@@ -112,7 +119,7 @@ public class MimeMultipartDataFormatTest extends CamelTestSupport {
}
@Test
- @Ignore("Fails on CI servers and some platforms - maybe due locale or something")
+ @Disabled("Fails on CI servers and some platforms - maybe due locale or something")
public void roundtripWithTextAttachmentsAndSpecialCharacters() throws IOException {
String attContentType = "text/plain";
String attText = "Attachment Text with special characters: \u00A9";