Merge branch release/0.3.1 into master

Add support for Spring Mail's SimpleMailMessage [fixes #6]
Upgrade kemitix-parent to 0.7.1

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
This commit is contained in:
Paul Campbell 2016-02-16 23:11:31 +00:00
commit 8d11da09e9
5 changed files with 58 additions and 5 deletions

View file

@ -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
------

12
pom.xml
View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.kemitix</groupId>
<artifactId>wiser-assertions</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<packaging>jar</packaging>
<name>wiser-assertions</name>
@ -31,7 +31,7 @@
<parent>
<groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId>
<version>0.6.1</version>
<version>0.7.1</version>
</parent>
<dependencies>
@ -57,12 +57,18 @@
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency><!-- for Issue1Test -->
<groupId>org.codemonkey.simplejavamail</groupId>
<artifactId>simple-java-mail</artifactId>
<version>2.5.1</version>
<scope>test</scope>
</dependency>
<dependency><!-- for Issue6Test -->
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.2.4.RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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 <carl@b.com>");
message.setFrom("Bob <bob@a.com>");
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");
}
}