本文整理汇总了Java中com.icegreen.greenmail.util.ServerSetupTest类的典型用法代码示例。如果您正苦于以下问题:Java ServerSetupTest类的具体用法?Java ServerSetupTest怎么用?Java ServerSetupTest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerSetupTest类属于com.icegreen.greenmail.util包,在下文中一共展示了ServerSetupTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setup() throws Exception
{
node = new SmtpOutputOperator();
greenMail = new GreenMail(ServerSetupTest.ALL);
greenMail.start();
node.setFrom(from);
node.setContent(content);
node.setSmtpHost("127.0.0.1");
node.setSmtpPort(ServerSetupTest.getPortOffset() + ServerSetup.SMTP.getPort());
node.setSmtpUserName(from);
node.setSmtpPassword("<password>");
//node.setUseSsl(true);
node.setSubject(subject);
data = new HashMap<String, String>();
data.put("alertkey", "alertvalue");
}
示例2: testAllServices
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Test
public void testAllServices() throws MessagingException {
// Send messages via SMTP and secure SMTPS
GreenMailUtil.sendTextEmail("[email protected]", "[email protected]",
"test1", "Test GreenMail Docker service",
ServerSetupTest.SMTP.createCopy(bindAddress));
GreenMailUtil.sendTextEmail("[email protected]", "[email protected]",
"test2", "Test GreenMail Docker service",
ServerSetupTest.SMTPS.createCopy(bindAddress));
// IMAP
for (ServerSetup setup : Arrays.asList(
ServerSetupTest.IMAP.createCopy(bindAddress),
ServerSetupTest.IMAPS.createCopy(bindAddress),
ServerSetupTest.POP3.createCopy(bindAddress),
ServerSetupTest.POP3S.createCopy(bindAddress))) {
final Store store = Session.getInstance(setup.configureJavaMailSessionProperties(null, false)).getStore();
store.connect("[email protected]", "[email protected]");
try {
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
assertEquals("Can not check mails using "+store.getURLName(), 2, folder.getMessageCount());
} finally {
store.close();
}
}
}
示例3: setUp
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
// copy files
File folder = temp.newFolder("template", "mixed", "source");
IOUtils.copy(resource("template/mixed/source/simple.html"), folder.toPath().resolve("simple.html").toFile());
IOUtils.copy(resource("template/mixed/source/simple.txt.ftl"), folder.toPath().resolve("simple.txt.ftl").toFile());
// prepare ogham
oghamService = MessagingBuilder.standard()
.environment()
.properties("/application.properties")
.properties()
.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
.set("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()))
.set("ogham.email.template.path-prefix", folder.getParentFile().getParent()+"/")
.and()
.and()
.build();
}
示例4: setUp
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
greenMail.setUser("[email protected]", "test.sender", "password"); // <1>
Properties additionalProps = new Properties();
additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
additionalProps.setProperty("mail.smtp.auth", "true"); // <2>
additionalProps.setProperty("ogham.email.javamail.authenticator.username", "test.sender"); // <3>
additionalProps.setProperty("ogham.email.javamail.authenticator.password", "password"); // <4>
oghamService = MessagingBuilder.standard()
.environment()
.properties("/application.properties")
.properties(additionalProps)
.and()
.build();
}
示例5: setUp
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
// copy files
File folder = temp.newFolder("template", "mixed", "source");
File thymeleafFolder = folder.toPath().resolve("thymeleaf").toFile();
thymeleafFolder.mkdirs();
File freemarkerFolder = folder.toPath().resolve("freemarker").toFile();
freemarkerFolder.mkdirs();
IOUtils.copy(resource("template/thymeleaf/source/simple.html"), thymeleafFolder.toPath().resolve("simple.html").toFile());
IOUtils.copy(resource("template/freemarker/source/simple.txt.ftl"), freemarkerFolder.toPath().resolve("simple.txt.ftl").toFile());
// prepare ogham
oghamService = MessagingBuilder.standard()
.environment()
.properties("/application.properties")
.properties()
.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
.set("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()))
.set("ogham.email.thymeleaf.classpath.path-prefix", "/template/thymeleaf/source/")
.set("ogham.email.thymeleaf.file.path-prefix", thymeleafFolder.getAbsolutePath()+"/")
.set("ogham.email.freemarker.classpath.path-prefix", "/template/freemarker/source/")
.set("ogham.email.freemarker.file.path-prefix", freemarkerFolder.getAbsolutePath()+"/")
.and()
.and()
.build();
}
示例6: setUp
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
Properties additional = new Properties();
additional.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
additional.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
additional.setProperty("ogham.email.from", "[email protected]");
additional.setProperty("ogham.email.to", "[email protected],[email protected],[email protected]"); // <1>
additional.setProperty("ogham.email.cc", "[email protected],[email protected]"); // <2>
additional.setProperty("ogham.email.bcc", "[email protected]"); // <3>
oghamService = MessagingBuilder.standard()
.environment()
.properties("/application.properties")
.properties(additional)
.and()
.build();
}
示例7: setUp
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
Properties additionalProps = new Properties();
additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
sender = new JavaMailBuilder()
.environment()
.systemProperties()
.properties(additionalProps)
.and()
.mimetype()
.tika()
.failIfOctetStream(false)
.and()
.and()
.build();
}
示例8: setMailSenderParameters
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@BeforeMethod(description = "setup parameters need to create a smtp server.")
public void setMailSenderParameters() {
initProperties = new HashMap<>();
initProperties.put(EmailTestConstant.MAIL_SENDER_USERNAME, USERNAME);
initProperties.put(EmailTestConstant.MAIL_SENDER_PASSWORD, PASSWORD);
//green mail server use port 3025 to create a connection to local email server.
initProperties.put("mail.smtp.port", "3025");
//It is required to set auth 'true' to create connection.
initProperties.put("mail.smtp.auth", "true");
initProperties.put("mail.smtp.host", HOST);
//start the green mail server
mailServer = new GreenMail(ServerSetupTest.SMTP);
mailServer.start();
}
示例9: testReceive
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Test
public void testReceive() throws MessagingException, IOException {
//Start all email servers using non-default ports.
GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
try {
greenMail.start();
//Use random content to avoid potential residual lingering problems
final String subject = GreenMailUtil.random();
final String body = GreenMailUtil.random();
MimeMessage message = createMimeMessage(subject, body, greenMail); // Construct message
GreenMailUser user = greenMail.setUser("[email protected]", "waelc", "soooosecret");
user.deliver(message);
assertEquals(1, greenMail.getReceivedMessages().length);
// --- Place your retrieve code here
} finally {
greenMail.stop();
}
}
示例10: testStartStop
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Test
public void testStartStop() {
GreenMail service = new GreenMail(ServerSetupTest.ALL);
try {
// Try to stop before start: Nothing happens
service.stop();
service.start();
service.stop();
// Now the server is stopped, should be started by reset command
service.reset();
// Start again
service.reset();
} finally {
// And finally stop
service.stop();
}
}
示例11: testSend
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Test
public void testSend() throws MessagingException, UnsupportedEncodingException {
Session session = GreenMailUtil.getSession(ServerSetupTest.SMTP, properties);
MimeMessage mimeMessage = new MockInternationalizedMimeMessage(session);
mimeMessage.setSubject("subject");
mimeMessage.setSentDate(new Date());
mimeMessage.setFrom("múchätįldé@tìldę.oœ");
mimeMessage.setRecipients(Message.RecipientType.TO, "用户@例子.广告");
mimeMessage.setRecipients(Message.RecipientType.CC, "θσερεχα@μπλε.ψομ");
mimeMessage.setRecipients(Message.RecipientType.BCC, "राममो@हन.ईन्फो");
// The body text needs to be encoded if it contains non us-ascii characters
mimeMessage.setText(MimeUtility.encodeText("用户@例子"));
GreenMailUtil.sendMimeMessage(mimeMessage);
// Decoding the body text to verify equality
String decodedText = MimeUtility.decodeText(GreenMailUtil.getBody(greenMail.getReceivedMessages()[0]));
assertEquals("用户@例子", decodedText);
}
示例12: testThis
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
private void testThis() throws InterruptedException {
exc = null;
final GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP);
greenMail.setUser("[email protected]","[email protected]");
greenMail.start();
final Thread sendThread = new Thread() {
public void run() {
try {
sendMail("[email protected]", "[email protected]", "abc", "def", ServerSetupTest.SMTP);
} catch (final Throwable e) {
exc = new RuntimeException(e);
}
}
};
sendThread.start();
greenMail.waitForIncomingEmail(3000, 1);
final MimeMessage[] emails = greenMail.getReceivedMessages();
assertEquals(1, emails.length);
greenMail.stop();
sendThread.join(10000);
if (exc != null) {
throw exc;
}
}
示例13: testSendProvisioningSuccessEmailSMTPS
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Ignore
@Test
public void testSendProvisioningSuccessEmailSMTPS() throws IOException, MessagingException {
//To run this test, please download the greenmail.jks from the following link:
// https://github.com/greenmail-mail-test/greenmail/blob/master/greenmail-core/src/main/resources/greenmail.jks
// and put into the /cert/trusted directory, and set the mail.transport.protocol variable to smtps.
greenMail = new GreenMail(ServerSetupTest.SMTPS);
greenMail.start();
//GIVEN
String content = getFileContent("mail/cluster-installer-mail-success").replaceAll("\\n", "");
String subject = String.format("%s cluster installation", NAME_OF_THE_CLUSTER);
//WHEN
emailSenderService.sendProvisioningSuccessEmail("[email protected]", "xxx", "123.123.123.123", NAME_OF_THE_CLUSTER, false);
//THEN
greenMail.waitForIncomingEmail(5000, 1);
Message[] messages = greenMail.getReceivedMessages();
Assert.assertEquals(1, messages.length);
Assert.assertEquals(subject, messages[0].getSubject());
Assert.assertTrue(String.valueOf(messages[0].getContent()).replaceAll("\\n", "").replaceAll("\\r", "").contains(content));
}
示例14: init
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void init() {
MockitoAnnotations.initMocks(this);
tokenStoreService = new TokenStoreServiceImpl(emailService, tokenStoreRepository);
greenMail = new GreenMail(ServerSetupTest.SMTP);
greenMail.start();
}
示例15: setup
import com.icegreen.greenmail.util.ServerSetupTest; //导入依赖的package包/类
@Before
public void setup() {
mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build();
smtpServer = new GreenMail(ServerSetupTest.SMTP);
smtpServer.start();
}