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:
commit
8d11da09e9
5 changed files with 58 additions and 5 deletions
|
@ -1,6 +1,12 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.3.1
|
||||||
|
------
|
||||||
|
|
||||||
|
* Add support for Spring Mail's SimpleMailMessage [fixes #6]
|
||||||
|
* Upgrade kemitix-parent to 0.7.1
|
||||||
|
|
||||||
0.3.0
|
0.3.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
12
pom.xml
12
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>wiser-assertions</artifactId>
|
<artifactId>wiser-assertions</artifactId>
|
||||||
<version>0.3.0</version>
|
<version>0.3.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>wiser-assertions</name>
|
<name>wiser-assertions</name>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>0.6.1</version>
|
<version>0.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -57,12 +57,18 @@
|
||||||
<version>1.10.19</version>
|
<version>1.10.19</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency><!-- for Issue1Test -->
|
||||||
<groupId>org.codemonkey.simplejavamail</groupId>
|
<groupId>org.codemonkey.simplejavamail</groupId>
|
||||||
<artifactId>simple-java-mail</artifactId>
|
<artifactId>simple-java-mail</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency><!-- for Issue6Test -->
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context-support</artifactId>
|
||||||
|
<version>4.2.4.RELEASE</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -181,6 +181,9 @@ public final class WiserAssertions {
|
||||||
private String getMimeMessageBody(final WiserMessage message)
|
private String getMimeMessageBody(final WiserMessage message)
|
||||||
throws IOException, MessagingException {
|
throws IOException, MessagingException {
|
||||||
Object content = getMimeMessage(message).getContent();
|
Object content = getMimeMessage(message).getContent();
|
||||||
|
if (content instanceof String) {
|
||||||
|
return (String) content;
|
||||||
|
}
|
||||||
if (content instanceof MimeMessage) {
|
if (content instanceof MimeMessage) {
|
||||||
return content.toString();
|
return content.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ public abstract class AbstractWiserTest {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty("mail.transport.protocol", "smtp");
|
properties.setProperty("mail.transport.protocol", "smtp");
|
||||||
properties.setProperty("mail.smtp.host", "localhost");
|
properties.setProperty("mail.smtp.host", "localhost");
|
||||||
properties.setProperty("mail.smtp.port", "" + WiserAssertionsTest.PORT);
|
properties.setProperty("mail.smtp.port", "" + PORT);
|
||||||
Session session = Session.getDefaultInstance(properties);
|
Session session = Session.getInstance(properties);
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
38
src/test/java/net/kemitix/wiser/assertions/Issue6Test.java
Normal file
38
src/test/java/net/kemitix/wiser/assertions/Issue6Test.java
Normal 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue