io.rocketbase.commons.test.SmtpServerRule Maven / Gradle / Ivy
package io.rocketbase.commons.test;
import com.icegreen.greenmail.util.GreenMail;
import com.icegreen.greenmail.util.ServerSetup;
import org.junit.rules.ExternalResource;
import javax.mail.internet.MimeMessage;
public class SmtpServerRule extends ExternalResource {
private GreenMail smtpServer;
@Override
protected void before() throws Throwable {
super.before();
smtpServer = new GreenMail(new ServerSetup(2525, null, "smtp"));
smtpServer.start();
}
public MimeMessage[] getMessages() {
return smtpServer.getReceivedMessages();
}
@Override
protected void after() {
super.after();
smtpServer.stop();
}
}