You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2011/12/18 13:19:26 UTC

svn commit: r1220379 - in /camel/branches/camel-2.8.x: components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/ components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/ components/camel-aws/src/test/java/org/a...

Author: cmueller
Date: Sun Dec 18 12:19:26 2011
New Revision: 1220379

URL: http://svn.apache.org/viewvc?rev=1220379&view=rev
Log:
CAMEL-3591: Add Simple Email Service SES to camel-aws
Thanks Bilgin for the patch

Added:
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConstants.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesEndpoint.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesProducer.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/aws-ses
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/AmazonSESClientMock.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentSpringTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/integration/
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/integration/SesComponentIntegrationTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/ses/
    camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/ses/SESComponentSpringTest-context.xml
      - copied, changed from r1215494, camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesIntegrationTest.java
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesTest.java
Modified:
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelContext.xml
    camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml

Added: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Defines the <a href="http://aws.amazon.com/ses/">AWS SES component</a> 
+ */
+public class SesComponent extends DefaultComponent {
+
+    public SesComponent() {
+        super();
+    }
+
+    public SesComponent(CamelContext context) {
+        super(context);
+    }
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        SesConfiguration configuration = new SesConfiguration();
+        setProperties(configuration, parameters);
+
+        if (remaining == null || remaining.trim().length() == 0) {
+            throw new IllegalArgumentException("From must be specified.");
+        }
+        configuration.setFrom(remaining);
+
+        if (configuration.getAmazonSESClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
+            throw new IllegalArgumentException("AmazonSESClient or accessKey and secretKey must be specified");
+        }
+
+        return new SesEndpoint(uri, getCamelContext(), configuration);
+    }
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
+
+/**
+ * The AWS SES component configuration properties
+ * 
+ */
+public class SesConfiguration {
+    
+    private AmazonSimpleEmailService amazonSESClient;
+    private String accessKey;
+    private String secretKey;
+    private String subject;
+    private String from;
+    private List<String> to;
+    private String returnPath;
+    private List<String> replyToAddresses;
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public AmazonSimpleEmailService getAmazonSESClient() {
+        return amazonSESClient;
+    }
+
+    public void setAmazonSESClient(AmazonSimpleEmailService amazonSESClient) {
+        this.amazonSESClient = amazonSESClient;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public List<String> getTo() {
+        return to;
+    }
+
+    public void setTo(List<String> to) {
+        this.to = to;
+    }
+    
+    public void setTo(String to) {
+        this.to = Arrays.asList(to.split(","));
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+    
+    public String getReturnPath() {
+        return returnPath;
+    }
+
+    public void setReturnPath(String returnPath) {
+        this.returnPath = returnPath;
+    }
+    
+    public List<String> getReplyToAddresses() {
+        return replyToAddresses;
+    }
+
+    public void setReplyToAddresses(List<String> replyToAddresses) {
+        this.replyToAddresses = replyToAddresses;
+    }
+    
+    public void setReplyToAddresses(String replyToAddresses) {
+        this.replyToAddresses = Arrays.asList(replyToAddresses.split(","));
+    }
+
+    @Override
+    public String toString() {
+        return "SesConfiguration{"
+                + "accessKey='" + accessKey + '\''
+                + ", amazonSESClient=" + amazonSESClient
+                + ", secretKey=xxxxxxxxxxxxxxx"
+                + ", subject='" + subject + '\''
+                + ", from='" + from + '\''
+                + ", to='" + to + '\''
+                + ", returnPath='" + returnPath + '\''
+                + ", replyToAddresses='" + replyToAddresses + '\''
+                + '}';
+    }
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConstants.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConstants.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConstants.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConstants.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+/**
+ * Constants used in Camel AWS SES component
+ */
+public interface SesConstants {
+    
+    String FROM = "CamelAwsSesFrom";
+    String MESSAGE_ID = "CamelAwsSesMessageId";
+    String REPLY_TO_ADDRESSES = "CamelAwsSesReplyToAddresses";    
+    String RETURN_PATH = "CamelAwsSesReturnPath";
+    String SUBJECT = "CamelAwsSesSubject";
+    String TO = "CamelAwsSesTo";
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesEndpoint.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesEndpoint.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesEndpoint.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
+import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * Defines the <a href="http://camel.apache.org/aws.html">AWS SES Endpoint</a>.  
+ *
+ */
+public class SesEndpoint extends DefaultEndpoint {
+    
+    private SesConfiguration configuration;
+
+    public SesEndpoint(String uri, CamelContext context, SesConfiguration configuration) {
+        super(uri, context);
+        this.configuration = configuration;
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
+    }
+
+    public Producer createProducer() throws Exception {
+        return new SesProducer(this);
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public SesConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public AmazonSimpleEmailService getSESClient() {
+        return configuration.getAmazonSESClient() != null
+                ? configuration.getAmazonSESClient()
+                : createSESClient();
+    }
+
+    private AmazonSimpleEmailService createSESClient() {
+        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
+        AmazonSimpleEmailService client = new AmazonSimpleEmailServiceClient(credentials);
+        configuration.setAmazonSESClient(client);
+        return client;
+    }
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesProducer.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesProducer.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesProducer.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,136 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import java.util.Collection;
+import java.util.List;
+
+import com.amazonaws.services.simpleemail.model.Body;
+import com.amazonaws.services.simpleemail.model.Content;
+import com.amazonaws.services.simpleemail.model.Destination;
+import com.amazonaws.services.simpleemail.model.SendEmailRequest;
+import com.amazonaws.services.simpleemail.model.SendEmailResult;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.URISupport;
+
+/**
+ * A Producer which sends messages to the Amazon Simple Email Service
+ * <a href="http://aws.amazon.com/ses/">AWS SES</a>
+ */
+public class SesProducer extends DefaultProducer {
+    
+    public SesProducer(Endpoint endpoint) {
+        super(endpoint);
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        SendEmailRequest request = createMailRequest(exchange);
+        log.trace("Sending request [{}] from exchange [{}]...", request, exchange);
+        
+        SendEmailResult result = getEndpoint().getSESClient().sendEmail(request);
+
+        log.trace("Received result [{}]", result);
+        Message message = getMessageForResponse(exchange);
+        message.setHeader(SesConstants.MESSAGE_ID, result.getMessageId());
+    }
+
+    private SendEmailRequest createMailRequest(Exchange exchange) {
+        SendEmailRequest request = new SendEmailRequest();
+        request.setSource(determineFrom(exchange));
+        request.setDestination(determineTo(exchange));
+        request.setReturnPath(determineReturnPath(exchange));
+        request.setReplyToAddresses(determineReplyToAddresses(exchange));
+        request.setMessage(createMessage(exchange));
+
+        return request;
+    }
+
+    private com.amazonaws.services.simpleemail.model.Message createMessage(Exchange exchange) {
+        com.amazonaws.services.simpleemail.model.Message message = new com.amazonaws.services.simpleemail.model.Message();
+        message.setBody(new Body(new Content(exchange.getIn().getBody(String.class))));
+        message.setSubject(new Content(determineSubject(exchange)));
+        return message;
+    }
+    
+    @SuppressWarnings("unchecked")
+    private Collection<String> determineReplyToAddresses(Exchange exchange) {
+        List<String> replyToAddresses = exchange.getIn().getHeader(SesConstants.REPLY_TO_ADDRESSES, List.class);
+        if (replyToAddresses == null) {
+            replyToAddresses = getConfiguration().getReplyToAddresses();
+        }
+        return replyToAddresses;
+    }
+    
+    private String determineReturnPath(Exchange exchange) {
+        String returnPath = exchange.getIn().getHeader(SesConstants.RETURN_PATH, String.class);
+        if (returnPath == null) {
+            returnPath = getConfiguration().getReturnPath();
+        }
+        return returnPath;
+    }
+
+    @SuppressWarnings("unchecked")
+    private Destination determineTo(Exchange exchange) {
+        List<String> to = exchange.getIn().getHeader(SesConstants.TO, List.class);
+        if (to == null) {
+            to = getConfiguration().getTo();
+        }
+        return new Destination(to);
+    }
+
+    private String determineFrom(Exchange exchange) {
+        String from = exchange.getIn().getHeader(SesConstants.FROM, String.class);
+        if (from == null) {
+            from = getConfiguration().getFrom();
+        }
+        return from;
+    }
+
+    private String determineSubject(Exchange exchange) {
+        String subject = exchange.getIn().getHeader(SesConstants.SUBJECT, String.class);
+        if (subject == null) {
+            subject = getConfiguration().getSubject();
+        }
+        return subject;
+    }
+
+    private Message getMessageForResponse(Exchange exchange) {
+        if (exchange.getPattern().isOutCapable()) {
+            Message out = exchange.getOut();
+            out.copyFrom(exchange.getIn());
+            return out;
+        }
+        return exchange.getIn();
+    }
+
+    protected SesConfiguration getConfiguration() {
+        return getEndpoint().getConfiguration();
+    }
+
+    @Override
+    public String toString() {
+        return "SesProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
+    }
+
+    @Override
+    public SesEndpoint getEndpoint() {
+        return (SesEndpoint) super.getEndpoint();
+    }
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/aws-ses
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/aws-ses?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/aws-ses (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/aws-ses Sun Dec 18 12:19:26 2011
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+class=org.apache.camel.component.aws.ses.SesComponent

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/AmazonSESClientMock.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/AmazonSESClientMock.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/AmazonSESClientMock.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/AmazonSESClientMock.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import com.amazonaws.AmazonClientException;
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
+import com.amazonaws.services.simpleemail.model.SendEmailRequest;
+import com.amazonaws.services.simpleemail.model.SendEmailResult;
+
+public class AmazonSESClientMock extends AmazonSimpleEmailServiceClient {
+    private SendEmailRequest sendEmailRequest;
+
+    public AmazonSESClientMock() {
+        super(new BasicAWSCredentials("myAccessKey", "mySecretKey"));
+    }
+
+    @Override
+    public SendEmailResult sendEmail(SendEmailRequest sendEmailRequest) throws AmazonServiceException, AmazonClientException {
+        this.sendEmailRequest = sendEmailRequest;
+        SendEmailResult result = new SendEmailResult();
+        result.setMessageId("1");
+        
+        return result;
+    }
+
+    public SendEmailRequest getSendEmailRequest() {
+        return sendEmailRequest;
+    }
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class SesComponentConfigurationTest extends CamelTestSupport {
+    
+    @Test
+    public void createEndpointWithMinimalConfiguration() throws Exception {
+        SesComponent component = new SesComponent(context);
+        SesEndpoint endpoint = (SesEndpoint) component.createEndpoint("aws-ses://from@example.com?accessKey=xxx&secretKey=yyy");
+        
+        assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
+        assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
+        assertNull(endpoint.getConfiguration().getAmazonSESClient());
+        assertNull(endpoint.getConfiguration().getTo());
+        assertNull(endpoint.getConfiguration().getSubject());
+        assertNull(endpoint.getConfiguration().getReturnPath());
+        assertNull(endpoint.getConfiguration().getReplyToAddresses());
+    }
+    
+    @Test
+    public void createEndpointWithMinimalConfigurationAndProvidedClient() throws Exception {
+        AmazonSESClientMock mock = new AmazonSESClientMock();
+        
+        ((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry())
+            .bind("amazonSESClient", mock);
+        
+        SesComponent component = new SesComponent(context);
+        SesEndpoint endpoint = (SesEndpoint) component.createEndpoint("aws-ses://from@example.com?"
+                + "amazonSESClient=#amazonSESClient");
+        
+        assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
+        assertNull(endpoint.getConfiguration().getAccessKey());
+        assertNull(endpoint.getConfiguration().getSecretKey());
+        assertSame(mock, endpoint.getConfiguration().getAmazonSESClient());
+        assertNull(endpoint.getConfiguration().getTo());
+        assertNull(endpoint.getConfiguration().getSubject());
+        assertNull(endpoint.getConfiguration().getReturnPath());
+        assertNull(endpoint.getConfiguration().getReplyToAddresses());
+    }
+
+    @Test
+    public void createEndpointWithMaximalConfiguration() throws Exception {
+        SesComponent component = new SesComponent(context);
+        SesEndpoint endpoint = (SesEndpoint) component.createEndpoint("aws-ses://from@example.com?accessKey=xxx"
+            + "&secretKey=yyy&to=to1@example.com,to2@example.com&subject=Subject&returnPath=bounce@example.com"
+            + "&replyToAddresses=replyTo1@example.com,replyTo2@example.com");
+        
+        assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
+        assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
+        assertNull(endpoint.getConfiguration().getAmazonSESClient());
+        assertEquals(2, endpoint.getConfiguration().getTo().size());
+        assertTrue(endpoint.getConfiguration().getTo().contains("to1@example.com"));
+        assertTrue(endpoint.getConfiguration().getTo().contains("to2@example.com"));
+        assertEquals("Subject", endpoint.getConfiguration().getSubject());
+        assertEquals("bounce@example.com", endpoint.getConfiguration().getReturnPath());
+        assertEquals(2, endpoint.getConfiguration().getReplyToAddresses().size());
+        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 {
+        SesComponent component = new SesComponent(context);
+        component.createEndpoint("aws-ses:// ");
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutAmazonSESClientConfiguration() throws Exception {
+        SesComponent component = new SesComponent(context);
+        component.createEndpoint("aws-ses://from@example.com");
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutAccessKeyConfiguration() throws Exception {
+        SesComponent component = new SesComponent(context);
+        component.createEndpoint("aws-ses://from@example.com?secretKey=yyy");
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutSecretKeyConfiguration() throws Exception {
+        SesComponent component = new SesComponent(context);
+        component.createEndpoint("aws-ses://from@example.com?accessKey=xxx");
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentSpringTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentSpringTest.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentSpringTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentSpringTest.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.amazonaws.services.simpleemail.model.SendEmailRequest;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SesComponentSpringTest extends CamelSpringTestSupport {
+    
+    private AmazonSESClientMock sesClient;
+    
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        sesClient = context.getRegistry().lookup("amazonSESClient", AmazonSESClientMock.class);
+    }
+
+    @Test
+    public void sendInOnlyMessageUsingUrlOptions() throws Exception {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertEquals("1", exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+        
+        SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
+        assertEquals("from@example.com", sendEmailRequest.getSource());
+        assertEquals(2, getTo(sendEmailRequest).size());
+        assertTrue(getTo(sendEmailRequest).contains("to1@example.com"));
+        assertTrue(getTo(sendEmailRequest).contains("to2@example.com"));
+        assertEquals("bounce@example.com", sendEmailRequest.getReturnPath());
+        assertEquals(2, sendEmailRequest.getReplyToAddresses().size());
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("replyTo1@example.com"));
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("replyTo2@example.com"));
+        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() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertEquals("1", exchange.getOut().getHeader(SesConstants.MESSAGE_ID));
+    }
+
+    @Test
+    public void sendMessageUsingMessageHeaders() throws Exception {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+                exchange.getIn().setHeader(SesConstants.FROM, "anotherFrom@example.com");
+                exchange.getIn().setHeader(SesConstants.TO,
+                        Arrays.asList("anotherTo1@example.com", "anotherTo2@example.com"));
+                exchange.getIn().setHeader(SesConstants.RETURN_PATH, "anotherBounce@example.com");
+                exchange.getIn().setHeader(SesConstants.REPLY_TO_ADDRESSES,
+                        Arrays.asList("anotherReplyTo1@example.com", "anotherReplyTo2@example.com"));
+                exchange.getIn().setHeader(SesConstants.SUBJECT, "anotherSubject");
+            }
+        });
+        
+        assertEquals("1", exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+
+        SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
+        assertEquals("anotherFrom@example.com", sendEmailRequest.getSource());
+        assertEquals(2, getTo(sendEmailRequest).size());
+        assertTrue(getTo(sendEmailRequest).contains("anotherTo1@example.com"));
+        assertTrue(getTo(sendEmailRequest).contains("anotherTo2@example.com"));
+        assertEquals("anotherBounce@example.com", sendEmailRequest.getReturnPath());
+        assertEquals(2, sendEmailRequest.getReplyToAddresses().size());
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("anotherReplyTo1@example.com"));
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("anotherReplyTo2@example.com"));
+        assertEquals("anotherSubject", getSubject(sendEmailRequest));
+        assertEquals("This is my message text.", getBody(sendEmailRequest));
+    }
+    
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+                "org/apache/camel/component/aws/ses/SESComponentSpringTest-context.xml");
+    }
+
+    private String getBody(SendEmailRequest sendEmailRequest) {
+        return sendEmailRequest.getMessage().getBody().getText().getData();
+    }
+
+    private String getSubject(SendEmailRequest sendEmailRequest) {
+        return sendEmailRequest.getMessage().getSubject().getData();
+    }
+
+    private List<String> getTo(SendEmailRequest sendEmailRequest) {
+        return sendEmailRequest.getDestination().getToAddresses();
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentTest.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentTest.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.amazonaws.services.simpleemail.model.SendEmailRequest;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SesComponentTest extends CamelTestSupport {
+    
+    private AmazonSESClientMock sesClient;
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        sesClient = new AmazonSESClientMock();
+        super.setUp();
+    }
+
+    @Test
+    public void sendInOnlyMessageUsingUrlOptions() throws Exception {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertEquals("1", exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+        
+        SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
+        assertEquals("from@example.com", sendEmailRequest.getSource());
+        assertEquals(2, getTo(sendEmailRequest).size());
+        assertTrue(getTo(sendEmailRequest).contains("to1@example.com"));
+        assertTrue(getTo(sendEmailRequest).contains("to2@example.com"));
+        assertEquals("bounce@example.com", sendEmailRequest.getReturnPath());
+        assertEquals(2, sendEmailRequest.getReplyToAddresses().size());
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("replyTo1@example.com"));
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("replyTo2@example.com"));
+        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() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertEquals("1", exchange.getOut().getHeader(SesConstants.MESSAGE_ID));
+    }
+
+    @Test
+    public void sendMessageUsingMessageHeaders() throws Exception {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+                exchange.getIn().setHeader(SesConstants.FROM, "anotherFrom@example.com");
+                exchange.getIn().setHeader(SesConstants.TO,
+                        Arrays.asList("anotherTo1@example.com", "anotherTo2@example.com"));
+                exchange.getIn().setHeader(SesConstants.RETURN_PATH, "anotherBounce@example.com");
+                exchange.getIn().setHeader(SesConstants.REPLY_TO_ADDRESSES,
+                        Arrays.asList("anotherReplyTo1@example.com", "anotherReplyTo2@example.com"));
+                exchange.getIn().setHeader(SesConstants.SUBJECT, "anotherSubject");
+            }
+        });
+        
+        assertEquals("1", exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+
+        SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest();
+        assertEquals("anotherFrom@example.com", sendEmailRequest.getSource());
+        assertEquals(2, getTo(sendEmailRequest).size());
+        assertTrue(getTo(sendEmailRequest).contains("anotherTo1@example.com"));
+        assertTrue(getTo(sendEmailRequest).contains("anotherTo2@example.com"));
+        assertEquals("anotherBounce@example.com", sendEmailRequest.getReturnPath());
+        assertEquals(2, sendEmailRequest.getReplyToAddresses().size());
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("anotherReplyTo1@example.com"));
+        assertTrue(sendEmailRequest.getReplyToAddresses().contains("anotherReplyTo2@example.com"));
+        assertEquals("anotherSubject", getSubject(sendEmailRequest));
+        assertEquals("This is my message text.", getBody(sendEmailRequest));
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        
+        registry.bind("amazonSESClient", sesClient);
+        
+        return registry;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("aws-ses://from@example.com"
+                        + "?to=to1@example.com,to2@example.com"
+                        + "&subject=Subject"
+                        + "&returnPath=bounce@example.com"
+                        + "&replyToAddresses=replyTo1@example.com,replyTo2@example.com"
+                        + "&amazonSESClient=#amazonSESClient");
+            }
+        };
+    }
+
+    private String getBody(SendEmailRequest sendEmailRequest) {
+        return sendEmailRequest.getMessage().getBody().getText().getData();
+    }
+
+    private String getSubject(SendEmailRequest sendEmailRequest) {
+        return sendEmailRequest.getMessage().getSubject().getData();
+    }
+
+    private List<String> getTo(SendEmailRequest sendEmailRequest) {
+        return sendEmailRequest.getDestination().getToAddresses();
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/integration/SesComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/integration/SesComponentIntegrationTest.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/integration/SesComponentIntegrationTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/integration/SesComponentIntegrationTest.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws.ses.integration;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws.ses.SesConstants;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
+public class SesComponentIntegrationTest extends CamelTestSupport {
+
+    @Test
+    public void sendUsingAccessKeyAndSecretKey() throws Exception {
+        Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SesConstants.SUBJECT, "This is my subject");
+                exchange.getIn().setHeader(SesConstants.TO, "to@example.com");
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+
+        assertNotNull(exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("aws-ses://from@example.com?accessKey=xxx&secretKey=yyy");
+            }
+        };
+    }
+}

Copied: camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/ses/SESComponentSpringTest-context.xml (from r1215494, camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/ses/SESComponentSpringTest-context.xml?p2=camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/ses/SESComponentSpringTest-context.xml&p1=camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml&r1=1215494&r2=1220379&rev=1220379&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml (original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/ses/SESComponentSpringTest-context.xml Sun Dec 18 12:19:26 2011
@@ -23,27 +23,9 @@
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:start"/>
-            <to uri="aws-sqs://MyQueue?accessKey=xxx&amp;secretKey=yyy"/>
-        </route>
-
-        <route>
-            <from uri="aws-sqs://MyQueue?accessKey=xxx&amp;secretKey=yyy"/>
-            <to uri="mock:result"/>
-        </route>
-        
-        <route>
-            <from uri="direct:start-sns"/>
-            <to uri="aws-sns://MyTopic?accessKey=xxx&amp;secretKey=yyy"/>
-        </route>
-        
-        <route>
-            <from uri="direct:start-s3"/>
-            <to uri="aws-s3://mycamelbucket?accessKey=xxx&amp;secretKey=yyy"/>
-        </route>
-        
-        <route>
-            <from uri="aws-s3://mycamelbucket?accessKey=xxx&amp;secretKey=yyy&amp;maxMessagesPerPoll=5"/>
-            <to uri="mock:result-s3"/>
+            <to uri="aws-ses://from@example.com?amazonSESClient=#amazonSESClient&amp;to=to1@example.com,to2@example.com&amp;subject=Subject&amp;returnPath=bounce@example.com&amp;replyToAddresses=replyTo1@example.com,replyTo2@example.com"/>
         </route>
     </camelContext>
+
+    <bean id="amazonSESClient" class="org.apache.camel.component.aws.ses.AmazonSESClientMock"/>
 </beans>
\ No newline at end of file

Added: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java (added)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSESClientMock.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.osgi.aws;
+
+import com.amazonaws.AmazonClientException;
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
+import com.amazonaws.services.simpleemail.model.SendEmailRequest;
+import com.amazonaws.services.simpleemail.model.SendEmailResult;
+
+public class AmazonSESClientMock extends AmazonSimpleEmailServiceClient {
+    private SendEmailRequest sendEmailRequest;
+
+    public AmazonSESClientMock() {
+        super(new BasicAWSCredentials("myAccessKey", "mySecretKey"));
+    }
+
+    @Override
+    public SendEmailResult sendEmail(SendEmailRequest sendEmailRequest) throws AmazonServiceException, AmazonClientException {
+        this.sendEmailRequest = sendEmailRequest;
+        SendEmailResult result = new SendEmailResult();
+        result.setMessageId("1");
+        
+        return result;
+    }
+
+    public SendEmailRequest getSendEmailRequest() {
+        return sendEmailRequest;
+    }
+}

Added: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesIntegrationTest.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesIntegrationTest.java (added)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesIntegrationTest.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.osgi.aws;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.aws.ses.SesConstants;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
+
+@RunWith(JUnit4TestRunner.class)
+@Ignore("Must be manually tested. Provide your own accessKey and secretKey in CamelIntegrationContext.xml!")
+public class AwsSesIntegrationTest extends AwsTestSupport {
+    
+    @Override
+    protected OsgiBundleXmlApplicationContext createApplicationContext() {
+        return new OsgiBundleXmlApplicationContext(
+                new String[]{"org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml"});
+    }
+    
+    @Test
+    public void sendInOnly() throws Exception {
+        Exchange exchange = template.send("direct:start-ses", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertNotNull(exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+    }
+    
+    @Test
+    public void sendInOut() throws Exception {
+        Exchange exchange = template.request("direct:start-ses", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertNotNull(exchange.getOut().getHeader(SesConstants.MESSAGE_ID));
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesTest.java?rev=1220379&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesTest.java (added)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSesTest.java Sun Dec 18 12:19:26 2011
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.osgi.aws;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.aws.ses.SesConstants;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
+
+@RunWith(JUnit4TestRunner.class)
+public class AwsSesTest extends AwsTestSupport {
+    
+    @Override
+    protected OsgiBundleXmlApplicationContext createApplicationContext() {
+        return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/aws/CamelContext.xml"});
+    }
+    
+    @Test
+    public void sendInOnly() throws Exception {
+        Exchange exchange = template.send("direct:start-ses", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertEquals("1", exchange.getIn().getHeader(SesConstants.MESSAGE_ID));
+    }
+    
+    @Test
+    public void sendInOut() throws Exception {
+        Exchange exchange = template.request("direct:start-ses", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("This is my message text.");
+            }
+        });
+        
+        assertEquals("1", exchange.getOut().getHeader(SesConstants.MESSAGE_ID));
+    }
+}
\ No newline at end of file

Modified: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelContext.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelContext.xml?rev=1220379&r1=1220378&r2=1220379&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelContext.xml (original)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelContext.xml Sun Dec 18 12:19:26 2011
@@ -45,6 +45,11 @@
             <from uri="aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&amp;maxMessagesPerPoll=5"/>
             <to uri="mock:result-s3"/>
         </route>
+        
+        <route>
+            <from uri="direct:start-ses"/>
+            <to uri="aws-ses://from@example.com?amazonSESClient=#amazonSESClient"/>
+        </route>
     </camelContext>
 
     <bean id="amazonSQSClient" class="org.apache.camel.itest.osgi.aws.AmazonSQSClientMock"/>
@@ -52,4 +57,6 @@
     <bean id="amazonSNSClient" class="org.apache.camel.itest.osgi.aws.AmazonSNSClientMock"/>
     
     <bean id="amazonS3Client" class="org.apache.camel.itest.osgi.aws.AmazonS3ClientMock"/>
+    
+    <bean id="amazonSESClient" class="org.apache.camel.itest.osgi.aws.AmazonSESClientMock"/>
 </beans>
\ No newline at end of file

Modified: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml?rev=1220379&r1=1220378&r2=1220379&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml (original)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml Sun Dec 18 12:19:26 2011
@@ -45,5 +45,10 @@
             <from uri="aws-s3://mycamelbucket?accessKey=xxx&amp;secretKey=yyy&amp;maxMessagesPerPoll=5"/>
             <to uri="mock:result-s3"/>
         </route>
+        
+        <route>
+            <from uri="direct:start-ses"/>
+            <to uri="aws-ses://from@example.com?accessKey=xxx&amp;secretKey=yyy"/>
+        </route>
     </camelContext>
 </beans>
\ No newline at end of file