http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java index 0cc1bae..4025c12 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java @@ -21,6 +21,7 @@ package org.apache.james.transport.matchers; import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; @@ -30,17 +31,17 @@ import org.apache.mailet.Mail; import org.apache.mailet.base.RFC2822Headers; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class RelayLimitTest { +class RelayLimitTest { private RelayLimit testee; private Mail mail; private MimeMessage mimeMessage; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { testee = new RelayLimit(); mimeMessage = MimeMessageUtil.defaultMimeMessage(); mail = FakeMail.builder() @@ -49,39 +50,47 @@ public class RelayLimitTest { .build(); } - @Test(expected = MessagingException.class) - public void relayLimitShouldBeANumber() throws Exception { - testee.init(FakeMatcherConfig.builder() + @Test + void relayLimitShouldBeANumber() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("Abc") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) - public void relayLimitShouldBeSpecified() throws Exception { - testee.init(FakeMatcherConfig.builder() + @Test + void relayLimitShouldBeSpecified() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) - public void relayLimitShouldNotBeNull() throws Exception { - testee.init(FakeMatcherConfig.builder() + @Test + void relayLimitShouldNotBeNull() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("0") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) - public void relayLimitShouldThrowWhenConditionLessThanZero() throws Exception { - testee.init(FakeMatcherConfig.builder() + @Test + void relayLimitShouldThrowWhenConditionLessThanZero() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("-1") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void shouldNotMatchWhenNoReceivedHeader() throws Exception { + void shouldNotMatchWhenNoReceivedHeader() throws Exception { testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("2") @@ -92,7 +101,7 @@ public class RelayLimitTest { @Test - public void shouldNotMatchWhenNotEnoughReceivedHeader() throws Exception { + void shouldNotMatchWhenNotEnoughReceivedHeader() throws Exception { testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("2") @@ -104,7 +113,7 @@ public class RelayLimitTest { } @Test - public void shouldMatchWhenEqualToLimit() throws Exception { + void shouldMatchWhenEqualToLimit() throws Exception { testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("2") @@ -117,7 +126,7 @@ public class RelayLimitTest { } @Test - public void shouldMatchWhenWhenOverLimit() throws Exception { + void shouldMatchWhenWhenOverLimit() throws Exception { testee.init(FakeMatcherConfig.builder() .matcherName("RelayLimit") .condition("2")
http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java index 67c7425..7c47bea 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java @@ -29,14 +29,14 @@ import org.apache.mailet.base.MailAddressFixture; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMailContext; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SMTPAuthSuccessfulTest { private SMTPAuthSuccessful testee; - @Before + @BeforeEach public void setUp() throws Exception { testee = new SMTPAuthSuccessful(); testee.init(FakeMatcherConfig.builder().matcherName("matcherName") http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java index 4e1908d..ef19a41 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java @@ -20,6 +20,8 @@ package org.apache.james.transport.matchers; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.Collection; import javax.mail.MessagingException; @@ -27,6 +29,7 @@ import javax.mail.MessagingException; import org.apache.james.core.MailAddress; import org.apache.mailet.Mail; import org.apache.mailet.base.GenericMatcher; +import org.junit.jupiter.api.Test; public class SMTPAuthUserIsTest extends AbstractHasMailAttributeTest { @@ -53,8 +56,8 @@ public class SMTPAuthUserIsTest extends AbstractHasMailAttributeTest { } - // test if the mail attribute was not matched @Override + @Test public void testAttributeIsNotMatched() throws MessagingException { setupAll(); setMailAttributeValue("notmatc...@james.apache.org"); http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java index 3ce6235..9860001 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java @@ -24,15 +24,15 @@ import static org.assertj.core.api.Assertions.assertThat; import org.apache.james.core.MailAddress; import org.apache.mailet.Mail; import org.apache.mailet.base.test.FakeMail; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SMTPIsAuthNetworkTest { private SMTPIsAuthNetwork testee; private MailAddress recipient; - @Before + @BeforeEach public void setUp() throws Exception { testee = new SMTPIsAuthNetwork(); recipient = new MailAddress("recipi...@domain.com"); http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java index 86e6e85..5d5982c 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java @@ -38,14 +38,14 @@ import org.apache.mailet.MailetContext; import org.apache.mailet.Matcher; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SenderHostIsLocalTest { private Matcher matcher; - @Before + @BeforeEach public void setUp() throws MessagingException { MailetContext mailContext = mock(MailetContext.class); when(mailContext.isLocalServer(JAMES_APACHE_ORG)).thenReturn(true); http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java index c4f85c0..0be03f0 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java @@ -22,6 +22,7 @@ package org.apache.james.transport.matchers; import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES2; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import java.util.Collection; @@ -33,23 +34,23 @@ import org.apache.mailet.Mail; import org.apache.mailet.MailetContext; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SenderHostIsTest { private SenderHostIs matcher; private MailetContext mailContext; - @Before - public void setUp() throws MessagingException { + @BeforeEach + void setUp() { mailContext = mock(MailetContext.class); matcher = new SenderHostIs(); } @Test - public void shouldMatchWhenSenderHostIsKnown() throws MessagingException { + void shouldMatchWhenSenderHostIsKnown() throws MessagingException { //Given FakeMatcherConfig mci = FakeMatcherConfig.builder() .matcherName("SenderHostIs") @@ -70,7 +71,7 @@ public class SenderHostIsTest { } @Test - public void shouldNotMatchWhenSenderHostIsUnknown() throws MessagingException { + void shouldNotMatchWhenSenderHostIsUnknown() throws MessagingException { //Given matcher.init(FakeMatcherConfig.builder() .matcherName("SenderHostIs") @@ -90,7 +91,7 @@ public class SenderHostIsTest { } @Test - public void shouldNotMatchWhenEmptyList() throws MessagingException { + void shouldNotMatchWhenEmptyList() throws MessagingException { //Given matcher.init(FakeMatcherConfig.builder() .matcherName("SenderHostIs") @@ -109,7 +110,7 @@ public class SenderHostIsTest { } @Test - public void shouldNotMatchWhenNullSender() throws MessagingException { + void shouldNotMatchWhenNullSender() throws MessagingException { //Given matcher.init(FakeMatcherConfig.builder() .matcherName("SenderHostIs") @@ -126,18 +127,19 @@ public class SenderHostIsTest { assertThat(actual).isNull(); } - @Test(expected = NullPointerException.class) - public void shouldThrowWhenNullCondition() throws Exception { - //When - matcher.init(FakeMatcherConfig.builder() + @Test + void shouldThrowWhenNullCondition() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("SenderHostIs") .mailetContext(mailContext) .condition(null) - .build()); + .build())) + .isInstanceOf(NullPointerException.class); } @Test - public void parseDomainsListShouldParseWhenOnlyOneDomain() { + void parseDomainsListShouldParseWhenOnlyOneDomain() { //When Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org"); //Then @@ -145,7 +147,7 @@ public class SenderHostIsTest { } @Test - public void parseDomainsListShouldParseWhenCommaSpacePattern() { + void parseDomainsListShouldParseWhenCommaSpacePattern() { //When Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org, james2.apache.org, james3.apache.org, james4.apache.org, james5.apache.org"); //Then @@ -153,7 +155,7 @@ public class SenderHostIsTest { } @Test - public void parseDomainsListShouldParseWhenCommaPattern() { + void parseDomainsListShouldParseWhenCommaPattern() { //When Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org,james2.apache.org,james3.apache.org,james4.apache.org,james5.apache.org"); //Then @@ -161,7 +163,7 @@ public class SenderHostIsTest { } @Test - public void parseDomainsListShouldParseWhenSpacePattern() { + void parseDomainsListShouldParseWhenSpacePattern() { //When Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org james2.apache.org james3.apache.org james4.apache.org james5.apache.org"); //Then @@ -169,7 +171,7 @@ public class SenderHostIsTest { } @Test - public void parseDomainsListShouldParseWhenMixedPatterns() { + void parseDomainsListShouldParseWhenMixedPatterns() { //When Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org james2.apache.org,james3.apache.org, james4.apache.org james5.apache.org"); //Then @@ -177,7 +179,7 @@ public class SenderHostIsTest { } @Test - public void parseDomainsListShouldIgnoreEmptyDomains() { + void parseDomainsListShouldIgnoreEmptyDomains() { //When Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org james2.apache.org james3.apache.org , james4.apache.org,,,james5.apache.org"); //Then http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java index d47bea1..97498a0 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java @@ -36,14 +36,14 @@ import org.apache.mailet.MailetContext; import org.apache.mailet.Matcher; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SenderIsLocalTest { private Matcher matcher; - @Before + @BeforeEach public void setUp() throws MessagingException { MailetContext mailContext = mock(MailetContext.class); when(mailContext.isLocalEmail(ANY_AT_JAMES)).thenReturn(true); http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java index 1c2b429..0b38c45 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java @@ -25,20 +25,15 @@ import static org.assertj.core.api.Assertions.assertThat; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class SenderIsNullTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class SenderIsNullTest { private SenderIsNull matcher; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { matcher = new SenderIsNull(); matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsNull") @@ -46,7 +41,7 @@ public class SenderIsNullTest { } @Test - public void shouldMatchWhenNullSender() throws Exception { + void shouldMatchWhenNullSender() throws Exception { FakeMail fakeMail = FakeMail.builder() .recipient(ANY_AT_JAMES) .build(); @@ -55,7 +50,7 @@ public class SenderIsNullTest { } @Test - public void shouldNotMatchWhenSenderIsPresent() throws Exception { + void shouldNotMatchWhenSenderIsPresent() throws Exception { FakeMail fakeMail = FakeMail.builder() .recipient(ANY_AT_JAMES) .sender("ot...@james.apache.org") http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java index f5668fb..7bf5c49 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java @@ -21,34 +21,30 @@ package org.apache.james.transport.matchers; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import javax.mail.MessagingException; import org.apache.james.core.MailAddress; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class SenderIsRegexTest { +class SenderIsRegexTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - public static final String SENDER_NAME = "t...@james.apache.org"; + private static final String SENDER_NAME = "t...@james.apache.org"; private SenderIsRegex matcher; private MailAddress recipient; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { matcher = new SenderIsRegex(); recipient = new MailAddress("recipi...@apache.org"); } @Test - public void shouldMatchOnMatchingPattern() throws Exception { + void shouldMatchOnMatchingPattern() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") .condition(".*@.*") @@ -63,7 +59,7 @@ public class SenderIsRegexTest { } @Test - public void shouldNotMatchSubParts() throws Exception { + void shouldNotMatchSubParts() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") .condition("test") @@ -78,7 +74,7 @@ public class SenderIsRegexTest { } @Test - public void shouldNotMatchWhenNullSender() throws Exception { + void shouldNotMatchWhenNullSender() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") .condition(".*@.*") @@ -92,7 +88,7 @@ public class SenderIsRegexTest { } @Test - public void shouldNotMatchOnNonMatchingPattern() throws Exception { + void shouldNotMatchOnNonMatchingPattern() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") .condition("^\\.") @@ -107,27 +103,30 @@ public class SenderIsRegexTest { } @Test - public void initShouldThrowWhenEmptyCondition() throws MessagingException { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void initShouldThrowWhenEmptyCondition() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowWhenNoConditions() throws MessagingException { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void initShouldThrowWhenNoConditions() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowWhenInvalidPattern() throws MessagingException { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void initShouldThrowWhenInvalidPattern() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIsRegex") .condition("(.") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java index e739959..fbfffa5 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java @@ -21,35 +21,31 @@ package org.apache.james.transport.matchers; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import javax.mail.MessagingException; import org.apache.james.core.MailAddress; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class SenderIsTest { +class SenderIsTest { private static final String SENDER_NAME = "t...@james.apache.org"; - @Rule - public ExpectedException expectedException = ExpectedException.none(); - private SenderIs matcher; private MailAddress recipient; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { matcher = new SenderIs(); recipient = new MailAddress("recipi...@james.apache.org"); } @Test - public void shouldMatchWhenGoodSender() throws Exception { + void shouldMatchWhenGoodSender() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIs") .condition(SENDER_NAME) @@ -64,7 +60,7 @@ public class SenderIsTest { } @Test - public void shouldNotMatchWhenWrongSender() throws Exception { + void shouldNotMatchWhenWrongSender() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIs") .condition(SENDER_NAME) @@ -79,7 +75,7 @@ public class SenderIsTest { } @Test - public void shouldNotMatchWhenNullSender() throws Exception { + void shouldNotMatchWhenNullSender() throws Exception { matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIs") .condition(SENDER_NAME) @@ -93,7 +89,7 @@ public class SenderIsTest { } @Test - public void senderIsShouldBeConfigurableWithSeveralAddresses() throws Exception { + void senderIsShouldBeConfigurableWithSeveralAddresses() throws Exception { String mailAddress = "a...@apache.org"; matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIs") @@ -104,18 +100,20 @@ public class SenderIsTest { } @Test - public void senderIsShouldThrowWhenNoAddressesPassedByConfiguration() throws Exception { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void senderIsShouldThrowWhenNoAddressesPassedByConfiguration() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIs") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void senderIsShouldThrowWhenNoConfiguration() throws Exception { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void senderIsShouldThrowWhenNoConfiguration() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("SenderIs") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java index 8d04492..4b5ee71 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java @@ -29,14 +29,14 @@ import org.apache.mailet.base.MailAddressFixture; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMailContext; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SentByMailetTest { private SentByMailet testee; - @Before + @BeforeEach public void setUp() throws Exception { testee = new SentByMailet(); testee.init(FakeMatcherConfig.builder().matcherName("matcherName") http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java index 9bfca72..2ef630f 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java @@ -21,6 +21,7 @@ package org.apache.james.transport.matchers; import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import javax.mail.MessagingException; @@ -28,25 +29,20 @@ import org.apache.mailet.Mail; import org.apache.mailet.Matcher; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class SizeGreaterThanTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class SizeGreaterThanTest { private Matcher matcher; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() { matcher = new SizeGreaterThan(); } @Test - public void matchShouldMatchWhenMailAboveSize() throws MessagingException { + void matchShouldMatchWhenMailAboveSize() throws MessagingException { Mail mail = FakeMail.builder() .size(2000000) .recipient(ANY_AT_JAMES) @@ -63,7 +59,7 @@ public class SizeGreaterThanTest { } @Test - public void matchShouldNotMatchWhenMailUnderSize() throws MessagingException { + void matchShouldNotMatchWhenMailUnderSize() throws MessagingException { Mail mail = FakeMail.builder() .size(200000) .recipient(ANY_AT_JAMES) @@ -80,7 +76,7 @@ public class SizeGreaterThanTest { } @Test - public void matchShouldNotMatchMailsWithSpecifiedSize() throws MessagingException { + void matchShouldNotMatchMailsWithSpecifiedSize() throws MessagingException { Mail mail = FakeMail.builder() .size(1024) .recipient(ANY_AT_JAMES) @@ -97,7 +93,7 @@ public class SizeGreaterThanTest { } @Test - public void matchShouldMatchMailsWithSizeSuperiorToSpecifiedSize() throws MessagingException { + void matchShouldMatchMailsWithSizeSuperiorToSpecifiedSize() throws MessagingException { Mail mail = FakeMail.builder() .size(1025) .recipient(ANY_AT_JAMES) @@ -114,7 +110,7 @@ public class SizeGreaterThanTest { } @Test - public void matchShouldReturnNullWhenUnderLimitNoUnit() throws MessagingException { + void matchShouldReturnNullWhenUnderLimitNoUnit() throws MessagingException { Mail mail = FakeMail.builder() .size(4) .recipient(ANY_AT_JAMES) @@ -131,7 +127,7 @@ public class SizeGreaterThanTest { } @Test - public void matchShouldMatchOverLimitWhenNoUnit() throws MessagingException { + void matchShouldMatchOverLimitWhenNoUnit() throws MessagingException { Mail mail = FakeMail.builder() .size(5) .recipient(ANY_AT_JAMES) @@ -148,33 +144,35 @@ public class SizeGreaterThanTest { } @Test - public void initShouldThrowOnInvalidUnits() throws Exception { - expectedException.expect(MessagingException.class); + void initShouldThrowOnInvalidUnits() { FakeMatcherConfig matcherConfiguration = FakeMatcherConfig.builder() .matcherName("SizeGreaterThan") .condition("1mb") .build(); - matcher.init(matcherConfiguration); + assertThatThrownBy(() -> matcher.init(matcherConfiguration)) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) - public void initShouldThrowOnNullSize() throws Exception { + @Test + void initShouldThrowOnNullSize() { FakeMatcherConfig matcherConfiguration = FakeMatcherConfig.builder() .matcherName("SizeGreaterThan") .condition("0") .build(); - matcher.init(matcherConfiguration); + assertThatThrownBy(() -> matcher.init(matcherConfiguration)) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) - public void initShouldThrowOnNegativeSize() throws Exception { + @Test + void initShouldThrowOnNegativeSize() { FakeMatcherConfig matcherConfiguration = FakeMatcherConfig.builder() .matcherName("SizeGreaterThan") .condition("-1") .build(); - matcher.init(matcherConfiguration); + assertThatThrownBy(() -> matcher.init(matcherConfiguration)) + .isInstanceOf(MessagingException.class); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java index 11193fa..22f5c75 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java @@ -29,15 +29,15 @@ import org.apache.james.core.MailAddress; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; import org.apache.mailet.base.test.MailUtil; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SubjectIsTest { private SubjectIs matcher; private MailAddress roger; - @Before + @BeforeEach public void setup() throws AddressException { matcher = new SubjectIs(); roger = new MailAddress("ro...@nasa.org"); http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java index e927980..a590b9b 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java @@ -29,15 +29,15 @@ import org.apache.james.core.MailAddress; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; import org.apache.mailet.base.test.MailUtil; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SubjectStartsWithTest { private SubjectStartsWith matcher; private MailAddress roger; - @Before + @BeforeEach public void setup() throws AddressException { matcher = new SubjectStartsWith(); roger = new MailAddress("ro...@nasa.org"); http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java index bd08510..29a8495 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java @@ -20,6 +20,7 @@ package org.apache.james.transport.matchers; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Collection; @@ -29,73 +30,68 @@ import org.apache.james.core.MailAddress; import org.apache.james.core.builder.MimeMessageBuilder; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class TooManyLinesTest { +class TooManyLinesTest { private TooManyLines testee; - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setUp() { + @BeforeEach + void setUp() { testee = new TooManyLines(); } @Test - public void initShouldThrowOnAbsentCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder().matcherName("name").build()); + void initShouldThrowOnAbsentCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder().matcherName("name").build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnInvalidCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init( - FakeMatcherConfig.builder() - .condition("a") - .matcherName("name") - .build()); + void initShouldThrowOnInvalidCondition() { + assertThatThrownBy(() -> + testee.init( + FakeMatcherConfig.builder() + .condition("a") + .matcherName("name") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnEmptyCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("") - .matcherName("name") - .build()); + void initShouldThrowOnEmptyCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("") + .matcherName("name") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnZeroCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("0") - .matcherName("name") - .build()); + void initShouldThrowOnZeroCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("0") + .matcherName("name") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnNegativeCondition() throws MessagingException { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("-10") - .matcherName("name") - .build()); + void initShouldThrowOnNegativeCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("-10") + .matcherName("name") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void matchShouldReturnNoRecipientWhenMailHaveNoMimeMessageAndConditionIs100() throws Exception { + void matchShouldReturnNoRecipientWhenMailHaveNoMimeMessageAndConditionIs100() throws Exception { testee.init(FakeMatcherConfig.builder() .condition("100") .matcherName("name") @@ -108,7 +104,7 @@ public class TooManyLinesTest { } @Test - public void matchShouldAcceptMailsUnderLimit() throws Exception { + void matchShouldAcceptMailsUnderLimit() throws Exception { testee.init(FakeMatcherConfig.builder() .condition("100") .matcherName("name") @@ -126,7 +122,7 @@ public class TooManyLinesTest { } @Test - public void matchShouldRejectMailsOverLimit() throws Exception { + void matchShouldRejectMailsOverLimit() throws Exception { testee.init(FakeMatcherConfig.builder().condition("10").matcherName("name").build()); FakeMail fakeMail = FakeMail.builder() http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java index 4a6c726..1aa47b8 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java @@ -20,6 +20,7 @@ package org.apache.james.transport.matchers; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Collection; @@ -28,76 +29,71 @@ import javax.mail.MessagingException; import org.apache.james.core.MailAddress; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; -public class TooManyRecipientsTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class TooManyRecipientsTest { private TooManyRecipients testee; - @Before - public void setUp() { + @BeforeEach + void setUp() { testee = new TooManyRecipients(); } @Test - public void initShouldThrowOnAbsentCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .matcherName("matcherName") - .build()); + void initShouldThrowOnAbsentCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .matcherName("matcherName") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnInvalidCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("a") - .matcherName("matcherName") - .build()); + void initShouldThrowOnInvalidCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("a") + .matcherName("matcherName") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnEmptyCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("") - .matcherName("matcherName") - .build()); + void initShouldThrowOnEmptyCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("") + .matcherName("matcherName") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnZeroCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("0") - .matcherName("matcherName") - .build()); + void initShouldThrowOnZeroCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("0") + .matcherName("matcherName") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnNegativeCondition() throws Exception { - expectedException.expect(MessagingException.class); - - testee.init(FakeMatcherConfig.builder() - .condition("-10") - .matcherName("matcherName") - .build()); + void initShouldThrowOnNegativeCondition() { + assertThatThrownBy(() -> + testee.init(FakeMatcherConfig.builder() + .condition("-10") + .matcherName("matcherName") + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void matchShouldReturnNoRecipientWhenMailHaveNoRecipient() throws Exception { + void matchShouldReturnNoRecipientWhenMailHaveNoRecipient() throws Exception { testee.init(FakeMatcherConfig.builder() .condition("3") .matcherName("matcherName") @@ -109,7 +105,7 @@ public class TooManyRecipientsTest { } @Test - public void matchShouldAcceptMailsUnderLimit() throws Exception { + void matchShouldAcceptMailsUnderLimit() throws Exception { testee.init(FakeMatcherConfig.builder() .condition("3") .matcherName("matcherName") @@ -126,7 +122,7 @@ public class TooManyRecipientsTest { @Test - public void matchShouldAcceptMailsAtLimit() throws Exception { + void matchShouldAcceptMailsAtLimit() throws Exception { testee.init(FakeMatcherConfig.builder() .condition("3") .matcherName("matcherName") @@ -142,7 +138,7 @@ public class TooManyRecipientsTest { } @Test - public void matchShouldRejectMailsOverLimit() throws Exception { + void matchShouldRejectMailsOverLimit() throws Exception { testee.init(FakeMatcherConfig.builder() .condition("3") .matcherName("matcherName") http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java index 348896c..2b89b45 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java @@ -24,30 +24,26 @@ import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES; import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES2; import static org.apache.mailet.base.MailAddressFixture.OTHER_AT_JAMES; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import javax.mail.MessagingException; import org.apache.mailet.base.test.FakeMail; import org.apache.mailet.base.test.FakeMatcherConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class UserIsTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class UserIsTest { private UserIs matcher; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() { matcher = new UserIs(); } @Test - public void shouldMatchCorrespondingUser() throws MessagingException { + void shouldMatchCorrespondingUser() throws MessagingException { matcher.init(FakeMatcherConfig.builder() .matcherName("UserIs") .condition("any") @@ -61,7 +57,7 @@ public class UserIsTest { } @Test - public void shouldMatchCorrespondingUserAccrossDomains() throws MessagingException { + void shouldMatchCorrespondingUserAccrossDomains() throws MessagingException { matcher.init(FakeMatcherConfig.builder() .matcherName("UserIs") .condition("any") @@ -75,7 +71,7 @@ public class UserIsTest { } @Test - public void shouldNotMatchNonSpecifiedUsersButPreserveSpecifiedUsers() throws MessagingException { + void shouldNotMatchNonSpecifiedUsersButPreserveSpecifiedUsers() throws MessagingException { matcher.init(FakeMatcherConfig.builder() .matcherName("UserIs") .condition("any") @@ -89,7 +85,7 @@ public class UserIsTest { } @Test - public void shouldNotMatchNonSpecifiedUsers() throws MessagingException { + void shouldNotMatchNonSpecifiedUsers() throws MessagingException { matcher.init(FakeMatcherConfig.builder() .matcherName("UserIs") .condition("any") @@ -103,18 +99,20 @@ public class UserIsTest { } @Test - public void initShouldThrowOnMissingCondition() throws Exception { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void initShouldThrowOnMissingCondition() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("UserIs") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } @Test - public void initShouldThrowOnEmptyCondition() throws Exception { - expectedException.expect(MessagingException.class); - matcher.init(FakeMatcherConfig.builder() + void initShouldThrowOnEmptyCondition() { + assertThatThrownBy(() -> + matcher.init(FakeMatcherConfig.builder() .matcherName("UserIs") - .build()); + .build())) + .isInstanceOf(MessagingException.class); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java index c4b0d8a..cb3a296 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java @@ -20,44 +20,40 @@ package org.apache.james.transport.matchers.util; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.apache.james.core.MailAddress; import org.apache.james.transport.matchers.utils.MailAddressCollectionReader; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; -public class MailAddressCollectionReaderTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class MailAddressCollectionReaderTest { @Test - public void readShouldThrowOnNullInput() { - expectedException.expect(IllegalArgumentException.class); - MailAddressCollectionReader.read(null); + void readShouldThrowOnNullInput() { + assertThatThrownBy(() -> MailAddressCollectionReader.read(null)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void readShouldThrowOnEmptyInput() { - expectedException.expect(IllegalArgumentException.class); - MailAddressCollectionReader.read(""); + void readShouldThrowOnEmptyInput() { + assertThatThrownBy(() -> MailAddressCollectionReader.read("")) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void readShouldThrowOnInvalidEmail() { - expectedException.expect(RuntimeException.class); - MailAddressCollectionReader.read("not_valid"); + void readShouldThrowOnInvalidEmail() { + assertThatThrownBy(() -> MailAddressCollectionReader.read("not_valid")) + .isInstanceOf(RuntimeException.class); } @Test - public void readShouldThrowOnInvalidEmailOnSecondPosition() { - expectedException.expect(RuntimeException.class); - MailAddressCollectionReader.read("va...@apache.org, not_valid"); + void readShouldThrowOnInvalidEmailOnSecondPosition() { + assertThatThrownBy(() -> MailAddressCollectionReader.read("va...@apache.org, not_valid")) + .isInstanceOf(RuntimeException.class); } @Test - public void readShouldParseOneEmail() throws Exception { + void readShouldParseOneEmail() throws Exception { MailAddress mailAddress = new MailAddress("va...@apache.org"); assertThat(MailAddressCollectionReader.read(mailAddress.toString())) @@ -65,7 +61,7 @@ public class MailAddressCollectionReaderTest { } @Test - public void readShouldParseTwoEmailSeparatedByComaOnly() throws Exception { + void readShouldParseTwoEmailSeparatedByComaOnly() throws Exception { MailAddress mailAddress1 = new MailAddress("va...@apache.org"); MailAddress mailAddress2 = new MailAddress("b...@apache.org"); @@ -74,7 +70,7 @@ public class MailAddressCollectionReaderTest { } @Test - public void readShouldParseTwoEmailSeparatedBySpaceOnly() throws Exception { + void readShouldParseTwoEmailSeparatedBySpaceOnly() throws Exception { MailAddress mailAddress1 = new MailAddress("va...@apache.org"); MailAddress mailAddress2 = new MailAddress("b...@apache.org"); @@ -83,7 +79,7 @@ public class MailAddressCollectionReaderTest { } @Test - public void readShouldParseTwoEmailSeparatedByTabOnly() throws Exception { + void readShouldParseTwoEmailSeparatedByTabOnly() throws Exception { MailAddress mailAddress1 = new MailAddress("va...@apache.org"); MailAddress mailAddress2 = new MailAddress("b...@apache.org"); @@ -93,7 +89,7 @@ public class MailAddressCollectionReaderTest { @Test - public void readShouldParseTwoEmailSeparatorsCombination() throws Exception { + void readShouldParseTwoEmailSeparatorsCombination() throws Exception { MailAddress mailAddress1 = new MailAddress("va...@apache.org"); MailAddress mailAddress2 = new MailAddress("b...@apache.org"); @@ -102,7 +98,7 @@ public class MailAddressCollectionReaderTest { } @Test - public void readShouldRemoveDuplicates() throws Exception { + void readShouldRemoveDuplicates() throws Exception { MailAddress mailAddress = new MailAddress("va...@apache.org"); assertThat(MailAddressCollectionReader.read(mailAddress.toString() + ", " + mailAddress.toString())) http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2bedd6c..37c9f6b 100644 --- a/pom.xml +++ b/pom.xml @@ -2217,6 +2217,11 @@ <version>${junit.jupiter.version}</version> </dependency> <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <version>${junit.jupiter.version}</version> + </dependency> + <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-launcher</artifactId> <version>${junit.plateform.version}</version> --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org