当前位置: 首页>>代码示例>>Java>>正文


Java GreenMailUtil.getBody方法代码示例

本文整理汇总了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);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:StudentExamControllerTest.java

示例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");
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:StudentExamControllerTest.java

示例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()));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:17,代码来源:SMTPAppender_GreenTest.java

示例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()));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:17,代码来源:SMTPAppender_GreenTest.java

示例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"));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:17,代码来源:SMTPAppender_GreenTest.java

示例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()));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:SMTPAppender_GreenTest.java

示例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"));
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:18,代码来源:MailerTest.java

示例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>"));
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:18,代码来源:MailerTest.java

示例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!"));
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:23,代码来源:MailerTest.java

示例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>!"));
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:23,代码来源:MailerTest.java

示例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();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:41,代码来源:CalendarControllerTest.java

示例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");
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:35,代码来源:ExternalCalendarInterfaceTest.java

示例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");
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:37,代码来源:ExternalCalendarInterfaceTest.java

示例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));
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:16,代码来源:MailServiceTest.java

示例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);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:SMTPAppender_GreenTest.java


注:本文中的com.icegreen.greenmail.util.GreenMailUtil.getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。