INT-4097: Fix Test IMAP Mail Server
JIRA: https://jira.spring.io/browse/INT-4097 Mismatched From/To headers when using a header mapper.
This commit is contained in:
@@ -81,7 +81,7 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.mail.ImapIdleChannelAdapter.ImapIdleExceptionEvent;
|
||||
import org.springframework.integration.mail.PoorMansMailServer.ImapServer;
|
||||
import org.springframework.integration.mail.TestMailServer.ImapServer;
|
||||
import org.springframework.integration.mail.config.ImapIdleChannelAdapterParserTests;
|
||||
import org.springframework.integration.mail.support.DefaultMailHeaderMapper;
|
||||
import org.springframework.integration.test.support.LongRunningIntegrationTest;
|
||||
@@ -105,7 +105,7 @@ public class ImapMailReceiverTests {
|
||||
|
||||
private final AtomicInteger failed = new AtomicInteger(0);
|
||||
|
||||
private final static ImapServer imapIdleServer = PoorMansMailServer.imap(0);
|
||||
private final static ImapServer imapIdleServer = TestMailServer.imap(0);
|
||||
|
||||
|
||||
@BeforeClass
|
||||
@@ -195,6 +195,9 @@ public class ImapMailReceiverTests {
|
||||
equalTo("TEXT/PLAIN; charset=ISO-8859-1"));
|
||||
assertThat((String) received.getHeaders().get(MessageHeaders.CONTENT_TYPE),
|
||||
equalTo("TEXT/PLAIN; charset=ISO-8859-1"));
|
||||
assertThat((String) received.getHeaders().get(MailHeaders.FROM), equalTo("Bar <bar@baz>"));
|
||||
assertThat(((String[]) received.getHeaders().get(MailHeaders.TO))[0], equalTo("Foo <foo@bar>"));
|
||||
assertThat((String) received.getHeaders().get(MailHeaders.SUBJECT), equalTo("Test Email"));
|
||||
}
|
||||
assertNotNull(channel.receive(10000)); // new message after idle
|
||||
assertNull(channel.receive(10000)); // no new message after second and third idle
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.Base64Utils;
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class PoorMansMailServer {
|
||||
public class TestMailServer {
|
||||
|
||||
public static SmtpServer smtp(int port) {
|
||||
try {
|
||||
@@ -282,10 +282,10 @@ public class PoorMansMailServer {
|
||||
write("* 1 FETCH (RFC822.SIZE 6909 INTERNALDATE \"27-May-2013 09:45:41 +0000\" "
|
||||
+ "FLAGS (\\Seen) "
|
||||
+ "ENVELOPE (\"Mon, 27 May 2013 15:14:49 +0530\" "
|
||||
+ "\"Test Email\" ((\"Foo\" NIL \"foo\" \"bar.tv\")) "
|
||||
+ "\"Test Email\" ((\"Bar\" NIL \"bar\" \"baz\")) "
|
||||
+ "((\"Foo\" NIL \"foo\" \"bar.tv\")) "
|
||||
+ "((\"Foo\" NIL \"foo\" \"bar.tv\")) "
|
||||
+ "((\"Bar\" NIL \"bar\" \"baz.net\")) NIL NIL "
|
||||
+ "((\"Foo\" NIL \"foo\" \"bar\")) NIL NIL "
|
||||
+ "\"<4DA0A7E4.3010506@baz.net>\" "
|
||||
+ "\"<CACVnpJkAUUfa3d_-4GNZW2WpxbB39tBCHC=T0gc7hty6dOEHcA@foo.bar.com>\") "
|
||||
+ "BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"ISO-8859-1\") NIL NIL \"7BIT\" 1176 43)))");
|
||||
@@ -433,7 +433,8 @@ public class PoorMansMailServer {
|
||||
|
||||
public abstract class MailHandler implements Runnable {
|
||||
|
||||
protected static final String MESSAGE = "To: foo@bar\r\nFrom: bar@baz\r\nSubject: Test Email\r\n\r\nfoo";
|
||||
protected static final String MESSAGE =
|
||||
"To: Foo <foo@bar>\r\nFrom: Bar <bar@baz>\r\nSubject: Test Email\r\n\r\nfoo";
|
||||
|
||||
protected final Socket socket;
|
||||
|
||||
@@ -471,7 +472,7 @@ public class PoorMansMailServer {
|
||||
|
||||
}
|
||||
|
||||
private PoorMansMailServer() {
|
||||
private TestMailServer() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user