You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/02/13 14:06:28 UTC
[camel] 06/06: CAMEL-14551 - Create an AWS-SES component based on
SDK v2, Fixed CS
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 b8c5d3bf1b63bd142259a92589067702a08e4549
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Feb 13 15:00:18 2020 +0100
CAMEL-14551 - Create an AWS-SES component based on SDK v2, Fixed CS
---
.../camel/component/aws2/ses/Ses2Component.java | 3 +-
.../aws2/ses/Ses2ComponentVerifierExtension.java | 1 -
.../component/aws2/ses/Ses2Configuration.java | 42 +++++++++-------
.../camel/component/aws2/ses/Ses2Constants.java | 4 +-
.../camel/component/aws2/ses/Ses2Endpoint.java | 11 ++---
.../camel/component/aws2/ses/Ses2Producer.java | 21 ++++----
.../component/aws2/ses/AmazonSESClientMock.java | 26 +++++-----
.../camel/component/aws2/ses/MockMessage.java | 23 +++------
.../aws2/ses/SESComponentClientRegistryTest.java | 8 ++-
.../aws2/ses/SesComponentConfigurationTest.java | 57 ++++++++++------------
.../component/aws2/ses/SesComponentSpringTest.java | 39 +++++++--------
.../camel/component/aws2/ses/SesComponentTest.java | 31 +++++-------
.../integration/SesComponentIntegrationTest.java | 3 +-
13 files changed, 121 insertions(+), 148 deletions(-)
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index a2c3360..e9b53bc 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -24,7 +24,6 @@ import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
-
import software.amazon.awssdk.services.ses.SesClient;
@Component("aws2-ses")
@@ -113,7 +112,7 @@ public class Ses2Component extends DefaultComponent {
public void setRegion(String region) {
this.region = region;
}
-
+
private void checkAndSetRegistryClient(Ses2Configuration configuration) {
Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class);
if (clients.size() == 1) {
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ComponentVerifierExtension.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ComponentVerifierExtension.java
index e217f07..9990101 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ComponentVerifierExtension.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2ComponentVerifierExtension.java
@@ -22,7 +22,6 @@ import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExt
import org.apache.camel.component.extension.verifier.ResultBuilder;
import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
import org.apache.camel.component.extension.verifier.ResultErrorHelper;
-
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.exception.SdkClientException;
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
index 1143343..96634a9 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
@@ -19,19 +19,19 @@ package org.apache.camel.component.aws2.ses;
import java.util.Arrays;
import java.util.List;
-import software.amazon.awssdk.core.Protocol;
-import software.amazon.awssdk.services.ses.SesClient;
-
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
+import software.amazon.awssdk.core.Protocol;
+import software.amazon.awssdk.services.ses.SesClient;
@UriParams
public class Ses2Configuration implements Cloneable {
- @UriPath @Metadata(required = true)
+ @UriPath
+ @Metadata(required = true)
private String from;
@UriParam
private SesClient amazonSESClient;
@@ -94,14 +94,16 @@ public class Ses2Configuration implements Cloneable {
}
/**
- * List of destination email address. Can be overriden with 'CamelAwsSesTo' header.
+ * List of destination email address. Can be overriden with 'CamelAwsSesTo'
+ * header.
*/
public void setTo(List<String> to) {
this.to = to;
}
/**
- * List of destination email address. Can be overriden with 'CamelAwsSesTo' header.
+ * List of destination email address. Can be overriden with 'CamelAwsSesTo'
+ * header.
*/
public void setTo(String to) {
this.to = Arrays.asList(to.split(","));
@@ -123,38 +125,41 @@ public class Ses2Configuration implements Cloneable {
}
/**
- * The subject which is used if the message header 'CamelAwsSesSubject' is not present.
+ * The subject which is used if the message header 'CamelAwsSesSubject' is
+ * not present.
*/
public void setSubject(String subject) {
this.subject = subject;
}
-
+
public String getReturnPath() {
return returnPath;
}
/**
- * The email address to which bounce notifications are to be forwarded, override it using 'CamelAwsSesReturnPath' header.
+ * The email address to which bounce notifications are to be forwarded,
+ * override it using 'CamelAwsSesReturnPath' header.
*/
public void setReturnPath(String returnPath) {
this.returnPath = returnPath;
}
-
+
public List<String> getReplyToAddresses() {
return replyToAddresses;
}
/**
- * List of reply-to email address(es) for the message, override it using 'CamelAwsSesReplyToAddresses' header.
+ * List of reply-to email address(es) for the message, override it using
+ * 'CamelAwsSesReplyToAddresses' header.
*/
public void setReplyToAddresses(List<String> replyToAddresses) {
this.replyToAddresses = replyToAddresses;
}
-
+
public void setReplyToAddresses(String replyToAddresses) {
this.replyToAddresses = Arrays.asList(replyToAddresses.split(","));
}
-
+
public Protocol getProxyProtocol() {
return proxyProtocol;
}
@@ -165,7 +170,7 @@ public class Ses2Configuration implements Cloneable {
public void setProxyProtocol(Protocol proxyProtocol) {
this.proxyProtocol = proxyProtocol;
}
-
+
public String getProxyHost() {
return proxyHost;
}
@@ -187,19 +192,20 @@ public class Ses2Configuration implements Cloneable {
public void setProxyPort(Integer proxyPort) {
this.proxyPort = proxyPort;
}
-
+
public String getRegion() {
return region;
}
/**
- * The region in which SES client needs to work. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1)
- * You'll need to use the name Regions.EU_WEST_1.name()
+ * The region in which SES client needs to work. When using this parameter,
+ * the configuration will expect the capitalized name of the region (for
+ * example AP_EAST_1) You'll need to use the name Regions.EU_WEST_1.name()
*/
public void setRegion(String region) {
this.region = region;
}
-
+
// *************************************************
//
// *************************************************
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Constants.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Constants.java
index 6240dd3..0573798 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Constants.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Constants.java
@@ -20,10 +20,10 @@ package org.apache.camel.component.aws2.ses;
* Constants used in Camel AWS SES component
*/
public interface Ses2Constants {
-
+
String FROM = "CamelAwsSesFrom";
String MESSAGE_ID = "CamelAwsSesMessageId";
- String REPLY_TO_ADDRESSES = "CamelAwsSesReplyToAddresses";
+ String REPLY_TO_ADDRESSES = "CamelAwsSesReplyToAddresses";
String RETURN_PATH = "CamelAwsSesReturnPath";
String SUBJECT = "CamelAwsSesSubject";
String TO = "CamelAwsSesTo";
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
index 71839db..4d95fb0 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
@@ -26,7 +26,6 @@ import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.util.ObjectHelper;
-
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
@@ -50,15 +49,13 @@ public class Ses2Endpoint extends DefaultEndpoint {
super(uri, component);
this.configuration = configuration;
}
-
+
@Override
public void doStart() throws Exception {
super.doStart();
- sesClient = configuration.getAmazonSESClient() != null
- ? configuration.getAmazonSESClient()
- : createSESClient();
+ sesClient = configuration.getAmazonSESClient() != null ? configuration.getAmazonSESClient() : createSESClient();
}
-
+
@Override
public void doStop() throws Exception {
if (ObjectHelper.isEmpty(configuration.getAmazonSESClient())) {
@@ -88,7 +85,7 @@ public class Ses2Endpoint extends DefaultEndpoint {
}
private SesClient createSESClient() {
- SesClient client = null;
+ SesClient client = null;
SesClientBuilder clientBuilder = SesClient.builder();
ProxyConfiguration.Builder proxyConfig = null;
ApacheHttpClient.Builder httpClientBuilder = null;
diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
index 49691c0..7ebba4e 100644
--- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
+++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Producer.java
@@ -29,7 +29,6 @@ import org.apache.camel.support.DefaultProducer;
import org.apache.camel.util.URISupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.services.ses.model.Body;
import software.amazon.awssdk.services.ses.model.Content;
@@ -48,7 +47,7 @@ public class Ses2Producer extends DefaultProducer {
private static final Logger LOG = LoggerFactory.getLogger(Ses2Producer.class);
private transient String sesProducerToString;
-
+
public Ses2Producer(Endpoint endpoint) {
super(endpoint);
}
@@ -82,7 +81,7 @@ public class Ses2Producer extends DefaultProducer {
return request.build();
}
-
+
private SendRawEmailRequest createRawMailRequest(Exchange exchange) throws Exception {
SendRawEmailRequest.Builder request = SendRawEmailRequest.builder();
request.source(determineFrom(exchange));
@@ -92,7 +91,7 @@ public class Ses2Producer extends DefaultProducer {
}
private software.amazon.awssdk.services.ses.model.Message createMessage(Exchange exchange) {
- software.amazon.awssdk.services.ses.model.Message.Builder message = software.amazon.awssdk.services.ses.model.Message.builder();
+ software.amazon.awssdk.services.ses.model.Message.Builder message = software.amazon.awssdk.services.ses.model.Message.builder();
Boolean isHtmlEmail = exchange.getIn().getHeader(Ses2Constants.HTML_EMAIL, false, Boolean.class);
String content = exchange.getIn().getBody(String.class);
if (isHtmlEmail) {
@@ -103,9 +102,9 @@ public class Ses2Producer extends DefaultProducer {
message.subject(Content.builder().data(determineSubject(exchange)).build());
return message.build();
}
-
+
private software.amazon.awssdk.services.ses.model.RawMessage createRawMessage(Exchange exchange) throws Exception {
- software.amazon.awssdk.services.ses.model.RawMessage.Builder message = software.amazon.awssdk.services.ses.model.RawMessage.builder();
+ software.amazon.awssdk.services.ses.model.RawMessage.Builder message = software.amazon.awssdk.services.ses.model.RawMessage.builder();
javax.mail.Message content = exchange.getIn().getBody(javax.mail.Message.class);
OutputStream byteOutput = new ByteArrayOutputStream();
try {
@@ -118,7 +117,7 @@ public class Ses2Producer extends DefaultProducer {
message.data(SdkBytes.fromByteBuffer(ByteBuffer.wrap(messageByteArray)));
return message.build();
}
-
+
@SuppressWarnings("unchecked")
private Collection<String> determineReplyToAddresses(Exchange exchange) {
List<String> replyToAddresses = exchange.getIn().getHeader(Ses2Constants.REPLY_TO_ADDRESSES, List.class);
@@ -127,7 +126,7 @@ public class Ses2Producer extends DefaultProducer {
}
return replyToAddresses;
}
-
+
private String determineReturnPath(Exchange exchange) {
String returnPath = exchange.getIn().getHeader(Ses2Constants.RETURN_PATH, String.class);
if (returnPath == null) {
@@ -144,7 +143,7 @@ public class Ses2Producer extends DefaultProducer {
}
return Destination.builder().toAddresses(to).build();
}
-
+
@SuppressWarnings("unchecked")
private List determineRawTo(Exchange exchange) {
List<String> to = exchange.getIn().getHeader(Ses2Constants.TO, List.class);
@@ -184,9 +183,9 @@ public class Ses2Producer extends DefaultProducer {
@Override
public Ses2Endpoint getEndpoint() {
- return (Ses2Endpoint) super.getEndpoint();
+ return (Ses2Endpoint)super.getEndpoint();
}
-
+
public static Message getMessageForResponse(final Exchange exchange) {
return exchange.getMessage();
}
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/AmazonSESClientMock.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/AmazonSESClientMock.java
index 5f2ebd4..a65487e 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/AmazonSESClientMock.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/AmazonSESClientMock.java
@@ -34,7 +34,7 @@ public class AmazonSESClientMock implements SesClient {
this.sendEmailRequest = sendEmailRequest;
return SendEmailResponse.builder().messageId("1").build();
}
-
+
@Override
public SendRawEmailResponse sendRawEmail(SendRawEmailRequest sendRawEmailRequest) {
this.sendRawEmailRequest = sendRawEmailRequest;
@@ -44,20 +44,20 @@ public class AmazonSESClientMock implements SesClient {
public SendEmailRequest getSendEmailRequest() {
return sendEmailRequest;
}
-
+
public SendRawEmailRequest getSendRawEmailRequest() {
return sendRawEmailRequest;
}
- @Override
- public String serviceName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void close() {
- // TODO Auto-generated method stub
-
- }
+ @Override
+ public String serviceName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/MockMessage.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/MockMessage.java
index 588feed..be12be6 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/MockMessage.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/MockMessage.java
@@ -105,7 +105,7 @@ public class MockMessage extends Message {
@Override
public void setText(String text) throws MessagingException {
}
-
+
@Override
public void setContent(Multipart mp) throws MessagingException {
}
@@ -120,13 +120,11 @@ public class MockMessage extends Message {
}
@Override
- public void setHeader(String headername, String headervalue)
- throws MessagingException {
+ public void setHeader(String headername, String headervalue) throws MessagingException {
}
@Override
- public void addHeader(String headername, String headervalue)
- throws MessagingException {
+ public void addHeader(String headername, String headervalue) throws MessagingException {
}
@Override
@@ -139,14 +137,12 @@ public class MockMessage extends Message {
}
@Override
- public Enumeration<Header> getMatchingHeaders(String[] headernames)
- throws MessagingException {
+ public Enumeration<Header> getMatchingHeaders(String[] headernames) throws MessagingException {
return null;
}
@Override
- public Enumeration<Header> getNonMatchingHeaders(String[] headernames)
- throws MessagingException {
+ public Enumeration<Header> getNonMatchingHeaders(String[] headernames) throws MessagingException {
return null;
}
@@ -168,19 +164,16 @@ public class MockMessage extends Message {
}
@Override
- public Address[] getRecipients(RecipientType type)
- throws MessagingException {
+ public Address[] getRecipients(RecipientType type) throws MessagingException {
return null;
}
@Override
- public void setRecipients(RecipientType type, Address[] addresses)
- throws MessagingException {
+ public void setRecipients(RecipientType type, Address[] addresses) throws MessagingException {
}
@Override
- public void addRecipients(RecipientType type, Address[] addresses)
- throws MessagingException {
+ public void addRecipients(RecipientType type, Address[] addresses) throws MessagingException {
}
@Override
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
index e6e8538..d76a2ae 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.component.aws2.ses;
-import org.apache.camel.component.aws2.ses.Ses2Component;
-import org.apache.camel.component.aws2.ses.Ses2Endpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
@@ -29,15 +27,15 @@ public class SESComponentClientRegistryTest extends CamelTestSupport {
AmazonSESClientMock awsSESClient = new AmazonSESClientMock();
context.getRegistry().bind("awsSesClient", awsSESClient);
Ses2Component component = new Ses2Component(context);
- Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws-ses://from@example.com");
+ Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws-ses://from@example.com");
assertNotNull(endpoint.getConfiguration().getAmazonSESClient());
}
-
+
@Test(expected = IllegalArgumentException.class)
public void createEndpointWithMinimalSESClientMisconfiguration() throws Exception {
Ses2Component component = new Ses2Component(context);
- Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws-ses://from@example.com");
+ Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws-ses://from@example.com");
}
}
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java
index ab7b09d..6f578c1 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java
@@ -19,25 +19,22 @@ package org.apache.camel.component.aws2.ses;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.component.aws2.ses.Ses2Component;
-import org.apache.camel.component.aws2.ses.Ses2Endpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-
import software.amazon.awssdk.core.Protocol;
import software.amazon.awssdk.regions.Region;
public class SesComponentConfigurationTest extends CamelTestSupport {
-
+
@Test
public void createEndpointWithMinimalConfiguration() throws Exception {
AmazonSESClientMock mock = new AmazonSESClientMock();
context.getRegistry().bind("amazonSESClient", mock);
-
+
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
- Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com?amazonSESClient=#amazonSESClient&accessKey=xxx&secretKey=yyy");
-
+ Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws2-ses://from@example.com?amazonSESClient=#amazonSESClient&accessKey=xxx&secretKey=yyy");
+
assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
@@ -51,7 +48,7 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
@Test
public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
- Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
+ Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
@@ -62,17 +59,16 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
assertNull(endpoint.getConfiguration().getReturnPath());
assertNull(endpoint.getConfiguration().getReplyToAddresses());
}
-
+
@Test
public void createEndpointWithMinimalConfigurationAndProvidedClient() throws Exception {
AmazonSESClientMock mock = new AmazonSESClientMock();
context.getRegistry().bind("amazonSESClient", mock);
-
+
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
- Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com?"
- + "amazonSESClient=#amazonSESClient");
-
+ Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws2-ses://from@example.com?" + "amazonSESClient=#amazonSESClient");
+
assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
assertNull(endpoint.getConfiguration().getAccessKey());
assertNull(endpoint.getConfiguration().getSecretKey());
@@ -97,10 +93,10 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
context.getRegistry().bind("toList", to);
context.getRegistry().bind("replyToList", replyAddress);
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
- Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://from@example.com?amazonSESClient=#amazonSESClient&accessKey=xxx"
- + "&secretKey=yyy&to=#toList&subject=Subject"
- + "&returnPath=bounce@example.com&replyToAddresses=#replyToList");
-
+ Ses2Endpoint endpoint = (Ses2Endpoint)component
+ .createEndpoint("aws2-ses://from@example.com?amazonSESClient=#amazonSESClient&accessKey=xxx" + "&secretKey=yyy&to=#toList&subject=Subject"
+ + "&returnPath=bounce@example.com&replyToAddresses=#replyToList");
+
assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
@@ -114,43 +110,43 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
assertTrue(endpoint.getConfiguration().getReplyToAddresses().contains("replyTo1@example.com"));
assertTrue(endpoint.getConfiguration().getReplyToAddresses().contains("replyTo2@example.com"));
}
-
+
@Test(expected = IllegalArgumentException.class)
public void createEndpointWithoutSourceName() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.createEndpoint("aws2-ses:// ");
}
-
+
@Test(expected = IllegalArgumentException.class)
public void createEndpointWithoutAmazonSESClientConfiguration() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.createEndpoint("aws2-ses://from@example.com");
}
-
+
@Test(expected = IllegalArgumentException.class)
public void createEndpointWithoutAccessKeyConfiguration() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.createEndpoint("aws2-ses://from@example.com?secretKey=yyy");
}
-
+
@Test(expected = IllegalArgumentException.class)
public void createEndpointWithoutSecretKeyConfiguration() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.createEndpoint("aws2-ses://from@example.com?accessKey=xxx");
}
-
+
@Test
public void createEndpointWithComponentElements() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.setAccessKey("XXX");
component.setSecretKey("YYY");
Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws2-ses://from@example.com");
-
+
assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
assertEquals("YYY", endpoint.getConfiguration().getSecretKey());
}
-
+
@Test
public void createEndpointWithComponentAndEndpointElements() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
@@ -158,21 +154,22 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
component.setSecretKey("YYY");
component.setRegion(Region.US_WEST_1.toString());
Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws-ses://from@example.com?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1");
-
+
assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey());
assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion());
}
-
+
@Test
public void createEndpointWithComponentEndpointElementsAndProxy() throws Exception {
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.setAccessKey("XXX");
component.setSecretKey("YYY");
component.setRegion(Region.US_WEST_1.toString());
- Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws2-ses://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1&proxyHost=localhost&proxyPort=9000&proxyProtocol=HTTP");
-
+ Ses2Endpoint endpoint = (Ses2Endpoint)component
+ .createEndpoint("aws2-ses://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1&proxyHost=localhost&proxyPort=9000&proxyProtocol=HTTP");
+
assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey());
assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion());
@@ -180,13 +177,13 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
assertEquals("localhost", endpoint.getConfiguration().getProxyHost());
assertEquals(Integer.valueOf(9000), endpoint.getConfiguration().getProxyPort());
}
-
+
@Test
public void createEndpointWithoutSecretKeyAndAccessKeyConfiguration() throws Exception {
AmazonSESClientMock mock = new AmazonSESClientMock();
context.getRegistry().bind("amazonSESClient", mock);
-
+
Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class);
component.createEndpoint("aws2-ses://from@example.com?amazonSESClient=#amazonSESClient");
}
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java
index 545c649..4f2b461 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java
@@ -21,25 +21,23 @@ import java.util.List;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-import org.apache.camel.component.aws2.ses.Ses2Constants;
import org.apache.camel.test.spring.CamelSpringTestSupport;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-
import software.amazon.awssdk.services.ses.model.SendEmailRequest;
import software.amazon.awssdk.services.ses.model.SendRawEmailRequest;
public class SesComponentSpringTest extends CamelSpringTestSupport {
-
+
private AmazonSESClientMock sesClient;
-
+
@Override
@Before
public void setUp() throws Exception {
super.setUp();
-
+
sesClient = context.getRegistry().lookupByNameAndType("amazonSESClient", AmazonSESClientMock.class);
}
@@ -51,15 +49,15 @@ public class SesComponentSpringTest extends CamelSpringTestSupport {
exchange.getIn().setBody("This is my message text.");
}
});
-
+
assertEquals("1", exchange.getIn().getHeader(Ses2Constants.MESSAGE_ID));
-
+
SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
assertEquals("from@example.com", sendEmailRequest.source());
assertEquals("bounce@example.com", sendEmailRequest.returnPath());
assertEquals("This is my message text.", getBody(sendEmailRequest));
}
-
+
@Test
public void sendInOutMessageUsingUrlOptions() throws Exception {
Exchange exchange = template.request("direct:start", new Processor() {
@@ -68,22 +66,22 @@ public class SesComponentSpringTest extends CamelSpringTestSupport {
exchange.getIn().setBody("This is my message text.");
}
});
-
+
assertEquals("1", exchange.getMessage().getHeader(Ses2Constants.MESSAGE_ID));
}
-
+
@Test
public void sendRawMessage() throws Exception {
- final MockMessage mess = new MockMessage();
+ final MockMessage mess = new MockMessage();
Exchange exchange = template.request("direct:start", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(mess);
}
});
-
+
assertEquals("1", exchange.getMessage().getHeader(Ses2Constants.MESSAGE_ID));
-
+
SendRawEmailRequest sendRawEmailRequest = sesClient.getSendRawEmailRequest();
assertEquals("from@example.com", sendRawEmailRequest.source());
}
@@ -94,15 +92,13 @@ public class SesComponentSpringTest extends CamelSpringTestSupport {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("This is my message text.");
exchange.getIn().setHeader(Ses2Constants.FROM, "anotherFrom@example.com");
- exchange.getIn().setHeader(Ses2Constants.TO,
- Arrays.asList("anotherTo1@example.com", "anotherTo2@example.com"));
+ exchange.getIn().setHeader(Ses2Constants.TO, Arrays.asList("anotherTo1@example.com", "anotherTo2@example.com"));
exchange.getIn().setHeader(Ses2Constants.RETURN_PATH, "anotherBounce@example.com");
- exchange.getIn().setHeader(Ses2Constants.REPLY_TO_ADDRESSES,
- Arrays.asList("anotherReplyTo1@example.com", "anotherReplyTo2@example.com"));
+ exchange.getIn().setHeader(Ses2Constants.REPLY_TO_ADDRESSES, Arrays.asList("anotherReplyTo1@example.com", "anotherReplyTo2@example.com"));
exchange.getIn().setHeader(Ses2Constants.SUBJECT, "anotherSubject");
}
});
-
+
assertEquals("1", exchange.getIn().getHeader(Ses2Constants.MESSAGE_ID));
SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
@@ -117,11 +113,10 @@ public class SesComponentSpringTest extends CamelSpringTestSupport {
assertEquals("anotherSubject", getSubject(sendEmailRequest));
assertEquals("This is my message text.", getBody(sendEmailRequest));
}
-
+
@Override
protected AbstractApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext(
- "org/apache/camel/component/aws2/ses/SESComponentSpringTest-context.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/aws2/ses/SESComponentSpringTest-context.xml");
}
private String getBody(SendEmailRequest sendEmailRequest) {
@@ -135,7 +130,7 @@ public class SesComponentSpringTest extends CamelSpringTestSupport {
private List<String> getTo(SendEmailRequest sendEmailRequest) {
return sendEmailRequest.destination().toAddresses();
}
-
+
private List<String> getTo(SendRawEmailRequest sendEmailRequest) {
return sendEmailRequest.destinations();
}
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
index 98d2887..df78663 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java
@@ -23,20 +23,18 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.aws2.ses.Ses2Constants;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-
import software.amazon.awssdk.services.ses.model.SendEmailRequest;
public class SesComponentTest extends CamelTestSupport {
@BindToRegistry("amazonSESClient")
private AmazonSESClientMock sesClient = new AmazonSESClientMock();
-
+
@BindToRegistry("toList")
private List<String> toList = Arrays.asList("to1@example.com", "to2@example.com");
-
+
@BindToRegistry("replyToList")
private List<String> replyToList = Arrays.asList("replyTo1@example.com", "replyTo2@example.com");
@@ -48,9 +46,9 @@ public class SesComponentTest extends CamelTestSupport {
exchange.getIn().setBody("This is my message text.");
}
});
-
+
assertEquals("1", exchange.getIn().getHeader(Ses2Constants.MESSAGE_ID));
-
+
SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
assertEquals("from@example.com", sendEmailRequest.source());
assertEquals(2, getTo(sendEmailRequest).size());
@@ -63,7 +61,7 @@ public class SesComponentTest extends CamelTestSupport {
assertEquals("Subject", getSubject(sendEmailRequest));
assertEquals("This is my message text.", getBody(sendEmailRequest));
}
-
+
@Test
public void sendInOutMessageUsingUrlOptions() throws Exception {
Exchange exchange = template.request("direct:start", new Processor() {
@@ -72,7 +70,7 @@ public class SesComponentTest extends CamelTestSupport {
exchange.getIn().setBody("This is my message text.");
}
});
-
+
assertEquals("1", exchange.getMessage().getHeader(Ses2Constants.MESSAGE_ID));
}
@@ -82,15 +80,13 @@ public class SesComponentTest extends CamelTestSupport {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("This is my message text.");
exchange.getIn().setHeader(Ses2Constants.FROM, "anotherFrom@example.com");
- exchange.getIn().setHeader(Ses2Constants.TO,
- Arrays.asList("anotherTo1@example.com", "anotherTo2@example.com"));
+ exchange.getIn().setHeader(Ses2Constants.TO, Arrays.asList("anotherTo1@example.com", "anotherTo2@example.com"));
exchange.getIn().setHeader(Ses2Constants.RETURN_PATH, "anotherBounce@example.com");
- exchange.getIn().setHeader(Ses2Constants.REPLY_TO_ADDRESSES,
- Arrays.asList("anotherReplyTo1@example.com", "anotherReplyTo2@example.com"));
+ exchange.getIn().setHeader(Ses2Constants.REPLY_TO_ADDRESSES, Arrays.asList("anotherReplyTo1@example.com", "anotherReplyTo2@example.com"));
exchange.getIn().setHeader(Ses2Constants.SUBJECT, "anotherSubject");
}
});
-
+
assertEquals("1", exchange.getIn().getHeader(Ses2Constants.MESSAGE_ID));
SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
@@ -111,13 +107,8 @@ public class SesComponentTest extends CamelTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start")
- .to("aws2-ses://from@example.com"
- + "?to=#toList"
- + "&subject=Subject"
- + "&returnPath=bounce@example.com"
- + "&replyToAddresses=#replyToList"
- + "&amazonSESClient=#amazonSESClient");
+ from("direct:start").to("aws2-ses://from@example.com" + "?to=#toList" + "&subject=Subject" + "&returnPath=bounce@example.com" + "&replyToAddresses=#replyToList"
+ + "&amazonSESClient=#amazonSESClient");
}
};
}
diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java
index 7e8cfce..58a0499 100644
--- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java
+++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java
@@ -48,8 +48,7 @@ public class SesComponentIntegrationTest extends CamelTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start")
- .to("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
+ from("direct:start").to("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
}
};
}