Upgrade JUnit 4.13 to 5.6.1 (#86)

* Upgrade JUnit 4.13 to 5.6.1

* Test build with JDK 13

* Revert "Test build with JDK 13"

This reverts commit a5f0acfb91d17373fca943f19ecf4b32ab8ca02a.
This commit is contained in:
Paul Campbell 2020-03-23 13:13:57 +00:00 committed by GitHub
parent 6ddd97f025
commit fbe8d06332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 25 deletions

16
pom.xml
View file

@ -34,6 +34,9 @@
</scm> </scm>
<properties> <properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<tiles-maven-plugin.version>2.16</tiles-maven-plugin.version> <tiles-maven-plugin.version>2.16</tiles-maven-plugin.version>
<kemitix-maven-tiles.version>2.1.2</kemitix-maven-tiles.version> <kemitix-maven-tiles.version>2.1.2</kemitix-maven-tiles.version>
<kemitix-tiles.version>0.9.0</kemitix-tiles.version> <kemitix-tiles.version>0.9.0</kemitix-tiles.version>
@ -42,7 +45,7 @@
<javax-mail.version>1.4.7</javax-mail.version> <javax-mail.version>1.4.7</javax-mail.version>
<subethasmtp.version>3.1.7</subethasmtp.version> <subethasmtp.version>3.1.7</subethasmtp.version>
<junit.version>4.13</junit.version> <junit.version>5.6.1</junit.version>
<mockito-core.version>3.3.3</mockito-core.version> <mockito-core.version>3.3.3</mockito-core.version>
<simple-java-mail.version>3.1.1</simple-java-mail.version> <simple-java-mail.version>3.1.1</simple-java-mail.version>
<spring-framework.version>5.2.4.RELEASE</spring-framework.version> <spring-framework.version>5.2.4.RELEASE</spring-framework.version>
@ -52,6 +55,7 @@
<jacoco-class-missed-count-maximum>1</jacoco-class-missed-count-maximum> <jacoco-class-missed-count-maximum>1</jacoco-class-missed-count-maximum>
<mon.version>2.1.0</mon.version> <mon.version>2.1.0</mon.version>
<spotbugs.version>4.0.1</spotbugs.version> <spotbugs.version>4.0.1</spotbugs.version>
<assertj.version>3.15.0</assertj.version>
</properties> </properties>
<dependencies> <dependencies>
@ -71,8 +75,8 @@
<version>${subethasmtp.version}</version> <version>${subethasmtp.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -82,6 +86,12 @@
<version>${mockito-core.version}</version> <version>${mockito-core.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency><!-- for Issue1Test --> <dependency><!-- for Issue1Test -->
<groupId>org.codemonkey.simplejavamail</groupId> <groupId>org.codemonkey.simplejavamail</groupId>
<artifactId>simple-java-mail</artifactId> <artifactId>simple-java-mail</artifactId>

View file

@ -1,7 +1,7 @@
package net.kemitix.wiser.assertions; package net.kemitix.wiser.assertions;
import org.junit.After; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.subethamail.wiser.Wiser; import org.subethamail.wiser.Wiser;
import java.io.IOException; import java.io.IOException;
@ -17,7 +17,7 @@ abstract class AbstractWiserTest {
private Wiser wiser; private Wiser wiser;
@Before @BeforeEach
public void setUp() throws IOException { public void setUp() throws IOException {
port = findFreePort(); port = findFreePort();
wiser = new Wiser(port); wiser = new Wiser(port);
@ -31,7 +31,7 @@ abstract class AbstractWiserTest {
} }
} }
@After @AfterEach
public void tearDown() { public void tearDown() {
wiser.stop(); wiser.stop();
} }

View file

@ -2,7 +2,7 @@ package net.kemitix.wiser.assertions;
import org.codemonkey.simplejavamail.Mailer; import org.codemonkey.simplejavamail.Mailer;
import org.codemonkey.simplejavamail.email.Email; import org.codemonkey.simplejavamail.email.Email;
import org.junit.Test; import org.junit.jupiter.api.Test;
import javax.mail.Message; import javax.mail.Message;

View file

@ -1,7 +1,6 @@
package net.kemitix.wiser.assertions; package net.kemitix.wiser.assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.JavaMailSenderImpl;

View file

@ -1,9 +1,10 @@
package net.kemitix.wiser.assertions; package net.kemitix.wiser.assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.subethamail.wiser.Wiser; import org.subethamail.wiser.Wiser;
import static org.junit.Assert.assertNotNull; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
@ -75,14 +76,17 @@ public class WiserAssertionsTest extends AbstractWiserTest {
* Test {@link WiserAssertions#withContent(java.lang.String)} where the * Test {@link WiserAssertions#withContent(java.lang.String)} where the
* content of the email does not match. * content of the email does not match.
*/ */
@Test(expected = AssertionError.class) @Test
public void testContentNotMatches() { public void testContentNotMatches() {
//given //given
final String body = "message body"; final String body = "message body";
//when //when
sendMimeMultipartMessage("from", "to", "subject", body); sendMimeMultipartMessage("from", "to", "subject", body);
//then //then
assertReceivedMessage().withContent("Other body"); assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
assertReceivedMessage()
.withContent("Other body"));
} }
/** /**
@ -103,14 +107,17 @@ public class WiserAssertionsTest extends AbstractWiserTest {
* Test {@link WiserAssertions#withContentContains(String)} where the * Test {@link WiserAssertions#withContentContains(String)} where the
* content of the email does not match. * content of the email does not match.
*/ */
@Test(expected = AssertionError.class) @Test
public void testContentContainsNotMatches() { public void testContentContainsNotMatches() {
//given //given
final String body = "message body"; final String body = "message body";
//when //when
sendMimeMultipartMessage("from", "to", "subject", body); sendMimeMultipartMessage("from", "to", "subject", body);
//then //then
assertReceivedMessage().withContentContains("agebo"); assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
assertReceivedMessage()
.withContentContains("agebo"));
} }
/** /**
@ -133,14 +140,17 @@ public class WiserAssertionsTest extends AbstractWiserTest {
* Test {@link WiserAssertions#from(java.lang.String)} can detect when mail * Test {@link WiserAssertions#from(java.lang.String)} can detect when mail
* is not sent from a user. * is not sent from a user.
*/ */
@Test(expected = AssertionError.class) @Test
public void testFromNotMatches() { public void testFromNotMatches() {
//given //given
final String from = "bob@a.com"; final String from = "bob@a.com";
//when //when
sendMimeMultipartMessage(from, "to", "subject", "body"); sendMimeMultipartMessage(from, "to", "subject", "body");
//then //then
assertReceivedMessage().from("lisa@c.com"); assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
assertReceivedMessage()
.from("lisa@c.com"));
} }
/** /**
@ -149,7 +159,8 @@ public class WiserAssertionsTest extends AbstractWiserTest {
*/ */
@Test @Test
public void testInstantiate() { public void testInstantiate() {
assertNotNull(assertReceivedMessage()); assertThat(assertReceivedMessage())
.isNotNull();
} }
/** /**
@ -171,14 +182,17 @@ public class WiserAssertionsTest extends AbstractWiserTest {
* Test {@link WiserAssertions#withSubjectContains(java.lang.String)} where * Test {@link WiserAssertions#withSubjectContains(java.lang.String)} where
* the subject does not contain the expected fragment. * the subject does not contain the expected fragment.
*/ */
@Test(expected = AssertionError.class) @Test
public void testSubjectContainsNotMatches() { public void testSubjectContainsNotMatches() {
//given //given
final String fragment = "foo"; final String fragment = "foo";
//when //when
sendMimeMultipartMessage("from", "to", "subject tail", "body"); sendMimeMultipartMessage("from", "to", "subject tail", "body");
//then //then
assertReceivedMessage().withSubjectContains(fragment); assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
assertReceivedMessage()
.withSubjectContains(fragment));
} }
/** /**
@ -199,14 +213,17 @@ public class WiserAssertionsTest extends AbstractWiserTest {
* Test {@link WiserAssertions#withSubject(java.lang.String)} where the * Test {@link WiserAssertions#withSubject(java.lang.String)} where the
* message does not have the subject expected. * message does not have the subject expected.
*/ */
@Test(expected = AssertionError.class) @Test
public void testSubjectNotMatches() { public void testSubjectNotMatches() {
//given //given
final String subject = "message subject"; final String subject = "message subject";
//when //when
sendMimeMultipartMessage("from", "to", subject, "body"); sendMimeMultipartMessage("from", "to", subject, "body");
//then //then
assertReceivedMessage().withSubject("other subject"); assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
assertReceivedMessage()
.withSubject("other subject"));
} }
/** /**
@ -228,14 +245,17 @@ public class WiserAssertionsTest extends AbstractWiserTest {
* is not sent from a user. * is not sent from a user.
* *
*/ */
@Test(expected = AssertionError.class) @Test
public void testToNotMatches() { public void testToNotMatches() {
//given //given
final String to = "carl@b.com"; final String to = "carl@b.com";
//when //when
sendMimeMultipartMessage("from", to, "subject", "body"); sendMimeMultipartMessage("from", to, "subject", "body");
//then //then
assertReceivedMessage().to("bob@a.com"); assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
assertReceivedMessage()
.to("bob@a.com"));
} }
} }