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
------
diff --git a/pom.xml b/pom.xml
index a6080f7..4f2c022 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
net.kemitix
wiser-assertions
- 0.3.0
+ 0.3.1
jar
wiser-assertions
@@ -31,7 +31,7 @@
net.kemitix
kemitix-parent
- 0.6.1
+ 0.7.1
@@ -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/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();
}
diff --git a/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java b/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java
index 675bbfa..cea04a6 100644
--- a/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java
+++ b/src/test/java/net/kemitix/wiser/assertions/AbstractWiserTest.java
@@ -56,8 +56,8 @@ 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);
- Session session = Session.getDefaultInstance(properties);
+ properties.setProperty("mail.smtp.port", "" + PORT);
+ Session session = Session.getInstance(properties);
return session;
}
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..72296a8
--- /dev/null
+++ b/src/test/java/net/kemitix/wiser/assertions/Issue6Test.java
@@ -0,0 +1,38 @@
+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().from("bob@a.com").to("carl@b.com")
+ .withSubject("Subject")
+ .withContentContains("Hi Carl");
+ }
+
+}