GH-3560 Parse mail FROM as comma-delimited header (#3562)
Fixes https://github.com/spring-projects/spring-integration/issues/3560 According RFC 5322 `FROM` and `REPLY-TO` received mail message can be as an array of addresses. * Fix `MailUtils` to present those arrays as comma-delimited strings for Spring message headers * Fix tests to deal already with several addresses for `FROM` mime header. In the future we may change the logic to map those mime headers to arrays as it states according the mentioned RFC **Cherry-pick to `5.4.x` & `5.3.x`**
This commit is contained in:
@@ -72,7 +72,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.mail.support.DefaultMailHeaderMapper;
|
||||
import org.springframework.integration.test.condition.LongRunningTest;
|
||||
import org.springframework.integration.test.mail.TestMailServer;
|
||||
import org.springframework.integration.test.mail.TestMailServer.ImapServer;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
@@ -97,7 +96,6 @@ import com.sun.mail.imap.IMAPFolder;
|
||||
@ContextConfiguration(
|
||||
"classpath:org/springframework/integration/mail/config/ImapIdleChannelAdapterParserTests-context.xml")
|
||||
@DirtiesContext
|
||||
@LongRunningTest
|
||||
public class ImapMailReceiverTests {
|
||||
|
||||
private AtomicInteger failed;
|
||||
@@ -703,7 +701,7 @@ public class ImapMailReceiverTests {
|
||||
|
||||
@Test // see INT-1801
|
||||
public void testImapLifecycleForRaceCondition() throws Exception {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
final ImapMailReceiver receiver = new ImapMailReceiver("imap://foo");
|
||||
Store store = mock(Store.class);
|
||||
Folder folder = mock(Folder.class);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Pop3Tests {
|
||||
assertThat(headers.get(MailHeaders.TO, String[].class)[0]).isEqualTo("Foo <foo@bar>");
|
||||
assertThat(Arrays.toString(headers.get(MailHeaders.CC, String[].class))).isEqualTo("[a@b, c@d]");
|
||||
assertThat(Arrays.toString(headers.get(MailHeaders.BCC, String[].class))).isEqualTo("[e@f, g@h]");
|
||||
assertThat(headers.get(MailHeaders.FROM)).isEqualTo("Bar <bar@baz>");
|
||||
assertThat(headers.get(MailHeaders.FROM)).isEqualTo("Bar <bar@baz>,Bar2 <bar2@baz>");
|
||||
assertThat(headers.get(MailHeaders.SUBJECT)).isEqualTo("Test Email");
|
||||
assertThat(message.getPayload()).isEqualTo("foo\r\n\r\n");
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class MailTests {
|
||||
assertThat(message).isNotNull();
|
||||
MessageHeaders headers = message.getHeaders();
|
||||
assertThat(headers.get(MailHeaders.TO, String[].class)).containsExactly("Foo <foo@bar>");
|
||||
assertThat(headers.get(MailHeaders.FROM)).isEqualTo("Bar <bar@baz>");
|
||||
assertThat(headers.get(MailHeaders.FROM)).isEqualTo("Bar <bar@baz>,Bar2 <bar2@baz>");
|
||||
assertThat(headers.get(MailHeaders.SUBJECT)).isEqualTo("Test Email");
|
||||
assertThat(message.getPayload()).isEqualTo("foo\r\n\r\n");
|
||||
assertThat(message.getHeaders().containsKey(IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE)).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user