Repository: james-project Updated Branches: refs/heads/master 336d1f94b -> 0d416804a
JAMES-2361 Don't rely on method name, use instead a class Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0dbf48c5 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0dbf48c5 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0dbf48c5 Branch: refs/heads/master Commit: 0dbf48c58b11089e5e37fcdc13beb0938f1ed00d Parents: 1e365b3 Author: Raphael Ouazana <raphael.ouaz...@linagora.com> Authored: Fri Mar 23 11:36:19 2018 +0100 Committer: Matthieu Baechler <matth...@apache.org> Committed: Mon Mar 26 14:57:23 2018 +0200 ---------------------------------------------------------------------- .../james/transport/mailets/AddFooterTest.java | 57 +++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/0dbf48c5/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java index b5e0abb..0c3b75a 100644 --- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java +++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java @@ -37,9 +37,11 @@ import org.apache.mailet.base.test.FakeMailetConfig; import org.apache.mailet.base.test.MailUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import com.google.common.base.Joiner; import com.google.common.collect.Lists; @@ -51,30 +53,33 @@ class AddFooterTest { private Mailet mailet; - private static Stream<Arguments> charsetTuples() { - //javamail has its own charset handling logic, it needs to be exercised - List<String> charsetNamesToTest = Lists.newArrayList( - "ANSI_X3.4-1968", - "iso-ir-6", - "ANSI_X3.4-1986", - "ISO_646.irv:1991", - "ASCII", - "ISO646-US", - "US-ASCII", - "us", - "IBM367", - "cp367", - "csASCII"); - return charsetNamesToTest.stream().flatMap(from -> charsetNamesToTest.stream().map(to -> Arguments.of(from, to))); + static class CharsetTuples implements ArgumentsProvider { + @Override + public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception { + //javamail has its own charset handling logic, it needs to be exercised + List<String> charsetNamesToTest = Lists.newArrayList( + "ANSI_X3.4-1968", + "iso-ir-6", + "ANSI_X3.4-1986", + "ISO_646.irv:1991", + "ASCII", + "ISO646-US", + "US-ASCII", + "us", + "IBM367", + "cp367", + "csASCII"); + return charsetNamesToTest.stream().flatMap(from -> charsetNamesToTest.stream().map(to -> Arguments.of(from, to))); + } } - + @BeforeEach void setup() { mailet = new AddFooter(); } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldAddFooterWhenQuotedPrintableTextPlainMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") @@ -100,7 +105,7 @@ class AddFooterTest { } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldEnsureCarriageReturnWhenAddFooterWithTextPlainMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") @@ -126,7 +131,7 @@ class AddFooterTest { } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldNotAddFooterWhenUnsupportedEncoding(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") @@ -150,7 +155,7 @@ class AddFooterTest { } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldNotAddFooterWhenUnsupportedTextContentType(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") @@ -178,7 +183,7 @@ class AddFooterTest { * This should not add the header and should leave the multipart/mixed Content-Type intact */ @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldNotAddFooterWhenNestedUnsupportedMultipart(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") @@ -215,7 +220,7 @@ class AddFooterTest { * Test for JAMES-368 */ @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldAddFooterWhenMultipartRelatedHtmlMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName("Test") @@ -268,7 +273,7 @@ class AddFooterTest { } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldAddFooterWhenMultipartAlternivateMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() @@ -306,7 +311,7 @@ class AddFooterTest { } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldAddFooterWhenHtmlMessageWithMixedCaseBodyTag(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() @@ -334,7 +339,7 @@ class AddFooterTest { } @ParameterizedTest - @MethodSource("charsetTuples") + @ArgumentsSource(CharsetTuples.class) void shouldAddFooterWhenHtmlMessageWithNoBodyTag(String javaCharset, String javaMailCharset) throws MessagingException, IOException { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org