Java Code Examples for com.icegreen.greenmail.util.ServerSetup#PROTOCOL_SMTP

The following examples show how to use com.icegreen.greenmail.util.ServerSetup#PROTOCOL_SMTP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SshdShellAutoConfigurationTest.java    From sshd-shell-spring-boot with Apache License 2.0 6 votes vote down vote up
@Test
public void testHealthInfoCommand() {
    int smtpPort = SocketUtils.findAvailableTcpPort();
    ServerSetup setup = new ServerSetup(smtpPort, null, ServerSetup.PROTOCOL_SMTP);
    setup.setServerStartupTimeout(5000);
    GreenMail mailServer = new GreenMail(setup);
    JavaMailSenderImpl jmsi = (JavaMailSenderImpl) mailSender;
    mailServer.setUser(jmsi.getUsername(), jmsi.getPassword());
    mailServer.start();
    jmsi.setPort(smtpPort);
    sshCallShell((is, os) -> {
        write(os, "health info");
        verifyResponseContains(is, "{\r\n  \"status\" : \"UP\"");
        mailServer.stop();
    });
}
 
Example 2
Source File: GreenMailStartStopListener.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public void contextInitialized(final ServletContextEvent sce) {
    ServletContext sc = sce.getServletContext();
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sc);

    InterruptableGreenMail greenMail = (InterruptableGreenMail) sc.getAttribute(GREENMAIL);
    if (greenMail == null) {
        ServerSetup[] config = new ServerSetup[2];
        config[0] = new ServerSetup(
                ctx.getEnvironment().getProperty("testmail.smtpport", Integer.class),
                "localhost", ServerSetup.PROTOCOL_SMTP);
        config[1] = new ServerSetup(
                ctx.getEnvironment().getProperty("testmail.pop3port", Integer.class),
                "localhost", ServerSetup.PROTOCOL_POP3);
        greenMail = new InterruptableGreenMail(config);
        greenMail.start();

        sc.setAttribute(GREENMAIL, greenMail);
    }

    LOG.info("SMTP and POP3 servers successfully (re)started");
}
 
Example 3
Source File: SendEmailTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Mock a smtp server.
 * @return GreenMail smtp server.
 * @throws IOException If something goes wrong.
 */
public GreenMail smtpServer(String bind, int port) throws IOException {
    return new GreenMail(
        new ServerSetup(
            port, bind,
            ServerSetup.PROTOCOL_SMTP
        )
    );
}
 
Example 4
Source File: AllocateAvailablePortTest.java    From greenmail with Apache License 2.0 4 votes vote down vote up
private ServerSetup smtpServerAtPort(int port) {
    return new ServerSetup(port, null, ServerSetup.PROTOCOL_SMTP);
}