public String verifyMail() throws Exception { List<String> messages = smtpServer.getMessages(); int n = 0; while (n++ < 100 && messages.size() < 1) { Thread.sleep(100); } assertThat(messages).hasSize(1); return messages.get(0); }
@BeforeClass public static void setup() { // Configure the boot property to send email to the test email server. System.setProperty("spring.mail.port", Integer.toString(smtpServer.getPort())); }
@Override public void resetServer() { super.resetServer(); this.seen = false; this.idled = false; }
@BeforeClass public static void setup() throws InterruptedException { int n = 0; while (n++ < 100 && (!smtpServer.isListening() || !pop3Server.isListening() || !imapServer.isListening()) || !imapIdleServer.isListening()) { Thread.sleep(100); } assertTrue(n < 100); }
@AfterClass public static void tearDown() { smtpServer.stop(); }
@After public void tearDown() { this.imapIdleServer.stop(); }
@AfterClass public static void tearDown() { pop3Server.stop(); }
@Before public void setup() throws InterruptedException { int n = 0; while (n++ < 100 && (!this.imapIdleServer.isListening())) { Thread.sleep(100); } assertTrue(n < 100); }
@BeforeClass public static void setup() throws InterruptedException { int n = 0; while (n++ < 100 && (!smtpServer.isListening())) { Thread.sleep(100); } assertTrue(n < 100); }
@BeforeClass public static void setup() throws InterruptedException { int n = 0; while (n++ < 100 && (!pop3Server.isListening())) { Thread.sleep(100); } assertTrue(n < 100); }
@Override protected MailHandler mailHandler(Socket socket) { return new ImapHandler(socket); }
@Override protected MailHandler mailHandler(Socket socket) { return new SmtpHandler(socket); }
@Override protected MailHandler mailHandler(Socket socket) { return new Pop3Handler(socket); }
public static Pop3Server pop3(int port) { try { return new Pop3Server(port); } catch (IOException e) { throw new RuntimeException(e); } }
public static ImapServer imap(int port) { try { return new ImapServer(port); } catch (IOException e) { throw new RuntimeException(e); } }
public static SmtpServer smtp(int port) { try { return new SmtpServer(port); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void run() { try { while (!serverSocket.isClosed()) { Socket socket = this.serverSocket.accept(); exec.execute(mailHandler(socket)); } } catch (IOException e) { this.listening = false; } }
@Before public void beforeTest() throws IOException { smtpServer.getMessages().clear(); tearDown(); this.fileInboundChannelAdapter.start(); }