本文整理汇总了Java中com.icegreen.greenmail.util.GreenMailUtil.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java GreenMailUtil.getBody方法的具体用法?Java GreenMailUtil.getBody怎么用?Java GreenMailUtil.getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.icegreen.greenmail.util.GreenMailUtil
的用法示例。
在下文中一共展示了GreenMailUtil.getBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoPrivateExam
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testDoPrivateExam() throws Exception {
Exam studentExam = createPrivateStudentExam();
Result result = request(Helpers.PUT, String.format("/app/student/exam/%s", studentExam.getHash()), null);
assertThat(result.status()).isEqualTo(200);
// Check that correct mail was sent
assertThat(greenMail.waitForIncomingEmail(MAIL_TIMEOUT, 1)).isTrue();
MimeMessage[] mails = greenMail.getReceivedMessages();
assertThat(mails).hasSize(1);
assertThat(mails[0].getFrom()[0].toString()).contains(ConfigFactory.load().getString("sitnet.email.system.account"));
assertThat(mails[0].getSubject()).isEqualTo("Personal exam has been returned");
String body = GreenMailUtil.getBody(mails[0]);
String reviewLink = String.format("%s/assessments/%d",
ConfigFactory.load().getString("sitnet.application.hostname"), studentExam.getId());
String reviewLinkElement = String.format("<a href=\"%s\">%s</a>", reviewLink, "Link to evaluation");
assertThat(body).contains(reviewLinkElement);
}
示例2: testAbortPrivateExam
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testAbortPrivateExam() throws Exception {
Exam studentExam = createPrivateStudentExam();
Result result = request(Helpers.PUT, String.format("/app/student/exam/abort/%s", studentExam.getHash()), null);
assertThat(result.status()).isEqualTo(200);
// Check that correct mail was sent
assertThat(greenMail.waitForIncomingEmail(MAIL_TIMEOUT, 1)).isTrue();
MimeMessage[] mails = greenMail.getReceivedMessages();
assertThat(mails).hasSize(1);
assertThat(mails[0].getFrom()[0].toString()).contains(ConfigFactory.load().getString("sitnet.email.system.account"));
assertThat(mails[0].getSubject()).isEqualTo("Personal exam has been abandoned");
String body = GreenMailUtil.getBody(mails[0]);
// Make sure there is no link to review
assertThat(body).doesNotContain("<a href");
}
示例3: synchronousSmoke
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void synchronousSmoke() throws Exception {
String subject = "synchronousSmoke";
buildSMTPAppender(subject, SYNCHRONOUS);
smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN));
smtpAppender.start();
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
MimeMultipart mp = verifyAndExtractMimeMultipart(subject);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertTrue(body.startsWith(HEADER.trim()));
assertTrue(body.endsWith(FOOTER.trim()));
}
示例4: asynchronousSmoke
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void asynchronousSmoke() throws Exception {
String subject = "asynchronousSmoke";
buildSMTPAppender(subject, ASYNCHRONOUS);
smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN));
smtpAppender.start();
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
waitUntilEmailIsSent();
MimeMultipart mp = verifyAndExtractMimeMultipart(subject);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertTrue(body.startsWith(HEADER.trim()));
assertTrue(body.endsWith(FOOTER.trim()));
}
示例5: callerDataShouldBeCorrectlySetWithAsynchronousSending
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void callerDataShouldBeCorrectlySetWithAsynchronousSending() throws Exception {
String subject = "LOGBACK-734";
buildSMTPAppender("LOGBACK-734", ASYNCHRONOUS);
smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN));
smtpAppender.setIncludeCallerData(true);
smtpAppender.start();
logger.addAppender(smtpAppender);
logger.debug("LOGBACK-734");
logger.error("callerData", new Exception("ShouldBeCorrectlySetWithAsynchronousSending"));
waitUntilEmailIsSent();
MimeMultipart mp = verifyAndExtractMimeMultipart(subject);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertTrue("actual [" + body + "]", body.contains("DEBUG " + this.getClass().getName() + " - LOGBACK-734"));
}
示例6: LBCLASSIC_104
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void LBCLASSIC_104() throws Exception {
String subject = "LBCLASSIC_104";
buildSMTPAppender(subject, SYNCHRONOUS);
smtpAppender.setAsynchronousSending(false);
smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN));
smtpAppender.start();
logger.addAppender(smtpAppender);
MDC.put("key", "val");
logger.debug("LBCLASSIC_104");
MDC.clear();
logger.error("en error", new Exception("test"));
MimeMultipart mp = verifyAndExtractMimeMultipart(subject);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertTrue(body.startsWith(HEADER.trim()));
System.out.println(body);
assertTrue(body.contains("key=val"));
assertTrue(body.endsWith(FOOTER.trim()));
}
示例7: testSendTextMail
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSendTextMail() throws Exception {
// prepare a mail request
MailRequest request = mailer.newTextMailRequest("Plain Text Message", "This is a plain text message");
request.getToAddresses().add(new Address("[email protected]"));
request.getToAddresses().add(new Address("[email protected]"));
// send the mail and wait for completion
mailer.sendSynchronously(request);
// validate the receipt
MimeMessage msgs[] = server.getReceivedMessages();
assertEquals(request.getToAddresses().size(), msgs.length);
String receivedBody = GreenMailUtil.getBody(msgs[0]);
assertTrue(receivedBody.contains("plain text"));
}
示例8: testSendHtmlMail
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSendHtmlMail() throws Exception {
// prepare a mail request
MailRequest request = mailer.newHtmlMailRequest("Html Test Message", "This is a <b>text/html</b> message");
request.getToAddresses().add(new Address("[email protected]"));
request.getToAddresses().add(new Address("[email protected]"));
// send the mail and wait for completion
mailer.sendSynchronously(request);
// validate the receipt
MimeMessage msgs[] = server.getReceivedMessages();
assertEquals(request.getToAddresses().size(), msgs.length);
String receivedBody = GreenMailUtil.getBody(msgs[0]);
assertTrue(receivedBody.contains("<b>text/html</b>"));
}
示例9: testSendTextTemplateMail
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSendTextTemplateMail() throws Exception {
Map<String, Object> parameters = new HashMap<>();
parameters.put("username", "Example User");
parameters.put("systemUsername", "Fathom");
// prepare a mail request
MailRequest request = mailer.newTextTemplateMailRequest("Hi ${username}", "test_text", parameters);
request.getToAddresses().add(new Address("[email protected]"));
request.getToAddresses().add(new Address("[email protected]"));
// send the mail and wait for completion
mailer.sendSynchronously(request);
// validate the receipt
MimeMessage msgs[] = server.getReceivedMessages();
assertEquals(request.getToAddresses().size(), msgs.length);
String receivedBody = GreenMailUtil.getBody(msgs[0]);
assertTrue(msgs[0].getSubject().equals("Hi Example User"));
assertTrue(receivedBody.contains("Hello Example User!"));
}
示例10: testSendHtmlTemplateMail
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSendHtmlTemplateMail() throws Exception {
// prepare a mail request
Map<String, Object> parameters = new HashMap<>();
parameters.put("username", "Example User");
parameters.put("systemUsername", "Fathom");
MailRequest request = mailer.newHtmlTemplateMailRequest("Hi ${username}", "test_html", parameters);
request.getToAddresses().add(new Address("[email protected]"));
request.getToAddresses().add(new Address("[email protected]"));
// send the mail and wait for completion
mailer.sendSynchronously(request);
// validate the receipt
MimeMessage msgs[] = server.getReceivedMessages();
assertEquals(request.getToAddresses().size(), msgs.length);
String receivedBody = GreenMailUtil.getBody(msgs[0]);
assertTrue(msgs[0].getSubject().equals("Hi Example User"));
assertTrue(receivedBody.contains("Hello <b>Example User</b>!"));
}
示例11: testCreateReservation
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testCreateReservation() throws Exception {
// Setup
// Private exam
exam.setExecutionType(Ebean.find(ExamExecutionType.class, 2));
// Add Arvo teacher to owner
exam.getExamOwners().add(Ebean.find(User.class, 4));
exam.save();
DateTime start = DateTime.now().withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).plusHours(1);
DateTime end = DateTime.now().withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).plusHours(2);
// Execute
Result result = request(Helpers.POST, "/app/calendar/reservation",
Json.newObject().put("roomId", room.getId())
.put("examId", exam.getId())
.put("start", ISODateTimeFormat.dateTime().print(start))
.put("end", ISODateTimeFormat.dateTime().print(end)));
assertThat(result.status()).isEqualTo(200);
// Verify
ExamEnrolment ee = Ebean.find(ExamEnrolment.class, enrolment.getId());
assertThat(ee.getReservation()).isNotNull();
assertThat(ee.getReservation().getStartAt()).isEqualTo(start);
assertThat(ee.getReservation().getEndAt()).isEqualTo(end);
assertThat(ee.getExam().getId()).isEqualTo(exam.getId());
assertThat(ee.getReservation().getMachine()).isIn(room.getExamMachines());
greenMail.purgeEmailFromAllMailboxes();
// Check that correct mail was sent
assertThat(greenMail.waitForIncomingEmail(MAIL_TIMEOUT, 1)).isTrue();
MimeMessage[] mails = greenMail.getReceivedMessages();
assertThat(mails).hasSize(1);
assertThat(mails[0].getFrom()[0].toString()).contains(ConfigFactory.load().getString("sitnet.email.system.account"));
String body = GreenMailUtil.getBody(mails[0]);
assertThat(body).contains("You have booked an exam time");
assertThat(body).contains("information in English here");
assertThat(body).contains(room.getName());
assertThat(GreenMailUtil.hasNonTextAttachments(mails[0])).isTrue();
}
示例12: testRequestReservation
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testRequestReservation() throws Exception {
initialize(null);
ObjectNode json = Json.newObject();
json.put("start", ISODateTimeFormat.dateTime().print(DateTime.now().plusHours(1)));
json.put("end", ISODateTimeFormat.dateTime().print(DateTime.now().plusHours(2)));
json.put("examId", exam.getId());
json.put("orgId", ORG_REF);
json.put("roomId", ROOM_REF);
json.put("requestingOrg", "foobar");
Result result = request(Helpers.POST, "/integration/iop/reservations/external", json);
assertThat(result.status()).isEqualTo(201);
JsonNode body = Json.parse(contentAsString(result));
assertThat(body.asText()).isEqualTo(RESERVATION_REF);
Reservation created = Ebean.find(Reservation.class).where().eq("externalRef", RESERVATION_REF).findUnique();
assertThat(created).isNotNull();
ExternalReservation external = created.getExternalReservation();
assertThat(external).isNotNull();
assertThat(external.getRoomInstructionEN()).isEqualTo("information in English here");
// Check that correct mail was sent
assertThat(greenMail.waitForIncomingEmail(MAIL_TIMEOUT, 1)).isTrue();
MimeMessage[] mails = greenMail.getReceivedMessages();
assertThat(mails).hasSize(1);
assertThat(mails[0].getFrom()[0].toString()).contains(ConfigFactory.load().getString("sitnet.email.system.account"));
String mailBody = GreenMailUtil.getBody(mails[0]);
assertThat(mailBody).contains("You have booked an exam time");
assertThat(mailBody).contains("Room 1");
}
示例13: testRequestReservationRemoval
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testRequestReservationRemoval() throws Exception {
initialize(null);
Reservation reservation = new Reservation();
reservation.setUser(user);
reservation.setStartAt(DateTime.now().plusHours(2));
reservation.setEndAt(DateTime.now().plusHours(3));
reservation.setExternalRef(RESERVATION_REF);
ExternalReservation er = new ExternalReservation();
er.setOrgRef(ORG_REF);
er.setRoomRef(ROOM_REF);
er.setMachineName("M1");
er.setRoomName("External Room R1");
er.save();
reservation.setExternalReservation(er);
reservation.save();
enrolment.setReservation(reservation);
enrolment.update();
Result result = request(Helpers.DELETE, "/integration/iop/reservations/external/" + RESERVATION_REF, null);
assertThat(result.status()).isEqualTo(200);
ExamEnrolment ee = Ebean.find(ExamEnrolment.class, enrolment.getId());
assertThat(ee.getReservation()).isNull();
assertThat(Ebean.find(Reservation.class, reservation.getId())).isNull();
// Check that correct mail was sent
assertThat(greenMail.waitForIncomingEmail(MAIL_TIMEOUT, 1)).isTrue();
MimeMessage[] mails = greenMail.getReceivedMessages();
assertThat(mails).hasSize(1);
assertThat(mails[0].getFrom()[0].toString()).contains(ConfigFactory.load().getString("sitnet.email.system.account"));
String mailBody = GreenMailUtil.getBody(mails[0]);
assertThat(mailBody).contains("External Room R1");
}
示例14: testSendMessage
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSendMessage() throws Exception {
final String testMessage = "Test email message";
final User user = new User("password1", "[email protected]");
user.setUserData(new UserData(user, "user"));
when(templateService.from(any(), any())).thenReturn(testMessage);
mailService.send(mails.welcomeMail(user));
final MimeMessage[] messages = testSmtp.getReceivedMessages();
assertEquals(1, messages.length);
final String body = GreenMailUtil.getBody(messages[0]);
assertTrue(body.contains(testMessage));
}
示例15: testCustomEvaluator
import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testCustomEvaluator() throws Exception {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX
+ "smtp/customEvaluator.xml");
logger.debug("test");
String msg2 = "CustomEvaluator";
logger.debug(msg2);
logger.debug("invisible");
waitUntilEmailIsSent();
MimeMultipart mp = verifyAndExtractMimeMultipart("testCustomEvaluator " + this.getClass().getName() + " - " + msg2);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertEquals("testCustomEvaluator", body);
}