From b9c6226245a09b8466384458f7b232e3193fe1d1 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 25 Jan 2016 13:28:47 +0000 Subject: [PATCH 1/9] pom.xml: version set to 0.4.0-SNAPSHOT Signed-off-by: Paul Campbell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6080f7..d9975b3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.kemitix wiser-assertions - 0.3.0 + 0.4.0-SNAPSHOT jar wiser-assertions From 6b7ea83051fab8958460f9661723508c06f48f89 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 21:42:27 +0000 Subject: [PATCH 2/9] pom.xml: Upgrade kemitix-parent to 0.7.1 Signed-off-by: Paul Campbell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d9975b3..b68ede7 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ net.kemitix kemitix-parent - 0.6.1 + 0.7.1 From 311eda0299975b312706936f7e2054a136ee7af2 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 22:26:31 +0000 Subject: [PATCH 3/9] Issue6Test: add regression test for issue 6 Signed-off-by: Paul Campbell --- pom.xml | 8 ++++- .../kemitix/wiser/assertions/Issue6Test.java | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/test/java/net/kemitix/wiser/assertions/Issue6Test.java diff --git a/pom.xml b/pom.xml index b68ede7..ad634cd 100644 --- a/pom.xml +++ b/pom.xml @@ -57,12 +57,18 @@ 1.10.19 test - + org.codemonkey.simplejavamail simple-java-mail 2.5.1 test + + org.springframework + spring-context-support + 4.2.4.RELEASE + test + diff --git a/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java b/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java new file mode 100644 index 0000000..26329e2 --- /dev/null +++ b/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java @@ -0,0 +1,36 @@ +package net.kemitix.wiser.assertions; + +import org.junit.Test; + +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSenderImpl; + +/** + * Regression test for issue #6. + * + * @see https://github.com/kemitix/wiser-assertions/issues/6 + * @author pcampbell + */ +public class Issue6Test extends AbstractWiserTest { + + /** + * Test {@link WiserAssertions#withContentContains(String)} where the + * message is a Spring Mail {@link SimpleMailMessage}. + */ + @Test + public void shouldMatchContentContainsFromSimpleMailMessage() { + //given + SimpleMailMessage message = new SimpleMailMessage(); + message.setTo("Carl "); + message.setFrom("Bob "); + message.setSubject("Subject"); + message.setText("Hi Carl,\n\nA new message was just posted."); + final JavaMailSenderImpl sender = new JavaMailSenderImpl(); + sender.setPort(PORT); + //when + sender.send(message); + //then + getAssertions().withContentContains("Hi Carl"); + } + +} From a11b2fcdd452a9cebf8ce6c5408368c0cbc339e3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 22:51:31 +0000 Subject: [PATCH 4/9] Issue6Test: assert from, to and withSubject to match submitted issue Signed-off-by: Paul Campbell --- src/test/java/net/kemitix/wiser/assertions/Issue6Test.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java b/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java index 26329e2..72296a8 100644 --- a/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java +++ b/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java @@ -30,7 +30,9 @@ public class Issue6Test extends AbstractWiserTest { //when sender.send(message); //then - getAssertions().withContentContains("Hi Carl"); + getAssertions().from("bob@a.com").to("carl@b.com") + .withSubject("Subject") + .withContentContains("Hi Carl"); } } From 06c48f444433a5e3bff4da370d0a13f9b3b8632e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 22:52:21 +0000 Subject: [PATCH 5/9] AbstractWiserTest: fix refactoring artifact and use constant directly Signed-off-by: Paul Campbell --- .../java/net/kemitix/wiser/assertions/AbstractWiserTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java b/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java index 675bbfa..5679d74 100644 --- a/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java +++ b/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java @@ -56,7 +56,7 @@ public abstract class AbstractWiserTest { Properties properties = new Properties(); properties.setProperty("mail.transport.protocol", "smtp"); properties.setProperty("mail.smtp.host", "localhost"); - properties.setProperty("mail.smtp.port", "" + WiserAssertionsTest.PORT); + properties.setProperty("mail.smtp.port", "" + PORT); Session session = Session.getDefaultInstance(properties); return session; } From 146f53e404a8ccea5c44ef753e603f6b9b02a868 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 22:53:44 +0000 Subject: [PATCH 6/9] AbstractWiserTest: always create a new Session for each test Otherwise properties are ignored on subsequent calls. Signed-off-by: Paul Campbell --- .../java/net/kemitix/wiser/assertions/AbstractWiserTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java b/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java index 5679d74..cea04a6 100644 --- a/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java +++ b/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java @@ -57,7 +57,7 @@ public abstract class AbstractWiserTest { properties.setProperty("mail.transport.protocol", "smtp"); properties.setProperty("mail.smtp.host", "localhost"); properties.setProperty("mail.smtp.port", "" + PORT); - Session session = Session.getDefaultInstance(properties); + Session session = Session.getInstance(properties); return session; } From eff6e6c0b3874c32d9bfbb4f23cd29347552b437 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 22:55:38 +0000 Subject: [PATCH 7/9] WiserAssertions.getMimeMessageBody: accept that content may be a String Spring's SimpleMailMessage doesn't wrap it's email body in a mime content type as it is just a 'simple' mail message. Signed-off-by: Paul Campbell --- .../java/net/kemitix/wiser/assertions/WiserAssertions.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 07d0c56..920adc5 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -181,6 +181,9 @@ public final class WiserAssertions { private String getMimeMessageBody(final WiserMessage message) throws IOException, MessagingException { Object content = getMimeMessage(message).getContent(); + if (content instanceof String) { + return (String) content; + } if (content instanceof MimeMessage) { return content.toString(); } From 02c78852afc36ebfe314a657b07cbfaf7ffd823a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 23:11:31 +0000 Subject: [PATCH 8/9] pom.xml: version set to 0.3.1 Signed-off-by: Paul Campbell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ad634cd..4f2c022 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.kemitix wiser-assertions - 0.4.0-SNAPSHOT + 0.3.1 jar wiser-assertions From 3e7d686f3c037d1f42602c821fff1e4b7a94f338 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Feb 2016 23:11:31 +0000 Subject: [PATCH 9/9] CHANGELOG Signed-off-by: Paul Campbell --- CHANGELOG | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6e97675..4e6deca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ CHANGELOG ========= +0.3.1 +------ + +* Add support for Spring Mail's SimpleMailMessage [fixes #6] +* Upgrade kemitix-parent to 0.7.1 + 0.3.0 ------