本文整理汇总了Java中com.icegreen.greenmail.util.GreenMailUtil.sendTextEmailTest方法的典型用法代码示例。如果您正苦于以下问题:Java GreenMailUtil.sendTextEmailTest方法的具体用法?Java GreenMailUtil.sendTextEmailTest怎么用?Java GreenMailUtil.sendTextEmailTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.icegreen.greenmail.util.GreenMailUtil
的用法示例。
在下文中一共展示了GreenMailUtil.sendTextEmailTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pollMailWithTextBody
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
@Deployment(resources = "processes/mail-poll.bpmn")
public void pollMailWithTextBody() throws MessagingException {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "subject", "text body");
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("poll-mails");
@SuppressWarnings("unchecked")
List<Mail> mails = (List<Mail>) engineRule.getRuntimeService().getVariable(processInstance.getId(), "mails");
assertThat(mails)
.isNotNull()
.hasSize(1);
Mail mail = mails.get(0);
assertThat(mail.getFrom()).isEqualTo("[email protected]");
assertThat(mail.getSubject()).isEqualTo("subject");
assertThat(mail.getText()).isEqualTo("text body");
}
示例2: pollSingleMail
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void pollSingleMail() throws MessagingException {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "subject", "text body");
PollMailResponse response = MailConnectors.pollMails()
.createRequest()
.folder("INBOX")
.execute();
List<Mail> mails = response.getMails();
assertThat(mails).hasSize(1);
Mail mail = mails.get(0);
assertThat(mail.getSubject()).isEqualTo("subject");
assertThat(mail.getText()).isEqualTo("text body");
}
示例3: pollMultipleMails
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void pollMultipleMails() throws MessagingException {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "mail-1", "body");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "mail-2", "body");
PollMailResponse response = MailConnectors.pollMails()
.createRequest()
.folder("INBOX")
.execute();
List<Mail> mails = response.getMails();
assertThat(mails)
.hasSize(2)
.extracting("subject")
.contains("mail-1", "mail-2");
}
示例4: dontPollDeletedMail
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void dontPollDeletedMail() throws MessagingException {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "mail-1", "body");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "mail-2", "body");
MailConnectors.deleteMails()
.createRequest()
.folder("INBOX")
.messageNumbers(1)
.execute();
PollMailResponse response = MailConnectors.pollMails()
.createRequest()
.folder("INBOX")
.execute();
List<Mail> mails = response.getMails();
assertThat(mails).hasSize(1);
}
示例5: messageHandler
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void messageHandler() throws Exception {
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "existing mail", "body");
notificationService.start();
final List<Message> receivedMessages = new ArrayList<>();
final CountDownLatch countDownLatch = new CountDownLatch(1);
notificationService.registerMessageHandler(messages -> {
receivedMessages.addAll(messages);
countDownLatch.countDown();
});
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "new mail", "body");
countDownLatch.await(10, TimeUnit.SECONDS);
assertThat(receivedMessages).hasSize(1);
}
示例6: testPopWait
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopWait() throws Exception{
BaleenCollectionReader bcr = getCollectionReader(
EmailReader.PARAM_PROTOCOL, "pop3",
EmailReader.PARAM_WAIT, 5,
EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
EmailReader.PARAM_USER, "[email protected]",
EmailReader.PARAM_PASS, "password",
EmailReader.PARAM_PROCESS, "content");
bcr.initialize();
assertFalse(bcr.doHasNext());
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", GreenMailUtil.random(), GreenMailUtil.random());
assertFalse(bcr.doHasNext()); //Should be a 5 second delay before it returns true
Thread.sleep(5000);
assertTrue(bcr.doHasNext());
bcr.close();
}
示例7: testSmtpServerReceiveInThread
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSmtpServerReceiveInThread() throws Throwable {
assertEquals(0, greenMail.getReceivedMessages().length);
Thread sendThread = new Thread() {
public void run() {
try {
Thread.sleep(700);
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "abc", "def");
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
};
sendThread.start();
greenMail.waitForIncomingEmail(3000, 1);
MimeMessage[] emails = greenMail.getReceivedMessages();
assertEquals(1, emails.length);
sendThread.join(10000);
}
示例8: testRetreiveSimpleWithNonDefaultPassword
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testRetreiveSimpleWithNonDefaultPassword() throws Exception {
assertNotNull(greenMail.getImap());
final String to = "[email protected]";
final String password = "donotharmanddontrecipricateharm";
greenMail.setUser(to, password);
final String subject = GreenMailUtil.random();
final String body = GreenMailUtil.random();
GreenMailUtil.sendTextEmailTest(to, "[email protected]", subject, body);
greenMail.waitForIncomingEmail(5000, 1);
try (Retriever retriever = new Retriever(greenMail.getImap())) {
try {
retriever.getMessages(to, "wrongpassword");
fail("Expected failed login");
} catch (Throwable e) {
// ok
}
Message[] messages = retriever.getMessages(to, password);
assertEquals(1, messages.length);
assertEquals(subject, messages[0].getSubject());
assertEquals(body, ((String) messages[0].getContent()).trim());
}
}
示例9: testRetrieve
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testRetrieve() throws Exception {
assertNotNull(greenMail.getPop3());
final String subject = GreenMailUtil.random();
final String body = GreenMailUtil.random() + "\r\n" + GreenMailUtil.random() + "\r\n" + GreenMailUtil.random();
String to = "[email protected]";
GreenMailUtil.sendTextEmailTest(to, "[email protected]", subject, body);
greenMail.waitForIncomingEmail(5000, 1);
try (Retriever retriever = new Retriever(greenMail.getPop3())) {
Message[] messages = retriever.getMessages(to);
assertEquals(1, messages.length);
assertEquals(subject, messages[0].getSubject());
assertEquals(body, GreenMailUtil.getBody(messages[0]).trim());
// UID
POP3Folder f = (POP3Folder) messages[0].getFolder();
assertNotEquals("UNKNOWN", f.getUID(messages[0]));
}
}
示例10: testRetrieveWithNonDefaultPassword
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testRetrieveWithNonDefaultPassword() throws Exception {
assertNotNull(greenMail.getPop3());
final String to = "[email protected]";
final String password = "donotharmanddontrecipricateharm";
greenMail.setUser(to, password);
final String subject = GreenMailUtil.random();
final String body = GreenMailUtil.random();
GreenMailUtil.sendTextEmailTest(to, "[email protected]", subject, body);
greenMail.waitForIncomingEmail(5000, 1);
try (Retriever retriever = new Retriever(greenMail.getPop3())) {
try {
retriever.getMessages(to, "wrongpassword");
fail("Expected authentication failure");
} catch (Throwable e) {
// ok
}
Message[] messages = retriever.getMessages(to, password);
assertEquals(1, messages.length);
assertEquals(subject, messages[0].getSubject());
assertEquals(body, GreenMailUtil.getBody(messages[0]).trim());
}
}
示例11: testSendMailAndReceiveWithAuthDisabled
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSendMailAndReceiveWithAuthDisabled() throws MessagingException, IOException {
final String to = "[email protected]";
final String subject = "subject";
final String body = "body";
GreenMailUtil.sendTextEmailTest(to, "[email protected]", subject, body);
MimeMessage[] emails = greenMail.getReceivedMessages();
assertEquals(1, emails.length);
assertEquals(subject, emails[0].getSubject());
assertEquals(body, GreenMailUtil.getBody(emails[0]));
greenMail.waitForIncomingEmail(5000, 1);
try (Retriever retriever = new Retriever(greenMail.getImap())) {
Message[] messages = retriever.getMessages(to);
assertEquals(1, messages.length);
assertEquals(subject, messages[0].getSubject());
assertEquals(body, messages[0].getContent());
}
}
示例12: folderFromConfiguration
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void folderFromConfiguration() throws MessagingException {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "subject", "text body");
PollMailResponse response = MailConnectors.pollMails()
.createRequest()
.execute();
List<Mail> mails = response.getMails();
assertThat(mails).hasSize(1);
}
示例13: createMails
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Before
public void createMails() {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "mail-1", "body");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "mail-2", "body");
}
示例14: testPopAttachments
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopAttachments() throws Exception{
File folder = Files.createTempDir();
String subject1 = GreenMailUtil.random();
String body1 = GreenMailUtil.random();
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
String subject2 = GreenMailUtil.random();
String body2 = GreenMailUtil.random();
GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
BaleenCollectionReader bcr = getCollectionReader(
EmailReader.PARAM_PROTOCOL, "pop3",
EmailReader.PARAM_WAIT, 5,
EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
EmailReader.PARAM_USER, "[email protected]",
EmailReader.PARAM_PASS, "password",
EmailReader.PARAM_PROCESS, "attachments",
EmailReader.PARAM_FOLDER, folder.getPath());
bcr.initialize();
assertTrue(bcr.doHasNext());
bcr.getNext(jCas);
assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
assertEquals(1, folder.list().length);
jCas.reset();
assertFalse(bcr.doHasNext());
bcr.close();
FileUtils.deleteDirectory(folder);
}
示例15: testPopLongWait
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopLongWait() throws Exception{
String subject = GreenMailUtil.random();
String body = GreenMailUtil.random();
String subject2 = GreenMailUtil.random();
String body2 = GreenMailUtil.random();
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject, body);
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject2, body2);
BaleenCollectionReader bcr = getCollectionReader(
EmailReader.PARAM_PROTOCOL, "pop3",
EmailReader.PARAM_WAIT, 15,
EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
EmailReader.PARAM_USER, "[email protected]",
EmailReader.PARAM_PASS, "password",
EmailReader.PARAM_PROCESS, "content");
bcr.initialize();
assertTrue(bcr.doHasNext());
bcr.getNext(jCas);
jCas.reset();
Thread.sleep(20000);
assertTrue(bcr.doHasNext());
bcr.getNext(jCas);
jCas.reset();
assertFalse(bcr.doHasNext());
bcr.close();
}