You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2022/09/07 22:04:22 UTC
[sling-org-apache-sling-commons-messaging-mail] branch master updated: SLING-11476 Update Testing PaxExam to 4.0.0
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-messaging-mail.git
The following commit(s) were added to refs/heads/master by this push:
new 864c698 SLING-11476 Update Testing PaxExam to 4.0.0
864c698 is described below
commit 864c69802aaa1830bc5d75ad887d0c8ff09a80af
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Thu Sep 8 00:04:03 2022 +0200
SLING-11476 Update Testing PaxExam to 4.0.0
* use Testing PaxExam 4.0.0-SNAPSHOT
* update test dependencies
* use Hamcrest's assertThat
---
pom.xml | 39 +--
.../mail/internal/SimpleMessageBuilderTest.java | 333 +++++++++++----------
.../mail/internal/SimpleMessageIdProviderTest.java | 10 +-
.../messaging/mail/it/tests/MailTestSupport.java | 57 +---
.../mail/it/tests/SimpleMailServiceIT.java | 143 ++++-----
5 files changed, 264 insertions(+), 318 deletions(-)
diff --git a/pom.xml b/pom.xml
index fe84a1c..8c913e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -225,7 +225,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>7.0.3</version>
+ <version>7.0.5</version>
<scope>test</scope>
</dependency>
<!-- Apache Sling -->
@@ -250,7 +250,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.paxexam</artifactId>
- <version>3.1.0</version>
+ <version>4.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- Jasypt -->
@@ -264,7 +264,7 @@
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
- <version>3.0.14.RELEASE</version>
+ <version>3.0.15.RELEASE</version>
<scope>test</scope>
</dependency>
<!-- logging -->
@@ -290,10 +290,16 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
+ <scope>test</scope>
+ <version>1.3_1</version>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>4.1.0</version>
+ <version>4.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -350,31 +356,6 @@
<version>2.6.7</version>
<scope>test</scope>
</dependency>
- <!-- testing - truth and dependencies -->
- <dependency>
- <groupId>com.google.truth</groupId>
- <artifactId>truth</artifactId>
- <version>1.1.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.googlecode.java-diff-utils</groupId>
- <artifactId>diffutils</artifactId>
- <version>1.3.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>31.0.1-jre</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>failureaccess</artifactId>
- <version>1.0.1</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageBuilderTest.java b/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageBuilderTest.java
index a1c1fbb..14569af 100644
--- a/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageBuilderTest.java
+++ b/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageBuilderTest.java
@@ -34,7 +34,10 @@ import org.apache.commons.mail.util.MimeMessageParser;
import org.junit.Before;
import org.junit.Test;
-import static com.google.common.truth.Truth.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
public class SimpleMessageBuilderTest {
@@ -61,14 +64,14 @@ public class SimpleMessageBuilderTest {
builder.header("c", "3");
final MimeMessage message = builder.build();
final String[] a = message.getHeader("a");
- assertThat(a).hasLength(1);
- assertThat(a[0]).isEqualTo("1");
+ assertThat(a, arrayWithSize(1));
+ assertThat(a[0], is("1"));
final String[] b = message.getHeader("b");
- assertThat(b).hasLength(1);
- assertThat(b[0]).isEqualTo("2");
+ assertThat(b, arrayWithSize(1));
+ assertThat(b[0], is("2"));
final String[] c = message.getHeader("c");
- assertThat(c).hasLength(1);
- assertThat(c[0]).isEqualTo("3");
+ assertThat(c, arrayWithSize(1));
+ assertThat(c[0], is("3"));
}
@Test
@@ -82,14 +85,14 @@ public class SimpleMessageBuilderTest {
builder.headers(headers);
final MimeMessage message = builder.build();
final String[] a = message.getHeader("a");
- assertThat(a).hasLength(1);
- assertThat(a[0]).isEqualTo("1");
+ assertThat(a, arrayWithSize(1));
+ assertThat(a[0], is("1"));
final String[] b = message.getHeader("b");
- assertThat(b).hasLength(1);
- assertThat(b[0]).isEqualTo("2");
+ assertThat(b, arrayWithSize(1));
+ assertThat(b[0], is("2"));
final String[] c = message.getHeader("c");
- assertThat(c).hasLength(1);
- assertThat(c[0]).isEqualTo("3");
+ assertThat(c, arrayWithSize(1));
+ assertThat(c[0], is("3"));
}
@Test
@@ -101,7 +104,7 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress from = parser.getFrom();
- assertThat(from).isEqualTo(address);
+ assertThat(from, is(address));
}
@Test
@@ -113,7 +116,7 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress from = parser.getFrom();
- assertThat(from.getAddress()).isEqualTo(address);
+ assertThat(from.getAddress(), is(address));
}
@Test
@@ -126,8 +129,8 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress from = parser.getFrom();
- assertThat(from.getAddress()).isEqualTo(address);
- assertThat(from.getPersonal()).isEqualTo(name);
+ assertThat(from.getAddress(), is(address));
+ assertThat(from.getPersonal(), is(name));
}
// single to
@@ -141,11 +144,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress to = (InternetAddress) parser.getTo().get(0);
- assertThat(to).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(1);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(to, is(address));
+ assertThat(parser.getTo(), hasSize(1));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -157,11 +160,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress to = (InternetAddress) parser.getTo().get(0);
- assertThat(to.getAddress()).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(1);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(to.getAddress(), is(address));
+ assertThat(parser.getTo(), hasSize(1));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -174,12 +177,12 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress to = (InternetAddress) parser.getTo().get(0);
- assertThat(to.getAddress()).isEqualTo(address);
- assertThat(to.getPersonal()).isEqualTo(name);
- assertThat(parser.getTo()).hasSize(1);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(to.getAddress(), is(address));
+ assertThat(to.getPersonal(), is(name));
+ assertThat(parser.getTo(), hasSize(1));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
// multiple to
@@ -199,13 +202,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getTo().get(0);
final InternetAddress b = (InternetAddress) parser.getTo().get(1);
final InternetAddress c = (InternetAddress) parser.getTo().get(2);
- assertThat(a).isEqualTo(addresses[0]);
- assertThat(b).isEqualTo(addresses[1]);
- assertThat(c).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(3);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a, is(addresses[0]));
+ assertThat(b, is(addresses[1]));
+ assertThat(c, is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(3));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -223,13 +226,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getTo().get(0);
final InternetAddress b = (InternetAddress) parser.getTo().get(1);
final InternetAddress c = (InternetAddress) parser.getTo().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(3);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(3));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -247,13 +250,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getTo().get(0);
final InternetAddress b = (InternetAddress) parser.getTo().get(1);
final InternetAddress c = (InternetAddress) parser.getTo().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(3);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(3));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
// single cc
@@ -267,11 +270,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress cc = (InternetAddress) parser.getCc().get(0);
- assertThat(cc).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(1);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(cc, is(address));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(1));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -283,11 +286,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress cc = (InternetAddress) parser.getCc().get(0);
- assertThat(cc.getAddress()).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(1);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(cc.getAddress(), is(address));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(1));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -300,12 +303,12 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress cc = (InternetAddress) parser.getCc().get(0);
- assertThat(cc.getAddress()).isEqualTo(address);
- assertThat(cc.getPersonal()).isEqualTo(name);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(1);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(cc.getAddress(), is(address));
+ assertThat(cc.getPersonal(), is(name));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(1));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
// multiple cc
@@ -325,13 +328,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getCc().get(0);
final InternetAddress b = (InternetAddress) parser.getCc().get(1);
final InternetAddress c = (InternetAddress) parser.getCc().get(2);
- assertThat(a).isEqualTo(addresses[0]);
- assertThat(b).isEqualTo(addresses[1]);
- assertThat(c).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(3);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a, is(addresses[0]));
+ assertThat(b, is(addresses[1]));
+ assertThat(c, is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(3));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -349,13 +352,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getCc().get(0);
final InternetAddress b = (InternetAddress) parser.getCc().get(1);
final InternetAddress c = (InternetAddress) parser.getCc().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(3);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(3));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -373,13 +376,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getCc().get(0);
final InternetAddress b = (InternetAddress) parser.getCc().get(1);
final InternetAddress c = (InternetAddress) parser.getCc().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(3);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(3));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
// single bcc
@@ -393,11 +396,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress bcc = (InternetAddress) parser.getBcc().get(0);
- assertThat(bcc).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(1);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(bcc, is(address));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(1));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -409,11 +412,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress bcc = (InternetAddress) parser.getBcc().get(0);
- assertThat(bcc.getAddress()).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(1);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(bcc.getAddress(), is(address));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(1));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -426,12 +429,12 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress bcc = (InternetAddress) parser.getBcc().get(0);
- assertThat(bcc.getAddress()).isEqualTo(address);
- assertThat(bcc.getPersonal()).isEqualTo(name);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(1);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(bcc.getAddress(), is(address));
+ assertThat(bcc.getPersonal(), is(name));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(1));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
// multiple bcc
@@ -451,13 +454,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getBcc().get(0);
final InternetAddress b = (InternetAddress) parser.getBcc().get(1);
final InternetAddress c = (InternetAddress) parser.getBcc().get(2);
- assertThat(a).isEqualTo(addresses[0]);
- assertThat(b).isEqualTo(addresses[1]);
- assertThat(c).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(3);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a, is(addresses[0]));
+ assertThat(b, is(addresses[1]));
+ assertThat(c, is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(3));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -475,13 +478,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getBcc().get(0);
final InternetAddress b = (InternetAddress) parser.getBcc().get(1);
final InternetAddress c = (InternetAddress) parser.getBcc().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(3);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(3));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
@Test
@@ -499,13 +502,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getBcc().get(0);
final InternetAddress b = (InternetAddress) parser.getBcc().get(1);
final InternetAddress c = (InternetAddress) parser.getBcc().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(3);
- assertThat(parser.getReplyTo()).hasSize(0);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(3));
+ assertThat(parser.getReplyTo(), hasSize(0));
}
// single replyTo
@@ -519,11 +522,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress replyTo = (InternetAddress) parser.getReplyTo().get(0);
- assertThat(replyTo).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(1);
+ assertThat(replyTo, is(address));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(1));
}
@Test
@@ -535,11 +538,11 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress replyTo = (InternetAddress) parser.getReplyTo().get(0);
- assertThat(replyTo.getAddress()).isEqualTo(address);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(1);
+ assertThat(replyTo.getAddress(), is(address));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(1));
}
@Test
@@ -552,12 +555,12 @@ public class SimpleMessageBuilderTest {
final MimeMessage message = builder.build();
final MimeMessageParser parser = new MimeMessageParser(message).parse();
final InternetAddress replyTo = (InternetAddress) parser.getReplyTo().get(0);
- assertThat(replyTo.getAddress()).isEqualTo(address);
- assertThat(replyTo.getPersonal()).isEqualTo(name);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(1);
+ assertThat(replyTo.getAddress(), is(address));
+ assertThat(replyTo.getPersonal(), is(name));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(1));
}
// multiple replyTo
@@ -577,13 +580,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getReplyTo().get(0);
final InternetAddress b = (InternetAddress) parser.getReplyTo().get(1);
final InternetAddress c = (InternetAddress) parser.getReplyTo().get(2);
- assertThat(a).isEqualTo(addresses[0]);
- assertThat(b).isEqualTo(addresses[1]);
- assertThat(c).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(3);
+ assertThat(a, is(addresses[0]));
+ assertThat(b, is(addresses[1]));
+ assertThat(c, is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(3));
}
@Test
@@ -601,13 +604,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getReplyTo().get(0);
final InternetAddress b = (InternetAddress) parser.getReplyTo().get(1);
final InternetAddress c = (InternetAddress) parser.getReplyTo().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(3);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(3));
}
@Test
@@ -625,13 +628,13 @@ public class SimpleMessageBuilderTest {
final InternetAddress a = (InternetAddress) parser.getReplyTo().get(0);
final InternetAddress b = (InternetAddress) parser.getReplyTo().get(1);
final InternetAddress c = (InternetAddress) parser.getReplyTo().get(2);
- assertThat(a.getAddress()).isEqualTo(addresses[0]);
- assertThat(b.getAddress()).isEqualTo(addresses[1]);
- assertThat(c.getAddress()).isEqualTo(addresses[2]);
- assertThat(parser.getTo()).hasSize(0);
- assertThat(parser.getCc()).hasSize(0);
- assertThat(parser.getBcc()).hasSize(0);
- assertThat(parser.getReplyTo()).hasSize(3);
+ assertThat(a.getAddress(), is(addresses[0]));
+ assertThat(b.getAddress(), is(addresses[1]));
+ assertThat(c.getAddress(), is(addresses[2]));
+ assertThat(parser.getTo(), hasSize(0));
+ assertThat(parser.getCc(), hasSize(0));
+ assertThat(parser.getBcc(), hasSize(0));
+ assertThat(parser.getReplyTo(), hasSize(3));
}
}
diff --git a/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageIdProviderTest.java b/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageIdProviderTest.java
index ef189b0..c6bddb1 100644
--- a/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageIdProviderTest.java
+++ b/src/test/java/org/apache/sling/commons/messaging/mail/internal/SimpleMessageIdProviderTest.java
@@ -19,10 +19,12 @@
package org.apache.sling.commons.messaging.mail.internal;
import jakarta.mail.internet.MimeMessage;
+
import org.apache.commons.lang3.reflect.MethodUtils;
import org.junit.Test;
-import static com.google.common.truth.Truth.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.endsWith;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -37,19 +39,19 @@ public class SimpleMessageIdProviderTest {
final SimpleMessageIdProviderConfiguration configuration = mock(SimpleMessageIdProviderConfiguration.class);
when(configuration.host()).thenReturn(host);
MethodUtils.invokeMethod(provider, true, "activate", configuration);
- assertThat(provider.getMessageId(message)).endsWith("@".concat(host));
+ assertThat(provider.getMessageId(message), endsWith("@".concat(host)));
}
{ // modified
final String host = "publish.cms.example.org";
final SimpleMessageIdProviderConfiguration configuration = mock(SimpleMessageIdProviderConfiguration.class);
when(configuration.host()).thenReturn(host);
MethodUtils.invokeMethod(provider, true, "modified", configuration);
- assertThat(provider.getMessageId(message)).endsWith("@".concat(host));
+ assertThat(provider.getMessageId(message), endsWith("@".concat(host)));
}
{ // deactivate
final String host = "publish.cms.example.org";
MethodUtils.invokeMethod(provider, true, "deactivate");
- assertThat(provider.getMessageId(message)).endsWith("@".concat(host));
+ assertThat(provider.getMessageId(message), endsWith("@".concat(host)));
}
}
diff --git a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
index 98dc4ae..6ecdd2c 100644
--- a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
+++ b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
@@ -23,17 +23,12 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Map;
-import java.util.Objects;
import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
-import org.apache.sling.testing.paxexam.SlingOptions;
import org.apache.sling.testing.paxexam.TestSupport;
-import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import org.ops4j.pax.exam.options.ModifiableCompositeOption;
-import org.ops4j.pax.exam.options.OptionalCompositeOption;
-import org.ops4j.pax.exam.options.extra.VMOption;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ConfigurationAdmin;
import org.thymeleaf.ITemplateEngine;
@@ -43,15 +38,14 @@ import org.thymeleaf.context.Context;
import org.thymeleaf.context.IContext;
import org.thymeleaf.templatemode.TemplateMode;
+import static org.apache.sling.testing.paxexam.SlingOptions.greenmail;
import static org.apache.sling.testing.paxexam.SlingOptions.scr;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingCommonsCrypto;
import static org.apache.sling.testing.paxexam.SlingOptions.slingCommonsThreads;
-import static org.ops4j.pax.exam.CoreOptions.bootClasspathLibrary;
+import static org.apache.sling.testing.paxexam.SlingOptions.thymeleaf;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.vmOption;
-import static org.ops4j.pax.exam.CoreOptions.when;
-import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
public abstract class MailTestSupport extends TestSupport {
@@ -75,52 +69,9 @@ public abstract class MailTestSupport extends TestSupport {
slingCommonsCrypto(),
slingCommonsThreads(),
// testing
- junitBundles(),
- wrappedBundle(mavenBundle().groupId("com.google.truth").artifactId("truth").versionAsInProject()),
- mavenBundle().groupId("com.google.guava").artifactId("guava").versionAsInProject(),
- mavenBundle().groupId("com.google.guava").artifactId("failureaccess").versionAsInProject(),
- mavenBundle().groupId("com.googlecode.java-diff-utils").artifactId("diffutils").versionAsInProject(),
mavenBundle().groupId("commons-io").artifactId("commons-io").versionAsInProject(),
greenmail(),
- thymeleaf(),
- jacoco() // remove with Testing PaxExam 4.0
- );
- }
-
- // remove with Testing PaxExam 4.0
- protected OptionalCompositeOption jacoco() {
- final String jacocoCommand = System.getProperty("jacoco.command");
- final VMOption option = Objects.nonNull(jacocoCommand) && !jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
- return when(Objects.nonNull(option)).useOptions(option);
- }
-
- private static ModifiableCompositeOption greenmail() {
- final MavenArtifactProvisionOption greenmail = mavenBundle().groupId("com.icegreen").artifactId("greenmail").versionAsInProject();
- final MavenArtifactProvisionOption slf4j_api = mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject();
- final MavenArtifactProvisionOption slf4j_simple = mavenBundle().groupId("org.slf4j").artifactId("slf4j-simple").versionAsInProject();
- return composite(
- greenmail,
- // add GreenMail to boot classpath to allow setting ssl.SocketFactory.provider to GreenMail's DummySSLSocketFactory
- bootClasspathLibrary(greenmail).afterFramework(),
- bootClasspathLibrary(slf4j_api).afterFramework(), // GreenMail dependency
- bootClasspathLibrary(slf4j_simple).afterFramework() // GreenMail dependency
- );
- }
-
- private static ModifiableCompositeOption thymeleaf() {
- return composite(
- mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.thymeleaf").version(SlingOptions.versionResolver),
- mavenBundle().groupId("org.attoparser").artifactId("attoparser").version(SlingOptions.versionResolver),
- mavenBundle().groupId("org.unbescape").artifactId("unbescape").version(SlingOptions.versionResolver),
- mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.ognl").version(SlingOptions.versionResolver),
- mavenBundle().groupId("org.javassist").artifactId("javassist").version(SlingOptions.versionResolver)
- );
- }
-
- private static ModifiableCompositeOption slingCommonsCrypto() {
- return composite(
- mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.crypto").versionAsInProject(),
- mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.jasypt").versionAsInProject()
+ thymeleaf()
);
}
diff --git a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/SimpleMailServiceIT.java b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/SimpleMailServiceIT.java
index ff906df..dbe7844 100644
--- a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/SimpleMailServiceIT.java
+++ b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/SimpleMailServiceIT.java
@@ -70,7 +70,16 @@ import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static com.google.common.truth.Truth.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.startsWith;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
@@ -202,7 +211,7 @@ public class SimpleMailServiceIT extends MailTestSupport {
@Test
public void testMessageService() throws ExecutionException, InterruptedException {
exception.expect(ExecutionException.class);
- assertThat(messageService).isNotNull();
+ assertThat(messageService, notNullValue());
final Properties properties = new Properties();
final Session session = Session.getDefaultInstance(properties);
final MimeMessage message = new MimeMessage(session);
@@ -212,7 +221,7 @@ public class SimpleMailServiceIT extends MailTestSupport {
@Test
public void testMailService() {
- assertThat(mailService).isNotNull();
+ assertThat(mailService, notNullValue());
}
@Test
@@ -235,16 +244,16 @@ public class SimpleMailServiceIT extends MailTestSupport {
final MimeMessage received = messages[0];
final MimeMessageParser parser = new MimeMessageParser(message).parse();
- assertThat(received.getMessageID()).endsWith("@localhost>");
- assertThat(received.getSubject()).isEqualTo(subject);
- assertThat(received.getFrom()[0]).isEqualTo(from);
- assertThat(received.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(to);
- assertThat(received.getReplyTo()[0]).isEqualTo(replyTo);
+ assertThat(received.getMessageID(), endsWith("@localhost>"));
+ assertThat(received.getSubject(), is(subject));
+ assertThat(received.getFrom()[0], is(from));
+ assertThat(received.getRecipients(Message.RecipientType.TO)[0], is(to));
+ assertThat(received.getReplyTo()[0], is(replyTo));
- assertThat(parser.getPlainContent()).isEqualTo(text);
+ assertThat(parser.getPlainContent(), is(text));
- assertThat(parser.getAttachmentList()).isEmpty();
- assertThat(parser.getContentIds()).isEmpty();
+ assertThat(parser.getAttachmentList(), empty());
+ assertThat(parser.getContentIds(), empty());
}
}
@@ -269,16 +278,16 @@ public class SimpleMailServiceIT extends MailTestSupport {
final MimeMessage received = messages[0];
final MimeMessageParser parser = new MimeMessageParser(message).parse();
- assertThat(received.getMessageID()).endsWith("@localhost>");
- assertThat(received.getSubject()).isEqualTo(subject);
- assertThat(received.getFrom()[0]).isEqualTo(from);
- assertThat(received.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(to);
- assertThat(received.getReplyTo()[0]).isEqualTo(replyTo);
+ assertThat(received.getMessageID(), endsWith("@localhost>"));
+ assertThat(received.getSubject(), is(subject));
+ assertThat(received.getFrom()[0], is(from));
+ assertThat(received.getRecipients(Message.RecipientType.TO)[0], is(to));
+ assertThat(received.getReplyTo()[0], is(replyTo));
- assertThat(parser.getPlainContent()).isEqualTo(text);
+ assertThat(parser.getPlainContent(), is(text));
- assertThat(parser.getAttachmentList().get(0).getName()).isEqualTo("SupportApache-small.png");
- assertThat(parser.getContentIds()).isEmpty();
+ assertThat(parser.getAttachmentList().get(0).getName(), is("SupportApache-small.png"));
+ assertThat(parser.getContentIds(), empty());
}
}
@@ -301,16 +310,16 @@ public class SimpleMailServiceIT extends MailTestSupport {
final MimeMessage received = messages[0];
final MimeMessageParser parser = new MimeMessageParser(message).parse();
- assertThat(received.getMessageID()).endsWith("@localhost>");
- assertThat(received.getSubject()).isEqualTo(subject);
- assertThat(received.getFrom()[0]).isEqualTo(from);
- assertThat(received.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(to);
- assertThat(received.getReplyTo()[0]).isEqualTo(replyTo);
+ assertThat(received.getMessageID(), endsWith("@localhost>"));
+ assertThat(received.getSubject(), is(subject));
+ assertThat(received.getFrom()[0], is(from));
+ assertThat(received.getRecipients(Message.RecipientType.TO)[0], is(to));
+ assertThat(received.getReplyTo()[0], is(replyTo));
- assertThat(parser.getHtmlContent()).isEqualTo(html);
+ assertThat(parser.getHtmlContent(), is(html));
- assertThat(parser.getAttachmentList()).isEmpty();
- assertThat(parser.getContentIds()).isEmpty();
+ assertThat(parser.getAttachmentList(), empty());
+ assertThat(parser.getContentIds(), empty());
}
}
@@ -335,16 +344,16 @@ public class SimpleMailServiceIT extends MailTestSupport {
final MimeMessage received = messages[0];
final MimeMessageParser parser = new MimeMessageParser(message).parse();
- assertThat(received.getMessageID()).endsWith("@localhost>");
- assertThat(received.getSubject()).isEqualTo(subject);
- assertThat(received.getFrom()[0]).isEqualTo(from);
- assertThat(received.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(to);
- assertThat(received.getReplyTo()[0]).isEqualTo(replyTo);
+ assertThat(received.getMessageID(), endsWith("@localhost>"));
+ assertThat(received.getSubject(), is(subject));
+ assertThat(received.getFrom()[0], is(from));
+ assertThat(received.getRecipients(Message.RecipientType.TO)[0], is(to));
+ assertThat(received.getReplyTo()[0], is(replyTo));
- assertThat(parser.getHtmlContent()).isEqualTo(html);
+ assertThat(parser.getHtmlContent(), is(html));
- assertThat(parser.getAttachmentList().get(0).getName()).isEqualTo("SupportApache-small.png");
- assertThat(parser.getContentIds()).isEmpty();
+ assertThat(parser.getAttachmentList().get(0).getName(), is("SupportApache-small.png"));
+ assertThat(parser.getContentIds(), empty());
}
}
@@ -371,15 +380,15 @@ public class SimpleMailServiceIT extends MailTestSupport {
final MimeMessage received = messages[0];
final MimeMessageParser parser = new MimeMessageParser(message).parse();
- assertThat(received.getMessageID()).endsWith("@localhost>");
- assertThat(received.getSubject()).isEqualTo(subject);
- assertThat(received.getFrom()[0]).isEqualTo(from);
- assertThat(received.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(to);
- assertThat(received.getReplyTo()[0]).isEqualTo(replyTo);
+ assertThat(received.getMessageID(), endsWith("@localhost>"));
+ assertThat(received.getSubject(), is(subject));
+ assertThat(received.getFrom()[0], is(from));
+ assertThat(received.getRecipients(Message.RecipientType.TO)[0], is(to));
+ assertThat(received.getReplyTo()[0], is(replyTo));
- assertThat(parser.getHtmlContent()).isEqualTo(html);
+ assertThat(parser.getHtmlContent(), is(html));
- assertThat(parser.getContentIds()).contains("sling");
+ assertThat(parser.getContentIds(), hasItem("sling"));
}
}
@@ -408,35 +417,35 @@ public class SimpleMailServiceIT extends MailTestSupport {
final MimeMessage received = messages[0];
final MimeMessageParser parser = new MimeMessageParser(message).parse();
- assertThat(received.getMessageID()).endsWith("@localhost>");
- assertThat(received.getSubject()).isEqualTo(subject);
- assertThat(received.getFrom()[0]).isEqualTo(from);
- assertThat(received.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(to);
- assertThat(received.getReplyTo()[0]).isEqualTo(replyTo);
+ assertThat(received.getMessageID(), endsWith("@localhost>"));
+ assertThat(received.getSubject(), is(subject));
+ assertThat(received.getFrom()[0], is(from));
+ assertThat(received.getRecipients(Message.RecipientType.TO)[0], is(to));
+ assertThat(received.getReplyTo()[0], is(replyTo));
- assertThat(parser.getPlainContent()).isEqualTo(text);
- assertThat(parser.getHtmlContent()).isEqualTo(html);
+ assertThat(parser.getPlainContent(), is(text));
+ assertThat(parser.getHtmlContent(), is(html));
- assertThat(parser.getContentIds()).contains("sling");
+ assertThat(parser.getContentIds(), hasItem("sling"));
final MimeMultipart content = (MimeMultipart) received.getContent();
- assertThat(content.getContentType()).startsWith("multipart/mixed");
+ assertThat(content.getContentType(), startsWith("multipart/mixed"));
final MimeBodyPart alternative = (MimeBodyPart) content.getBodyPart(0);
- assertThat(alternative.getContentType()).startsWith("multipart/alternative");
+ assertThat(alternative.getContentType(), startsWith("multipart/alternative"));
final MimeBodyPart related = (MimeBodyPart) ((MimeMultipart) alternative.getContent()).getBodyPart(0);
- assertThat(related.getContentType()).startsWith("multipart/related");
+ assertThat(related.getContentType(), startsWith("multipart/related"));
final MimeBodyPart inline = (MimeBodyPart) ((MimeMultipart) related.getContent()).getBodyPart(1);
- assertThat(inline.getContentType()).isEqualTo("image/png");
- assertThat(inline.getHeader("X-Inline")).hasLength(1);
- assertThat(inline.getHeader("X-Inline")[0]).isEqualTo("Apache Sling");
+ assertThat(inline.getContentType(), is("image/png"));
+ assertThat(inline.getHeader("X-Inline"), arrayWithSize(1));
+ assertThat(inline.getHeader("X-Inline")[0], is("Apache Sling"));
final MimeBodyPart attachment = (MimeBodyPart) content.getBodyPart(1);
- assertThat(attachment.getContentType()).isEqualTo("image/png; name=SupportApache-small.png");
- assertThat(attachment.getHeader("X-Attachment")).hasLength(1);
- assertThat(attachment.getHeader("X-Attachment")[0]).isEqualTo("Apache Software Foundation");
+ assertThat(attachment.getContentType(), is("image/png; name=SupportApache-small.png"));
+ assertThat(attachment.getHeader("X-Attachment"), arrayWithSize(1));
+ assertThat(attachment.getHeader("X-Attachment")[0], is("Apache Software Foundation"));
}
}
@@ -464,17 +473,17 @@ public class SimpleMailServiceIT extends MailTestSupport {
final CompletableFuture<Void> future = mailService.sendMessage(message);
future.get();
- assertThat(unusedCLSR.getReference().getUsingBundles()).isNull();
- assertThat(unusedTLSR.getReference().getUsingBundles()).isNull();
+ assertThat(unusedCLSR.getReference().getUsingBundles(), nullValue());
+ assertThat(unusedTLSR.getReference().getUsingBundles(), nullValue());
- assertThat(usedCLSR.getReference().getUsingBundles()).hasLength(1);
- assertThat(usedTLSR.getReference().getUsingBundles()).hasLength(1);
+ assertThat(usedCLSR.getReference().getUsingBundles(), arrayWithSize(1));
+ assertThat(usedTLSR.getReference().getUsingBundles(), arrayWithSize(1));
- assertThat(usedCLSR.getReference().getUsingBundles()[0].getSymbolicName()).isEqualTo("org.apache.sling.commons.messaging.mail");
- assertThat(usedTLSR.getReference().getUsingBundles()[0].getSymbolicName()).isEqualTo("org.apache.sling.commons.messaging.mail");
+ assertThat(usedCLSR.getReference().getUsingBundles()[0].getSymbolicName(), is("org.apache.sling.commons.messaging.mail"));
+ assertThat(usedTLSR.getReference().getUsingBundles()[0].getSymbolicName(), is("org.apache.sling.commons.messaging.mail"));
- assertThat(usedConnectionListener.opened.size()).isEqualTo(1);
- assertThat(usedConnectionListener.closed.size()).isEqualTo(1);
+ assertThat(usedConnectionListener.opened, hasSize(1));
+ assertThat(usedConnectionListener.closed, hasSize(1));
}
private static class RecordingConnectionListener implements ConnectionListener {