diff --git a/samples/mail-ses-integration/README.md b/samples/mail-ses-integration/README.md new file mode 100644 index 0000000..667fb78 --- /dev/null +++ b/samples/mail-ses-integration/README.md @@ -0,0 +1,4 @@ +AWS SES Spring Integration Sample +========================= + + diff --git a/samples/mail-ses-integration/pom.xml b/samples/mail-ses-integration/pom.xml new file mode 100644 index 0000000..56cb721 --- /dev/null +++ b/samples/mail-ses-integration/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + org.springframework.integration.samples + mail-ses-integration + AWS SES Mail Demo + 1.0.0.BUILD-SNAPSHOT + + + 2.2.1 + + + + UTF-8 + 2.2.0.RELEASE + 1.2.17 + 4.10 + + + + org.springframework.integration + spring-integration-mail + ${spring.integration.version} + + + org.springframework.integration + spring-integration-test + ${spring.integration.version} + + + org.springframework.integration + spring-integration-aws + 0.5.0.BUILD-SNAPSHOT + + + log4j + log4j + ${log4j.version} + + + + junit + junit + ${junit.version} + test + + + org.subethamail + subethasmtp-wiser + 1.2 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.6 + 1.6 + -Xlint:all + true + true + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + org.springframework.integration.samples.mailses.Main + + + + + + + repo.springsource.org.milestone + SpringSource Maven Milestone Repository + https://repo.springsource.org/libs-milestone + + + \ No newline at end of file diff --git a/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/EmailService.java b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/EmailService.java new file mode 100644 index 0000000..a3a4050 --- /dev/null +++ b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/EmailService.java @@ -0,0 +1,24 @@ +package org.springframework.integration.samples.mailses; + +import org.springframework.integration.annotation.Header; +import org.springframework.integration.annotation.Payload; +import org.springframework.integration.mail.MailHeaders; + +public interface EmailService { + + + void send( + + @Header(MailHeaders.FROM) + String fromEmail, + + @Header(MailHeaders.TO) + String toEmail, + + @Header(MailHeaders.SUBJECT) + String subject, + + @Payload + String body); + +} diff --git a/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/Main.java b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/Main.java new file mode 100644 index 0000000..7972880 --- /dev/null +++ b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/Main.java @@ -0,0 +1,101 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed 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.springframework.integration.samples.mailses; + +import java.util.Scanner; + +import org.apache.log4j.Logger; +import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.core.env.ConfigurableEnvironment; + +/** + * Starts the Spring Context and will initialize the Spring Integration routes. + * + * @author Gunnar Hillert + * @since 1.0 + * + */ +public final class Main { + + private static final Logger LOGGER = Logger.getLogger(Main.class); + + private static final String HORIZONTAL_LINE = "\n========================================================="; + + private Main() { + } + + /** + * Load the Spring Integration Application Context + * + * @param args - command line arguments + */ + public static void main(final String... args) { + + final Scanner scanner = new Scanner(System.in); + + LOGGER.info(HORIZONTAL_LINE + "\n" + + "\n Welcome to Spring Integration! " + + "\n" + + "\n For more information please visit: " + + "\n http://www.springsource.org/spring-integration " + + "\n" + HORIZONTAL_LINE); + + final GenericXmlApplicationContext context = new GenericXmlApplicationContext(); + final ConfigurableEnvironment environment = context.getEnvironment(); + + final String fromEmailAddress; + final String toEmailAddress; + final String subject; + final String body; + + System.out.print("\nFrom which email address would you like to send a message?: "); + fromEmailAddress = scanner.nextLine(); + + System.out.print("To which email address would you like to send a message?: "); + toEmailAddress = scanner.nextLine(); + + System.out.print("What is the subject line?: "); + subject = scanner.nextLine(); + + System.out.print("What is the body of the message?: "); + body = scanner.nextLine(); + + if (!environment.containsProperty("accessKey")) { + System.out.print("Please enter your access key: "); + final String accessKey = scanner.nextLine(); + environment.getSystemProperties().put("accessKey", accessKey); + } + + if (!environment.containsProperty("secretKey")) { + System.out.print("Please enter your secret key: "); + final String secretKey = scanner.nextLine(); + environment.getSystemProperties().put("secretKey", secretKey); + } + + context.load("classpath:META-INF/spring/integration/*-context.xml"); + context.registerShutdownHook(); + context.refresh(); + + final EmailService emailService = context.getBean(EmailService.class); + + emailService.send(fromEmailAddress, toEmailAddress, subject, body); + + System.out.println(String.format("The email to '%s' was sent successfully.", toEmailAddress)); + + System.exit(0); + + } +} diff --git a/samples/mail-ses-integration/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/samples/mail-ses-integration/src/main/resources/META-INF/spring/integration/spring-integration-context.xml new file mode 100644 index 0000000..81623df --- /dev/null +++ b/samples/mail-ses-integration/src/main/resources/META-INF/spring/integration/spring-integration-context.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/samples/mail-ses-integration/src/main/resources/log4j.xml b/samples/mail-ses-integration/src/main/resources/log4j.xml new file mode 100644 index 0000000..364cd81 --- /dev/null +++ b/samples/mail-ses-integration/src/main/resources/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/mail-ses/README.md b/samples/mail-ses/README.md new file mode 100644 index 0000000..35a1138 --- /dev/null +++ b/samples/mail-ses/README.md @@ -0,0 +1,5 @@ +AWS SES MailSender sample +========================= + +This sample uses a Spring-provided *JavaMailSender* to send emails. This application demonstrates that by only replacing the *JavaMailSender* XML bean declaration with the *DefaultAmazonSESMailSender*, existing applications can send emails using Amazon SES without changing application code. The *DefaultAmazonSESMailSender* is provided by the *Spring Integration Extensions AWS Module*. + diff --git a/samples/mail-ses/pom.xml b/samples/mail-ses/pom.xml new file mode 100644 index 0000000..a0eae15 --- /dev/null +++ b/samples/mail-ses/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + org.springframework.integration.samples + mail-ses + AWS SES Mail Demo + 1.0.0.BUILD-SNAPSHOT + + + 2.2.1 + + + + UTF-8 + 2.2.0.RELEASE + 1.2.17 + 4.10 + + + + org.springframework.integration + spring-integration-mail + ${spring.integration.version} + + + org.springframework.integration + spring-integration-test + ${spring.integration.version} + + + org.springframework.integration + spring-integration-aws + 0.5.0.BUILD-SNAPSHOT + + + log4j + log4j + ${log4j.version} + + + + junit + junit + ${junit.version} + test + + + org.subethamail + subethasmtp-wiser + 1.2 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.6 + 1.6 + -Xlint:all + true + true + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + org.springframework.integration.samples.mailses.Main + + + + + + + repo.springsource.org.milestone + SpringSource Maven Milestone Repository + https://repo.springsource.org/libs-milestone + + + \ No newline at end of file diff --git a/samples/mail-ses/src/main/java/org/springframework/integration/samples/mailses/Main.java b/samples/mail-ses/src/main/java/org/springframework/integration/samples/mailses/Main.java new file mode 100644 index 0000000..2712acf --- /dev/null +++ b/samples/mail-ses/src/main/java/org/springframework/integration/samples/mailses/Main.java @@ -0,0 +1,165 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed 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.springframework.integration.samples.mailses; + +import java.util.List; +import java.util.Scanner; + +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; + +import org.apache.log4j.Logger; +import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.mail.MailException; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessagePreparator; +import org.subethamail.wiser.Wiser; +import org.subethamail.wiser.WiserMessage; + +/** + * Starts the Spring Context and will initialize the Spring Integration routes. + * + * @author Gunnar Hillert + * @since 2.2 + * + */ +public final class Main { + + private static final Logger LOGGER = Logger.getLogger(Main.class); + + private static final String HORIZONTAL_LINE = "\n========================================================="; + + private Main() { + } + + /** + * Load the Spring Integration Application Context + * + * @param args - command line arguments + */ + public static void main(final String... args) { + + final Scanner scanner = new Scanner(System.in); + + LOGGER.info(HORIZONTAL_LINE + "\n" + + "\n Welcome to Spring Integration! " + + "\n" + + "\n For more information please visit: " + + "\n http://www.springsource.org/spring-integration " + + "\n" + HORIZONTAL_LINE); + + System.out.println("Please enter a choice and press : "); + System.out.println("\t1. Use Embedded SMTP Server (Wiser)"); + System.out.println("\t2. Use Amazon SES"); + + System.out.println("\tq. Quit the application"); + System.out.print("Enter your choice: "); + + final GenericXmlApplicationContext context = new GenericXmlApplicationContext(); + final ConfigurableEnvironment environment = context.getEnvironment(); + + boolean usingWiser = false; + + String toEmailAddress; + + while (true) { + final String input = scanner.nextLine(); + + if("1".equals(input.trim())) { + environment.setActiveProfiles("default"); + usingWiser = true; + + System.out.print("\nTo which email address would you like to send a message?: "); + toEmailAddress = scanner.nextLine(); + + break; + } else if("2".equals(input.trim())) { + environment.setActiveProfiles("aws"); + + if (!environment.containsProperty("accessKey")) { + System.out.print("\nPlease enter your access key: "); + final String accessKey = scanner.nextLine(); + environment.getSystemProperties().put("accessKey", accessKey); + } + + if (!environment.containsProperty("secretKey")) { + System.out.print("\nPlease enter your secret key: "); + final String secretKey = scanner.nextLine(); + environment.getSystemProperties().put("secretKey", secretKey); + } + System.out.print("\nTo which email address would you like to send a message?: "); + toEmailAddress = scanner.nextLine(); + + break; + } else if("q".equals(input.trim())) { + System.out.println("Exiting application...bye."); + System.exit(0); + } else { + System.out.println("Invalid choice\n\n"); + System.out.print("Enter you choice: "); + } + } + + context.load("classpath:META-INF/spring/integration/*-context.xml"); + context.registerShutdownHook(); + context.refresh(); + + final JavaMailSender ms = context.getBean(JavaMailSender.class); + final String toEmailAddressToUse = toEmailAddress; + final MimeMessagePreparator preparator = new MimeMessagePreparator() { + + public void prepare(MimeMessage mimeMessage) throws Exception { + + mimeMessage.setRecipient(Message.RecipientType.TO, + new InternetAddress(toEmailAddressToUse)); + mimeMessage.setFrom(new InternetAddress(toEmailAddressToUse)); + mimeMessage.setSubject("Testing Email - Subject"); + mimeMessage.setText("Hello World"); + } + + }; + + try { + ms.send(preparator); + } catch (MailException e) { + throw new IllegalStateException(e); + } + + System.out.println(String.format("The email to '%s' was sent successfully.", toEmailAddress)); + + if (usingWiser) { + Wiser wiser = context.getBean(Wiser.class); + List messages = wiser.getMessages(); + + final String from; + final String subject; + try { + from = messages.get(0).getMimeMessage().getFrom()[0].toString(); + subject = messages.get(0).getMimeMessage().getSubject(); + } catch (MessagingException e) { + throw new IllegalStateException(e); + } + + System.out.println(String.format("Wiser received an email from '%s' with subject '%s'", from, subject)); + } + + System.exit(0); + + } +} diff --git a/samples/mail-ses/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/samples/mail-ses/src/main/resources/META-INF/spring/integration/spring-integration-context.xml new file mode 100644 index 0000000..5d35a49 --- /dev/null +++ b/samples/mail-ses/src/main/resources/META-INF/spring/integration/spring-integration-context.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/mail-ses/src/main/resources/log4j.xml b/samples/mail-ses/src/main/resources/log4j.xml new file mode 100644 index 0000000..364cd81 --- /dev/null +++ b/samples/mail-ses/src/main/resources/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-integration-aws/README.md b/spring-integration-aws/README.md index e091601..9ffaec4 100644 --- a/spring-integration-aws/README.md +++ b/spring-integration-aws/README.md @@ -1,18 +1,16 @@ Spring Integration Extension for Amazon Web Services (AWS) ========================================================== +# Introduction +## Amazon Web Services (AWS) -##Small Introduction to Amazon Web Services (AWS) +Launched in 2006, [Amazon Web Services][] (AWS) provides key infrastructure services for business through its cloud computing platform. Using cloud computing businesses can adopt a new business model whereby they do not have to plan and invest in procuring their own IT infrastructure. They can use the infrastructure and services provided by the cloud service provider and pay as they use the services. Visit [http://aws.amazon.com/products/] for more details about various products offered by Amazon as a part their cloud computing services. +*Spring Integration Extension for Amazon Web Services* provides Spring Integration adapters for the various services provided by the [AWS SDK for Java][]. -Launched in 2006, Amazon Web Services (AWS) started providing key infrastructure for business as web services, which, also known as cloud computing. Using cloud computing businesses can adopt a new business model whereby they do not have to plan and invest in procuring their own IT infrastructure. They can use the infrastructure and services provided by the cloud service provider and pay as they use the services. -Visit [http://aws.amazon.com/products/] for more details about various products offered by Amazon as a part their cloud computing services. +## Spring Integration's extensions to AWS -##Introduction to Spring Integration's extensions to AWS - -This guide intends to explain in brief about various adapters available for the AWS and sample xml tag definition for each of them and code snippets wherever necessary, - -The library aims to provide adapters for following AWS Services +This guide intends to explain briefly the various adapters available for [Amazon Web Services][] such as: * **Amazon Simple Email Service (SES)** * **Amazon Simple Storage Service (S3)** (Development complete, coming soon) @@ -21,35 +19,27 @@ The library aims to provide adapters for following AWS Services * **Amazon SimpleDB** (Not initiated) * **Amazon SNS** (Not initiated) -Of the above libraries, SES and SNS have outbound adapters only. All other -services have inbound and outbound adapters. The SQS inbound adapter is capable of receiving notifications sent out from SNS where the topic is an SQS Queue. -For DymamoDB and SimpleDB, apart from inbound and outbound adapters we shall provide a *MessageStore* implementation too. +Sample XML Namespace configurations for each adapter as well as sample code snippets are provided wherever necessary. Of the above libraries, *SES* and *SNS* provide outbound adapters only. All other services have inbound and outbound adapters. The *SQS* inbound adapter is capable of receiving notifications sent out from *SNS* where the topic is an *SQS* Queue. +For *DymamoDB* and *SimpleDB*, besides providing *Inbound*- and *Outbound Adapters*, a *MessageStore* implementation is provided, too. -###Executing the test cases. +# Executing the test cases. -All the test cases for the adapters are present in the *src/test/java* folder. On executing the build, maven's surefire plugin will execute all -the tests. Please note that all the tests ending with **AWSTests.java* connect -to the actual webservices and are excluded by default in the maven build. -All other tests rely on mocking to test the functionality. You need to execute the **AWSTests.java* -explicitly, manually to test the conectivity to AWS using your credentials. -All these **AWSTests.java* tests look for the file *awscredentials.properties* in the classpath. -To be on the safer side create one at location *src/test/resources* as this file -*spring-integration-aws/src/test/resources/awscredentials.properties* is added to *.gitignore* file. -This will prevent this file to be checked in accidently and revealing your credentials. -This file needs to have two properties *accessKey* and *secretKey* holding the values of your access key and secret key respectively. -> **Note: AWS Services are chargeable and we recommend not to execute the **AWSTests.java* as part of your regular builds. -AWS does provide a free tier which is sufficient to perform your tests without being -charged (not true for DynamoDB though), however keep a check on your account usage regularly. -Get more information about AWS free tier at [http://aws.amazon.com/free/][]** +All test cases for the adapters are present in the *src/test/java* folder. On executing the build, maven's surefire plugin will execute all the tests. +> Please note that all the tests ending with **AWSTests.java* connect to the actual [Amazon Web Services][] and are excluded by default in the maven build. All other tests rely on mocking to test the functionality. You need to execute the **AWSTests.java* manually to test the connectivity to AWS using your credentials. +All these **AWSTests.java* tests look for the file *awscredentials.properties* in the classpath. To be on the safe side, create the following file at *src/test/resources*: +*spring-integration-aws/src/test/resources/awscredentials.properties*. It is added to the *.gitignore* file by default. This will prevent this file to be checked in accidentally and revealing your credentials. + +This file needs to have two properties *accessKey* and *secretKey*, holding the values of your access key and secret key respectively. + +> **Note: AWS Services are chargeable and we recommend not to execute the **AWSTests.java* as part of your regular builds. AWS does provide a free tier which is sufficient to perform your tests without being charged (not true for DynamoDB though), however keep a check on your account usage regularly. Get more information about AWS free tier at [http://aws.amazon.com/free/][]** #Adapters ##Simple Email Service (SES) - ###Introduction Amazon Simple Email Service (SES) is a web service for sending emails from the cloud. It supports two types of mails currently, the simple mail and raw email. @@ -134,7 +124,8 @@ We shall now see a java code snippet to send a mail using the SNS adapter The messages over this channel are consumed by the outbound SES adapter and the mail is sent out using SES. - +[AWS SDK for Java]: http://aws.amazon.com/sdkforjava/ +[Amazon Web Services]: http://aws.amazon.com/ [http://aws.amazon.com/products/]: http://aws.amazon.com/products/ [http://aws.amazon.com/ses/]: http://aws.amazon.com/ses/ [http://aws.amazon.com/documentation/ses/]: http://aws.amazon.com/documentation/ses/ diff --git a/spring-integration-aws/pom.xml b/spring-integration-aws/pom.xml index b868095..6e58330 100644 --- a/spring-integration-aws/pom.xml +++ b/spring-integration-aws/pom.xml @@ -1,28 +1,29 @@ - - 4.0.0 - org.springframework.integration - spring-integration-aws - 1.0.0.BUILD-SNAPSHOT - Spring Integration Amazon Web Services Support - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - + + 4.0.0 + org.springframework.integration + spring-integration-aws + 0.5.0.BUILD-SNAPSHOT + Spring Integration Amazon Web Services Support + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + 2.2.1 - 2.2.0.RELEASE - 3.1.3.RELEASE - 1.3.12 - 1.5 + 2.2.0.RELEASE + 3.1.3.RELEASE + 1.3.12 + 1.5 1.1.1 2.0.1 1.4.4 @@ -34,190 +35,189 @@ UTF8 - - - - src/main/java - - **/* - - - **/*.java - - - - src/main/resources - - **/* - - - - - - src/test/java - - **/* - - - **/*.java - - - - src/test/resources - - **/* - - - - - - maven-compiler-plugin - - 1.6 - 1.6 - - - - maven-surefire-plugin - - - **/*Tests.java - - - **/*Abstract*.java - **/*AWSTests.java - - - - - - - - springsource-libs-milestone - Spring Framework Maven Milestone Repository - https://repo.springsource.org/libs-milestone - - - - - com.amazonaws - aws-java-sdk - ${aws.sdk.version} - compile - + + + + src/main/java + + **/* + + + **/*.java + + + + src/main/resources + + **/* + + + + + + src/test/java + + **/* + + + **/*.java + + + + src/test/resources + + **/* + + + + + + maven-compiler-plugin + + 1.6 + 1.6 + + + + maven-surefire-plugin + + + **/*Tests.java + + + **/*Abstract*.java + **/*AWSTests.java + + + + + + + + springsource-libs-milestone + Spring Framework Maven Milestone Repository + https://repo.springsource.org/libs-milestone + + + + + com.amazonaws + aws-java-sdk + ${aws.sdk.version} + compile + - - commons-codec - commons-codec - ${commons.codec.version} - compile - + + commons-codec + commons-codec + ${commons.codec.version} + compile + - - commons-logging - commons-logging - ${commons.logging.version} - compile - + + commons-logging + commons-logging + ${commons.logging.version} + compile + - - commons-io - commons-io - ${commons.io.version} - compile - + + commons-io + commons-io + ${commons.io.version} + compile + - - javax.mail - mail - ${java.mail.version} - compile - + + javax.mail + mail + ${java.mail.version} + compile + - - org.springframework.integration - spring-integration-core - ${spring.integration.version} - compile - + + org.springframework.integration + spring-integration-core + ${spring.integration.version} + compile + - - org.springframework.integration - spring-integration-mail - ${spring.integration.version} - compile - + + org.springframework.integration + spring-integration-mail + ${spring.integration.version} + provided + + + org.codehaus.jackson + jackson-core-asl + ${jackson.version} + compile + - - org.codehaus.jackson - jackson-core-asl - ${jackson.version} - compile - + + org.codehaus.jackson + jackson-mapper-asl + ${jackson.version} + compile + - - org.codehaus.jackson - jackson-mapper-asl - ${jackson.version} - compile - + + org.apache.httpcomponents + httpclient + ${apache.httpclient.version} + compile + - - org.apache.httpcomponents - httpclient - ${apache.httpclient.version} - compile - + + org.apache.httpcomponents + httpcore + ${apache.httpclient.version} + compile + - - org.apache.httpcomponents - httpcore - ${apache.httpclient.version} - compile - + + org.springframework.integration + spring-integration-test + ${spring.integration.version} + test + - - org.springframework.integration - spring-integration-test - ${spring.integration.version} - test - + + org.hamcrest + hamcrest-core + ${hamcrest.version} + test + - - org.hamcrest - hamcrest-core - ${hamcrest.version} - test - + + junit + junit + ${junit.version} + test + - - junit - junit - ${junit.version} - test - + + org.mockito + mockito-all + ${mockito.version} + test + - - org.mockito - mockito-all - ${mockito.version} - test - + + org.mockito + mockito-core + ${mockito.version} + test + - - org.mockito - mockito-core - ${mockito.version} - test - + + org.springframework + spring-test + ${spring.test.version} + test + - - org.springframework - spring-test - ${spring.test.version} - test - - - + diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java index 044e702..5894d8c 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java @@ -23,7 +23,7 @@ import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHa * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AWSNamespaceHandler extends diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java index 3ea2a57..3a1d848 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java @@ -29,7 +29,7 @@ import org.w3c.dom.Element; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public abstract class AbstractAWSOutboundChannelAdapterParser extends diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java index 974550e..d8f0f34 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java @@ -28,7 +28,7 @@ import org.w3c.dom.Element; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public final class AmazonWSParserUtils { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java index 1c74cbe..c76216f 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java @@ -23,7 +23,7 @@ import com.amazonaws.AmazonWebServiceClient; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public interface AWSClientFactory { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java index 664f231..3ae05ef 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java @@ -20,7 +20,7 @@ package org.springframework.integration.aws.core; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public interface AWSCredentials { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java index 1b9035d..70c2df8 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java @@ -20,7 +20,7 @@ package org.springframework.integration.aws.core; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AWSOperationException extends RuntimeException { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java index e630607..6cc42ee 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java @@ -34,7 +34,7 @@ import com.amazonaws.AmazonWebServiceClient; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public abstract class AbstractAWSClientFactory implements AWSClientFactory { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java index 69cebea..30fe0cb 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java @@ -15,13 +15,15 @@ */ package org.springframework.integration.aws.core; +import org.springframework.util.Assert; + /** * The basic implementation class holding the Access key and the secret * key for the AWS account . * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class BasicAWSCredentials implements AWSCredentials { @@ -45,12 +47,15 @@ public class BasicAWSCredentials implements AWSCredentials { } /**. - * The constructor accepting the access and secret key - * @param accessKey - * @param secretKey + * The constructor accepting the access and secret key. + * + * @param accessKey Must not be null or empty + * @param secretKey Must not be null or empty */ public BasicAWSCredentials(String accessKey, String secretKey) { - super(); + Assert.hasText(accessKey, "The accessKey parameter must not be null or empty."); + Assert.hasText(secretKey, "The secretKey parameter must not be null or empty."); + this.accessKey = accessKey; this.secretKey = secretKey; } @@ -68,6 +73,7 @@ public class BasicAWSCredentials implements AWSCredentials { * @param accessKey */ public void setAccessKey(String accessKey) { + Assert.hasText(accessKey, "The accessKey parameter must not be null or empty."); this.accessKey = accessKey; } @@ -84,6 +90,7 @@ public class BasicAWSCredentials implements AWSCredentials { * @param secretKey */ public void setSecretKey(String secretKey) { + Assert.hasText(secretKey, "The secretKey parameter must not be null or empty."); this.secretKey = secretKey; } } diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java index 408c916..5abde9f 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java @@ -20,7 +20,7 @@ package org.springframework.integration.aws.core; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class InvalidAWSCredentialsException extends RuntimeException { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java index 2f2ef39..567efa2 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java @@ -21,6 +21,7 @@ import java.util.Properties; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; @@ -30,7 +31,7 @@ import org.springframework.util.StringUtils; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class PropertiesAWSCredentials extends BasicAWSCredentials implements InitializingBean { @@ -44,11 +45,13 @@ public class PropertiesAWSCredentials extends BasicAWSCredentials implements Ini private String propertyFileName; /**. - * Constructor accepting the properties file - * @param propertyFileName + * Constructor accepting the properties file. + * + * @param propertyFileName Must not be null or empty */ public PropertiesAWSCredentials(String propertyFileName) { super(); + Assert.hasText(propertyFileName, "The propertyFileName parameter must not be null or empty."); this.propertyFileName = propertyFileName; } @@ -95,10 +98,12 @@ public class PropertiesAWSCredentials extends BasicAWSCredentials implements Ini } /**. - * Sets the name of the file that will hold the AW credentials - * @param propertyFileName + * Sets the name of the file that will hold the AW credentials. + * + * @param propertyFileName Must not be null or empty */ public void setPropertyFileName(String propertyFileName) { + Assert.hasText(propertyFileName, "The propertyFileName parameter must not be null or empty."); this.propertyFileName = propertyFileName; } diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java index 0403c7d..9465d31 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java @@ -26,7 +26,7 @@ import org.springframework.mail.javamail.JavaMailSender; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AmazonSESMessageHandler extends MailSendingMessageHandler { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java index 8ea1cae..fdb3a68 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java @@ -25,7 +25,7 @@ import org.springframework.integration.core.MessageHandler; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AmazonSESOutboundAdapterParser extends diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java index a28018a..03bb6da 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java @@ -24,7 +24,7 @@ import org.springframework.integration.aws.core.AWSOperationException; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AmazonSESMailSendException extends AWSOperationException { diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSender.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSender.java index 9fdc60e..b44b716 100644 --- a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSender.java +++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSender.java @@ -15,94 +15,107 @@ */ package org.springframework.integration.aws.ses.core; -import java.io.ByteArrayOutputStream; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; +import java.io.InputStream; +import java.util.Properties; +import javax.mail.NoSuchProviderException; +import javax.mail.Session; +import javax.mail.Transport; import javax.mail.internet.MimeMessage; import org.springframework.integration.aws.core.AWSCredentials; import org.springframework.integration.aws.core.AWSOperationException; import org.springframework.mail.MailException; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.mail.javamail.MimeMessagePreparator; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; -import com.amazonaws.services.simpleemail.model.RawMessage; -import com.amazonaws.services.simpleemail.model.SendRawEmailRequest; +import com.amazonaws.services.simpleemail.AWSJavaMailTransport; /** * The implementation class for sending mail using the Amazon SES service * * @author Amol Nayak + * @author Gunnar Hillert * - * @since 1.0 + * @since 0.5 * */ -public class DefaultAmazonSESMailSender extends JavaMailSenderImpl { - - /**. - * The API class used for sending email using Amazon SES - */ - private final AmazonSimpleEmailServiceClient emailService; - - private final AWSCredentials credentials; +public class DefaultAmazonSESMailSender implements JavaMailSender { public DefaultAmazonSESMailSender(AWSCredentials credentials) { - if(credentials == null) + + if(credentials == null) { throw new AWSOperationException(null, "Credentials cannot be null, provide a non null valid set of credentials"); - this.credentials = credentials; + } + + /* + * Setup JavaMail to use the Amazon Simple Email Service by specifying + * the "aws" protocol. + */ + Properties properties = new Properties(); + properties.setProperty("mail.transport.protocol", "aws"); + + properties.setProperty(AWSJavaMailTransport.AWS_ACCESS_KEY_PROPERTY, credentials.getAccessKey()); + properties.setProperty(AWSJavaMailTransport.AWS_SECRET_KEY_PROPERTY, credentials.getSecretKey()); + + javaMailSender.setJavaMailProperties(properties); - emailService = new AmazonSimpleEmailServiceClient( - new BasicAWSCredentials(credentials.getAccessKey(), - credentials.getSecretKey())); } + private JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl() { + + @Override + protected Transport getTransport(Session session) + throws NoSuchProviderException { + return new AWSJavaMailTransport(session, null); + } + + }; - /** - * The Actual implementation of the sending of the mail message using the AWS SES - * SDK - */ @Override - protected void doSend(MimeMessage[] mimeMessages, Object[] originalMessages) + public void send(SimpleMailMessage simpleMessage) throws MailException { + javaMailSender.send(simpleMessage); + } + + @Override + public void send(SimpleMailMessage[] simpleMessages) throws MailException { + javaMailSender.send(simpleMessages); + } + + @Override + public MimeMessage createMimeMessage() { + return javaMailSender.createMimeMessage(); + } + + @Override + public MimeMessage createMimeMessage(InputStream contentStream) throws MailException { - Map failedMessageMap = new HashMap(); - if(mimeMessages != null && mimeMessages.length > 0) { - int index = 0; - for(MimeMessage mailMessage:mimeMessages) { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - mailMessage.writeTo(baos); - RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(baos.toByteArray())); - SendRawEmailRequest rawMail = new SendRawEmailRequest(rawMessage); - emailService.sendRawEmail(rawMail); - index++; - } catch (Exception e) { - failedMessageMap.put(originalMessages != null? originalMessages[index]:mailMessage, e); - } - } - } - - if(!failedMessageMap.isEmpty()) { - throw new AmazonSESMailSendException(credentials.getAccessKey(), - "Exception while sending one or more messages, see failedMessages for more details", - failedMessageMap); - } + return javaMailSender.createMimeMessage(contentStream); } @Override - public void setPort(int port) { - throw new UnsupportedOperationException("AWS SES Implementation of mail " + - "sender does not allow setting the port number"); + public void send(MimeMessage mimeMessage) throws MailException { + javaMailSender.send(mimeMessage); } - @Override - public void setHost(String host) { - throw new UnsupportedOperationException("AWS SES Implementation of mail " + - "sender does not allow setting the host name. It is already configured with an endpoint"); + public void send(MimeMessage[] mimeMessages) throws MailException { + javaMailSender.send(mimeMessages); + } + + @Override + public void send(MimeMessagePreparator mimeMessagePreparator) + throws MailException { + javaMailSender.send(mimeMessagePreparator); + + } + + @Override + public void send(MimeMessagePreparator[] mimeMessagePreparators) + throws MailException { + javaMailSender.send(mimeMessagePreparators); } - //Should we disallow setSession? } \ No newline at end of file diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/AWSClientFactoryTest.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/AWSClientFactoryTest.java index a3a44d5..8bbc2a5 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/AWSClientFactoryTest.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/AWSClientFactoryTest.java @@ -28,7 +28,7 @@ import com.amazonaws.services.sqs.AmazonSQSClient; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AWSClientFactoryTest { diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/BaseTestCase.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/BaseTestCase.java index 91e501b..74dc96e 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/BaseTestCase.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/common/BaseTestCase.java @@ -24,7 +24,7 @@ import java.util.Properties; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public abstract class BaseTestCase { diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParserTests.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParserTests.java index 62f2501..45fb3d7 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParserTests.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParserTests.java @@ -32,7 +32,7 @@ import org.springframework.integration.test.util.TestUtils; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public abstract class AbstractAWSOutboundChannelAdapterParserTests { diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/core/AbstractAWSClientFactoryTests.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/core/AbstractAWSClientFactoryTests.java index 1db3983..f3dece2 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/core/AbstractAWSClientFactoryTests.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/core/AbstractAWSClientFactoryTests.java @@ -30,7 +30,7 @@ import com.amazonaws.AmazonWebServiceClient; * The abstract test class for Amazon WebService client factory tests * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public abstract class AbstractAWSClientFactoryTests { diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/AmazonSESMessageHandlerTests.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/AmazonSESMessageHandlerTests.java index 8b3038b..f86a175 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/AmazonSESMessageHandlerTests.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/AmazonSESMessageHandlerTests.java @@ -48,7 +48,7 @@ import org.springframework.mail.javamail.JavaMailSender; * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AmazonSESMessageHandlerTests { diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParserTests.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParserTests.java index ce60ac1..9ea5e16 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParserTests.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParserTests.java @@ -15,22 +15,25 @@ */ package org.springframework.integration.aws.ses.config.xml; +import java.util.Properties; + import junit.framework.Assert; import org.junit.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.integration.aws.core.AWSCredentials; import org.springframework.integration.core.MessageHandler; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.test.util.TestUtils; +import com.amazonaws.services.simpleemail.AWSJavaMailTransport; + /** * The test class for the AmazonSESOutboundAdapterParser * * @author Amol Nayak * - * @since 1.0 + * @since 0.5 * */ public class AmazonSESOutboundAdapterParserTests { @@ -79,10 +82,11 @@ public class AmazonSESOutboundAdapterParserTests { Assert.assertNotNull("Expected a non null EventDrivenConsumer", consumer); MessageHandler handler = TestUtils.getPropertyValue(consumer, "handler", MessageHandler.class); Assert.assertNotNull("Expected a non null messagehandler", handler); - AWSCredentials credentials = TestUtils.getPropertyValue(handler, "mailSender.credentials", AWSCredentials.class); - Assert.assertNotNull("Expected a non null instance of credentials", credentials); - Assert.assertEquals("dummy", credentials.getAccessKey()); - Assert.assertEquals("dummy", credentials.getSecretKey()); + + Properties properties = TestUtils.getPropertyValue(handler, "mailSender.javaMailSender.javaMailProperties", Properties.class); + Assert.assertNotNull("Expected a non null instance of credentials", properties); + Assert.assertEquals("dummy", properties.getProperty(AWSJavaMailTransport.AWS_ACCESS_KEY_PROPERTY)); + Assert.assertEquals("dummy", properties.getProperty(AWSJavaMailTransport.AWS_SECRET_KEY_PROPERTY)); } /** diff --git a/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSenderAWSTests.java b/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSenderAWSTests.java index 95c703b..386e219 100644 --- a/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSenderAWSTests.java +++ b/spring-integration-aws/src/test/java/org/springframework/integration/aws/ses/core/DefaultAmazonSESMailSenderAWSTests.java @@ -15,7 +15,6 @@ */ package org.springframework.integration.aws.ses.core; -import javax.mail.Session; import javax.mail.internet.MimeMessage; import org.junit.BeforeClass; @@ -38,7 +37,7 @@ import org.springframework.mail.javamail.MimeMessageHelper; * * @author Amol Nayak * -* @since 1.0 +* @since 0.5 * */ public class DefaultAmazonSESMailSenderAWSTests { @@ -96,8 +95,7 @@ public class DefaultAmazonSESMailSenderAWSTests { */ @Test public void sendMimeMessage() throws Exception { - Session session = sender.getSession(); - MimeMessageHelper helper = new MimeMessageHelper(new MimeMessage(session)); + MimeMessageHelper helper = new MimeMessageHelper(sender.createMimeMessage()); helper.setText("Some HTML Text", true); helper.setTo(TO_EMAIL_ID); helper.setFrom(TO_EMAIL_ID); @@ -111,16 +109,15 @@ public class DefaultAmazonSESMailSenderAWSTests { */ @Test public void sendMimeMessageArray() throws Exception { - Session session = sender.getSession(); MimeMessage[] messages = new MimeMessage[2]; - MimeMessageHelper helper = new MimeMessageHelper(new MimeMessage(session)); + MimeMessageHelper helper = new MimeMessageHelper(sender.createMimeMessage()); helper.setText("Some HTML Text One", true); helper.setTo(TO_EMAIL_ID); helper.setFrom(TO_EMAIL_ID); helper.setSubject("Some HTML Message's Subject Line One"); MimeMessage message = helper.getMimeMessage(); messages[0] = message; - helper = new MimeMessageHelper(new MimeMessage(session)); + helper = new MimeMessageHelper(sender.createMimeMessage()); helper.setText("Some HTML Text Two", true); helper.setTo(TO_EMAIL_ID); helper.setFrom(TO_EMAIL_ID);