Port TestMailServer to the SI-test module

To avoid copy/paste of `TestMailServer` in other projects (e.g. samples or Java DSL),
port `TestMailServer` from SI-5.0 to the shared `spring-integration-test` module

That allows to avoid unexpected SI-5.0 dependency in samples for SI-4.3
This commit is contained in:
Artem Bilan
2016-11-11 12:30:03 -05:00
parent 7d2120afb6
commit 476a0b706c
2 changed files with 17 additions and 8 deletions

View File

@@ -81,9 +81,9 @@ 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.TestMailServer.ImapServer;
import org.springframework.integration.mail.config.ImapIdleChannelAdapterParserTests;
import org.springframework.integration.mail.support.DefaultMailHeaderMapper;
import org.springframework.integration.test.mail.TestMailServer;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageHeaders;
@@ -105,7 +105,7 @@ public class ImapMailReceiverTests {
private final AtomicInteger failed = new AtomicInteger(0);
private final static ImapServer imapIdleServer = TestMailServer.imap(0);
private final static TestMailServer.ImapServer imapIdleServer = TestMailServer.imap(0);
@BeforeClass

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.mail;
package org.springframework.integration.test.mail;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -35,8 +35,15 @@ import javax.net.ServerSocketFactory;
import org.springframework.util.Base64Utils;
/**
* A basic test mail server for pop3, imap,
* Serves up a canned email message with each protocol.
* For smtp, it handles the basic handshaking and captures
* the pertinent data so it can be verified by a test case.
*
* @author Gary Russell
*
* @since 4.3.6
*
*/
public class TestMailServer {
@@ -283,8 +290,8 @@ public class TestMailServer {
+ "FLAGS (\\Seen) "
+ "ENVELOPE (\"Mon, 27 May 2013 15:14:49 +0530\" "
+ "\"Test Email\" ((\"Bar\" NIL \"bar\" \"baz\")) "
+ "((\"Foo\" NIL \"foo\" \"bar.tv\")) "
+ "((\"Foo\" NIL \"foo\" \"bar.tv\")) "
+ "((\"Bar\" NIL \"bar\" \"baz\")) "
+ "((\"Bar\" NIL \"bar\" \"baz\")) "
+ "((\"Foo\" NIL \"foo\" \"bar\")) NIL NIL "
+ "\"<4DA0A7E4.3010506@baz.net>\" "
+ "\"<CACVnpJkAUUfa3d_-4GNZW2WpxbB39tBCHC=T0gc7hty6dOEHcA@foo.bar.com>\") "
@@ -433,8 +440,10 @@ public class TestMailServer {
public abstract class MailHandler implements Runnable {
protected static final String MESSAGE =
"To: Foo <foo@bar>\r\nFrom: Bar <bar@baz>\r\nSubject: Test Email\r\n\r\nfoo";
public static final String BODY = "foo\r\n";
public static final String MESSAGE =
"To: Foo <foo@bar>\r\nFrom: Bar <bar@baz>\r\nSubject: Test Email\r\n\r\n" + BODY;
protected final Socket socket;