This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit f927b17e539b1313b79e35eeecd45d1e539dbaba Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon Jul 29 14:01:46 2019 +0200 Camel-Mail: Fixed CS --- .../component/mail/MailCustomMailSenderTest.java | 2 +- .../MailIdempotentRepositoryDuplicateTest.java | 5 ++- .../mail/MailIdempotentRepositoryTest.java | 8 ++-- .../component/mail/MailPostProcessActionTest.java | 1 + .../camel/component/mail/MailSearchTermTest.java | 7 ++-- .../camel/component/mail/MailSortTermTest.java | 23 ++++++----- .../component/mail/MailSortTermThreeTest.java | 23 ++++++----- .../camel/component/mail/MailSortTermTwoTest.java | 20 +++++----- .../component/mail/MailUsingCustomSessionTest.java | 5 ++- .../SslContextParametersMailRouteTest.java | 45 ++++++++++------------ 10 files changed, 74 insertions(+), 65 deletions(-) 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 6b057ce..7b57ccd 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 @@ -30,7 +30,7 @@ import org.junit.Test; public class MailCustomMailSenderTest extends CamelTestSupport { private static boolean sent; - + @BindToRegistry("mySender") private MySender sender = new MySender(); 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 024de5b..13c57b6 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import javax.mail.Folder; import javax.mail.Message; import javax.mail.Store; @@ -35,7 +36,7 @@ import org.jvnet.mock_javamail.Mailbox; */ public class MailIdempotentRepositoryDuplicateTest extends CamelTestSupport { - @BindToRegistry("myRepo") + @BindToRegistry("myRepo") MemoryIdempotentRepository myRepo = new MemoryIdempotentRepository(); @Override @@ -94,7 +95,7 @@ public class MailIdempotentRepositoryDuplicateTest extends CamelTestSupport { return new RouteBuilder() { public void configure() throws Exception { from("imap://jones@localhost?password=secret&idempotentRepository=#myRepo&consumer.initialDelay=100&consumer.delay=100").routeId("foo").noAutoStartup() - .to("mock:result"); + .to("mock:result"); } }; } 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 19ed520..a96fb99 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import javax.mail.Folder; import javax.mail.Message; import javax.mail.Store; @@ -35,7 +36,7 @@ import org.jvnet.mock_javamail.Mailbox; */ public class MailIdempotentRepositoryTest extends CamelTestSupport { - @BindToRegistry("myRepo") + @BindToRegistry("myRepo") private MemoryIdempotentRepository myRepo = new MemoryIdempotentRepository(); @Override @@ -60,7 +61,8 @@ public class MailIdempotentRepositoryTest extends CamelTestSupport { Thread.sleep(500); assertEquals(0, Mailbox.get("jones@localhost").getNewMessageCount()); - // they get deleted after processing by default so we should be back to 0 + // they get deleted after processing by default so we should be back to + // 0 assertEquals(0, myRepo.getCacheSize()); } @@ -89,7 +91,7 @@ public class MailIdempotentRepositoryTest extends CamelTestSupport { return new RouteBuilder() { public void configure() throws Exception { from("imap://jones@localhost?password=secret&idempotentRepository=#myRepo&consumer.initialDelay=100&consumer.delay=100").routeId("foo").noAutoStartup() - .to("mock:result"); + .to("mock:result"); } }; } 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 623f548..a2a7c91 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import javax.mail.Folder; import javax.mail.Message; import javax.mail.Store; 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 6147b15..15d3e62 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import javax.mail.Folder; import javax.mail.Message; import javax.mail.Store; @@ -35,9 +36,9 @@ import static org.apache.camel.component.mail.SearchTermBuilder.Op; public class MailSearchTermTest extends CamelTestSupport { - @BindToRegistry("myTerm") - private SearchTerm term = createSearchTerm(); - + @BindToRegistry("myTerm") + private SearchTerm term = createSearchTerm(); + @Override @Before public void setUp() 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 11ecf1f..fcde90a 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import java.util.Date; import javax.mail.Folder; @@ -35,17 +36,17 @@ import org.junit.Test; import org.jvnet.mock_javamail.Mailbox; /** - * This is a test that checks integration of the sort term in Camel. The actual sorting logic is tested in the - * SortUtilTest. + * This is a test that checks integration of the sort term in Camel. The actual + * sorting logic is tested in the SortUtilTest. */ public class MailSortTermTest extends CamelTestSupport { - - @BindToRegistry("sortAscendingDate") - private SortTerm[] termAscDate = new SortTerm[]{SortTerm.DATE}; - + + @BindToRegistry("sortAscendingDate") + private SortTerm[] termAscDate = new SortTerm[] {SortTerm.DATE}; + @BindToRegistry("sortDescendingDate") - private SortTerm[] termDescDate = new SortTerm[]{SortTerm.REVERSE, SortTerm.DATE}; - + private SortTerm[] termDescDate = new SortTerm[] {SortTerm.REVERSE, SortTerm.DATE}; + @BindToRegistry("searchTerm") private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build(); @@ -80,7 +81,8 @@ public class MailSortTermTest extends CamelTestSupport { folder.open(Folder.READ_WRITE); folder.expunge(); - // inserts 3 messages, one with earlier, one with later sent date and one with invalid subject (not returned in search) + // inserts 3 messages, one with earlier, one with later sent date and + // one with invalid subject (not returned in search) Message[] messages = new Message[3]; messages[0] = new MimeMessage(sender.getSession()); messages[0].setText("Earlier date"); @@ -109,7 +111,8 @@ public class MailSortTermTest extends CamelTestSupport { public void configure() throws Exception { context.setAutoStartup(false); - from("pop3://bill@localhost?password=secret&searchTerm=#searchTerm&sortTerm=#sortAscendingDate&consumer.initialDelay=100&consumer.delay=100").to("mock:resultAscending"); + from("pop3://bill@localhost?password=secret&searchTerm=#searchTerm&sortTerm=#sortAscendingDate&consumer.initialDelay=100&consumer.delay=100") + .to("mock:resultAscending"); } }; } 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 133927c..ff3e7a1 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import java.util.Date; import javax.mail.Folder; @@ -35,19 +36,20 @@ import org.junit.Test; import org.jvnet.mock_javamail.Mailbox; /** - * This is a test that checks integration of the sort term in Camel. The actual sorting logic is tested in the - * SortUtilTest. + * This is a test that checks integration of the sort term in Camel. The actual + * sorting logic is tested in the SortUtilTest. */ public class MailSortTermThreeTest extends CamelTestSupport { - + @BindToRegistry("sortAscendingDate") - private SortTerm[] termAscDate = new SortTerm[]{SortTerm.DATE}; - -@BindToRegistry("sortDescendingDate") -private SortTerm[] termDescDate = new SortTerm[]{SortTerm.REVERSE, SortTerm.DATE}; + private SortTerm[] termAscDate = new SortTerm[] {SortTerm.DATE}; + + @BindToRegistry("sortDescendingDate") + private SortTerm[] termDescDate = new SortTerm[] {SortTerm.REVERSE, SortTerm.DATE}; + + @BindToRegistry("searchTerm") + private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build(); -@BindToRegistry("searchTerm") -private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build(); @Override @Before public void setUp() throws Exception { @@ -79,7 +81,8 @@ private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build() folder.open(Folder.READ_WRITE); folder.expunge(); - // inserts 3 messages, one with earlier, one with later sent date and one with invalid subject (not returned in search) + // inserts 3 messages, one with earlier, one with later sent date and + // one with invalid subject (not returned in search) Message[] messages = new Message[3]; messages[0] = new MimeMessage(sender.getSession()); messages[0].setText("Earlier date"); 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 17f85a2..2a1de53 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 @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.component.mail; + import java.util.Date; import javax.mail.Folder; @@ -35,19 +36,19 @@ import org.junit.Test; import org.jvnet.mock_javamail.Mailbox; /** - * This is a test that checks integration of the sort term in Camel. The actual sorting logic is tested in the - * SortUtilTest. + * This is a test that checks integration of the sort term in Camel. The actual + * sorting logic is tested in the SortUtilTest. */ public class MailSortTermTwoTest extends CamelTestSupport { @BindToRegistry("sortAscendingDate") - private SortTerm[] termAscDate = new SortTerm[]{SortTerm.DATE}; - -@BindToRegistry("sortDescendingDate") -private SortTerm[] termDescDate = new SortTerm[]{SortTerm.REVERSE, SortTerm.DATE}; + private SortTerm[] termAscDate = new SortTerm[] {SortTerm.DATE}; + + @BindToRegistry("sortDescendingDate") + private SortTerm[] termDescDate = new SortTerm[] {SortTerm.REVERSE, SortTerm.DATE}; -@BindToRegistry("searchTerm") -private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build(); + @BindToRegistry("searchTerm") + private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build(); @Override @Before @@ -80,7 +81,8 @@ private SearchTerm searchTerm = new SearchTermBuilder().subject("Camel").build() folder.open(Folder.READ_WRITE); folder.expunge(); - // inserts 3 messages, one with earlier, one with later sent date and one with invalid subject (not returned in search) + // inserts 3 messages, one with earlier, one with later sent date and + // one with invalid subject (not returned in search) Message[] messages = new Message[3]; messages[0] = new MimeMessage(sender.getSession()); messages[0].setText("Earlier date"); 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 d437b01..0994680 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 @@ -35,7 +35,7 @@ import org.jvnet.mock_javamail.Mailbox; public class MailUsingCustomSessionTest extends CamelTestSupport { - @BindToRegistry("myCustomMailSession") + @BindToRegistry("myCustomMailSession") private Session mailSession = Session.getInstance(new Properties()); @Before @@ -46,7 +46,8 @@ public class MailUsingCustomSessionTest extends CamelTestSupport { @Test public void testEndpointConfigurationWithCustomSession() { - // Verify that the mail session bound to the bean registry is identical to the session tied to the endpoint configuration + // Verify that the mail session bound to the bean registry is identical + // to the session tied to the endpoint configuration assertSame(mailSession, getEndpointMailSession("smtp://james@localhost?session=#myCustomMailSession")); } 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 2924a19..bdb9c6c 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 @@ -33,9 +33,9 @@ import org.junit.Ignore; import org.junit.Test; /** - * 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. + * 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 public class SslContextParametersMailRouteTest extends CamelTestSupport { @@ -45,25 +45,23 @@ public class SslContextParametersMailRouteTest extends CamelTestSupport { private String imapHost = "imap.gmail.com"; private String smtpHost = "smtp.gmail.com"; private String password = "PASSWORD"; - + @BindToRegistry("sslContextParameters") private SSLContextParameters params = MailTestHelper.createSslContextParameters(); - + @Test public void testSendAndReceiveMails() throws Exception { - + context.addRoutes(new RouteBuilder() { public void configure() { - + from("imaps://" + imapHost + "?username=" + username + "&password=" + password - + "&delete=false&unseen=true&fetchSize=1&consumer.useFixedDelay=true&consumer.initialDelay=100&consumer.delay=100") - .to("mock:in"); - - from("direct:in") - .to("smtps://" + smtpHost + "?username=" + username + "&password=" + password); + + "&delete=false&unseen=true&fetchSize=1&consumer.useFixedDelay=true&consumer.initialDelay=100&consumer.delay=100").to("mock:in"); + + from("direct:in").to("smtps://" + smtpHost + "?username=" + username + "&password=" + password); } }); - + context.start(); MockEndpoint resultEndpoint = getMockEndpoint("mock:in"); @@ -74,24 +72,22 @@ public class SslContextParametersMailRouteTest extends CamelTestSupport { headers.put("From", email); headers.put("Reply-to", email); headers.put("Subject", "SSL/TLS Test"); - + template.sendBodyAndHeaders("direct:in", "Test Email Body", headers); resultEndpoint.assertIsSatisfied(); } - + @Test public void testSendAndReceiveMailsWithCustomTrustStore() throws Exception { - + context.addRoutes(new RouteBuilder() { public void configure() { - - from("direct:in") - .to("smtps://" + smtpHost + "?username=" + username + "&password=" + password - + "&sslContextParameters=#sslContextParameters"); + + from("direct:in").to("smtps://" + smtpHost + "?username=" + username + "&password=" + password + "&sslContextParameters=#sslContextParameters"); } }); - + context.start(); Map<String, Object> headers = new HashMap<>(); @@ -99,17 +95,16 @@ public class SslContextParametersMailRouteTest extends CamelTestSupport { headers.put("From", email); headers.put("Reply-to", email); headers.put("Subject", "SSL/TLS Test"); - + try { template.sendBodyAndHeaders("direct:in", "Test Email Body", headers); fail("Should have thrown exception"); } catch (CamelExecutionException e) { assertTrue(e.getCause().getCause() instanceof SSLHandshakeException); - assertTrue(e.getCause().getCause().getMessage().contains( - "unable to find valid certification path to requested target")); + assertTrue(e.getCause().getCause().getMessage().contains("unable to find valid certification path to requested target")); } } - + /** * Stop Camel startup. */