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


Java WiserMessage.getMimeMessage方法代码示例

本文整理汇总了Java中org.subethamail.wiser.WiserMessage.getMimeMessage方法的典型用法代码示例。如果您正苦于以下问题:Java WiserMessage.getMimeMessage方法的具体用法?Java WiserMessage.getMimeMessage怎么用?Java WiserMessage.getMimeMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.subethamail.wiser.WiserMessage的用法示例。


在下文中一共展示了WiserMessage.getMimeMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Test
public void test() throws Exception {

    mailSample.sendMail();

    final List<WiserMessage> messages = wiser.getMessages();
    assertThat(messages.size()).isEqualTo(1);

    final WiserMessage message = messages.get(0);

    assertThat(message.getEnvelopeReceiver()).isEqualTo("[email protected]");
    assertThat(message.getEnvelopeSender()).isEqualTo("[email protected]");

    final MimeMessage msg = message.getMimeMessage();
    assertThat(msg.getSubject()).isEqualTo("HELLO");
    assertThat(msg.getContent()).asString().contains("Hello, world!");
}
 
开发者ID:backpaper0,项目名称:spring-boot-sandbox,代码行数:18,代码来源:MailSampleApplicationTest.java

示例2: printMessage

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
/**
 * Print out the message
 */
public void printMessage(WiserMessage message, PrintStream out) {
    out.println("===== New message =====");

    out.println("Envelope sender: " + message.getEnvelopeSender());
    out.println("Envelope recipient: " + message.getEnvelopeReceiver());

    try {
        MimeMessage mm = message.getMimeMessage();
        mm.writeTo(out);
    } catch (IOException | MessagingException ex) {
        out.println("*** ERROR: EXCEPTION THROWN ***\n" + ex);
    }

    out.println("===== End message =====\n");
}
 
开发者ID:kcoolsae,项目名称:Rasbeb,代码行数:19,代码来源:SmtpEchoServer.java

示例3: smoke

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Test
public void smoke() throws Exception {
  smtpAppender.setLayout(buildPatternLayout(loggerContext));
  smtpAppender.start();
  Logger logger = loggerContext.getLogger("test");
  logger.addAppender(smtpAppender);
  logger.debug("hello");
  logger.error("en error", new Exception("an exception"));

  waitUntilEmailIsSent();
  System.out.println("*** " + ((ThreadPoolExecutor) loggerContext.getExecutorService()).getCompletedTaskCount());
  List<WiserMessage> wiserMsgList = WISER.getMessages();

  assertNotNull(wiserMsgList);
  assertEquals(numberOfOldMessages+1, wiserMsgList.size());
  WiserMessage wm = wiserMsgList.get(numberOfOldMessages);
  // http://jira.qos.ch/browse/LBCLASSIC-67
  MimeMessage mm = wm.getMimeMessage();
  assertEquals(TEST_SUBJECT, mm.getSubject());

  MimeMultipart mp = (MimeMultipart) mm.getContent();
  String body = getBody(mp.getBodyPart(0));
  System.out.println("[" + body);
  assertTrue(body.startsWith(HEADER.trim()));
  assertTrue(body.endsWith(FOOTER.trim()));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:27,代码来源:SMTPAppender_SubethaSMTPTest.java

示例4: getMessage

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Nonnull
public MimeMessage getMessage(String envelopeReceiver)
		throws MessagingException {
	checkState("getMessages()");
	List<WiserMessage> messages = getMessages();
	Iterator<WiserMessage> iterator = messages.iterator();
	while (iterator.hasNext()) {
		WiserMessage wiserMessage = iterator.next();
		if (wiserMessage.getEnvelopeReceiver().equals(envelopeReceiver)) {
			MimeMessage mimeMessage = wiserMessage.getMimeMessage();
			iterator.remove();
			return mimeMessage;
		}
	}
	throw new AssertionError("message not found for recipient " + envelopeReceiver);
}
 
开发者ID:bbottema,项目名称:simple-java-mail,代码行数:17,代码来源:SmtpServerRule.java

示例5: translate

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
public Mail translate(WiserMessage message) {
	try {
		MimeMessage mimeMessage = message.getMimeMessage();
		return new Mail(getAddresses(mimeMessage, RecipientType.TO), getAddresses(mimeMessage, RecipientType.CC),
				getAddresses(mimeMessage, RecipientType.BCC), getFrom(mimeMessage), mimeMessage.getSubject(), null);
	} catch (MessagingException e) {
	}
	return null;
}
 
开发者ID:quirinobrizi,项目名称:maileasy,代码行数:10,代码来源:MailTranslator.java

示例6: testEmailUser

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Test
public void testEmailUser() throws Exception {
    CallingContext context = ContextFactory.getKernelUser();
    AdminApi admin = Kernel.getAdmin();

    Map<String, String> map = ImmutableMap.of("msgBody", "Hi", "emailTo", "$user.emailAddress$", "subject", "Test Rapture Password Reset");
    Kernel.getSys().writeSystemConfig(context, "CONFIG", "email/template/CREATE_PASSWORD_RESET_TOKEN", JacksonUtil.jsonFromObject(map));

    if (!admin.doesUserExist(context, geezer)) {
        admin.addUser(context, geezer, "Geezer Butler", MD5Utils.hash16(geezer), "[email protected]");
    }

    Map<String, Object> tmap = ImmutableMap.of("username", geezer);
    Kernel.getAdmin().emailUser(context, geezer, "CREATE_PASSWORD_RESET_TOKEN", tmap);

    boolean found = false;
    for (WiserMessage message : wiser.getMessages()) {
        String envelopeSender = message.getEnvelopeSender();
        String envelopeReceiver = message.getEnvelopeReceiver();
        MimeMessage mess = message.getMimeMessage();
        if (mess.getSubject().equals(map.get("subject"))) {
            assertEquals("[email protected]", envelopeSender);
            assertEquals("[email protected]", envelopeReceiver);
            assertEquals("Hi\r\n", mess.getContent().toString());
            found = true;
        }
    }
    assertTrue(found);
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:30,代码来源:AdminApiImplTest.java

示例7: testSendEmail

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Deployment
public void testSendEmail() throws Exception {

    String from = "[email protected]";
    boolean male = true;
    String recipientName = "John Doe";
    String recipient = "[email protected]";
    Date now = new Date();
    String orderId = "123456";

    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("sender", from);
    vars.put("recipient", recipient);
    vars.put("recipientName", recipientName);
    vars.put("male", male);
    vars.put("now", now);
    vars.put("orderId", orderId);

    runtimeService.startProcessInstanceByKey("sendMailExample", vars);

    List<WiserMessage> messages = wiser.getMessages();
    assertEquals(1, messages.size());

    WiserMessage message = messages.get(0);
    MimeMessage mimeMessage = message.getMimeMessage();

    assertEquals("Your order " + orderId + " has been shipped", mimeMessage.getHeader("Subject", null));
    assertEquals(from, mimeMessage.getHeader("From", null));
    assertTrue(mimeMessage.getHeader("To", null).contains(recipient));
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:31,代码来源:EmailServiceTaskTest.java

示例8: assertEmailSend

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
public static void assertEmailSend(WiserMessage emailMessage, boolean htmlMail, String subject, String message,
        String from, List<String> to, List<String> cc) throws IOException {
    try {
        MimeMessage mimeMessage = emailMessage.getMimeMessage();
        if (htmlMail) {
            assertTrue(mimeMessage.getContentType().contains("multipart/mixed"));
        } else {
            assertTrue(mimeMessage.getContentType().contains("text/plain"));
        }

        assertEquals(subject, mimeMessage.getHeader("Subject", null));
        assertEquals(from, mimeMessage.getHeader("From", null));
        assertTrue(getMessage(mimeMessage).contains(message));

        for (String t : to) {
            assertTrue(mimeMessage.getHeader("To", null).contains(t));
        }

        if (cc != null) {
            for (String c : cc) {
                assertTrue(mimeMessage.getHeader("Cc", null).contains(c));
            }
        }

    } catch (MessagingException e) {
        fail(e.getMessage());
    }

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:30,代码来源:EmailServiceTaskTest.java

示例9: assertEmailSend

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
private void assertEmailSend(WiserMessage emailMessage, boolean htmlMail, String subject, String message,
        String from, List<String> to, List<String> cc) throws IOException {
    try {
        MimeMessage mimeMessage = emailMessage.getMimeMessage();

        if (htmlMail) {
            assertTrue(mimeMessage.getContentType().contains("multipart/mixed"));
        } else {
            assertTrue(mimeMessage.getContentType().contains("text/plain"));
        }

        assertEquals(subject, mimeMessage.getHeader("Subject", null));
        assertEquals(from, mimeMessage.getHeader("From", null));
        assertTrue(getMessage(mimeMessage).contains(message));

        for (String t : to) {
            assertTrue(mimeMessage.getHeader("To", null).contains(t));
        }

        if (cc != null) {
            for (String c : cc) {
                assertTrue(mimeMessage.getHeader("Cc", null).contains(c));
            }
        }

    } catch (MessagingException e) {
        fail(e.getMessage());
    }

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:31,代码来源:EmailSendTaskTest.java

示例10: testSendEmail

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Deployment
public void testSendEmail() throws Exception {

    String from = "[email protected]";
    boolean male = true;
    String recipientName = "John Doe";
    String recipient = "[email protected]";
    Date now = new Date();
    String orderId = "123456";

    Map<String, Object> vars = new HashMap<>();
    vars.put("sender", from);
    vars.put("recipient", recipient);
    vars.put("recipientName", recipientName);
    vars.put("male", male);
    vars.put("now", now);
    vars.put("orderId", orderId);

    runtimeService.startProcessInstanceByKey("sendMailExample", vars);

    List<WiserMessage> messages = wiser.getMessages();
    assertEquals(1, messages.size());

    WiserMessage message = messages.get(0);
    MimeMessage mimeMessage = message.getMimeMessage();

    assertEquals("Your order " + orderId + " has been shipped", mimeMessage.getHeader("Subject", null));
    assertEquals(from, mimeMessage.getHeader("From", null));
    assertTrue(mimeMessage.getHeader("To", null).contains(recipient));
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:31,代码来源:EmailServiceTaskTest.java

示例11: assertEmailSend

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
public static void assertEmailSend(WiserMessage emailMessage, boolean htmlMail, String subject, String message, String from, List<String> to, List<String> cc) throws IOException {
    try {
        MimeMessage mimeMessage = emailMessage.getMimeMessage();
        if (htmlMail) {
            assertTrue(mimeMessage.getContentType().contains("multipart/mixed"));
        } else {
            assertTrue(mimeMessage.getContentType().contains("text/plain"));
        }

        assertEquals(subject, mimeMessage.getHeader("Subject", null));
        assertEquals(from, mimeMessage.getHeader("From", null));
        assertTrue(getMessage(mimeMessage).contains(message));

        for (String t : to) {
            assertTrue(mimeMessage.getHeader("To", null).contains(t));
        }

        if (cc != null) {
            for (String c : cc) {
                assertTrue(mimeMessage.getHeader("Cc", null).contains(c));
            }
        }

    } catch (MessagingException e) {
        fail(e.getMessage());
    }

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:29,代码来源:EmailServiceTaskTest.java

示例12: assertEmailSend

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
private void assertEmailSend(WiserMessage emailMessage, boolean htmlMail, String subject, String message, String from, List<String> to, List<String> cc) throws IOException {
    try {
        MimeMessage mimeMessage = emailMessage.getMimeMessage();

        if (htmlMail) {
            assertTrue(mimeMessage.getContentType().contains("multipart/mixed"));
        } else {
            assertTrue(mimeMessage.getContentType().contains("text/plain"));
        }

        assertEquals(subject, mimeMessage.getHeader("Subject", null));
        assertEquals(from, mimeMessage.getHeader("From", null));
        assertTrue(getMessage(mimeMessage).contains(message));

        for (String t : to) {
            assertTrue(mimeMessage.getHeader("To", null).contains(t));
        }

        if (cc != null) {
            for (String c : cc) {
                assertTrue(mimeMessage.getHeader("Cc", null).contains(c));
            }
        }

    } catch (MessagingException e) {
        fail(e.getMessage());
    }

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:30,代码来源:EmailSendTaskTest.java

示例13: html

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Test
public void html() throws Exception {

  smtpAppender.setLayout(buildHTMLLayout(loggerContext));
  smtpAppender.start();
  Logger logger = loggerContext.getLogger("test");
  logger.addAppender(smtpAppender);
  logger.debug("hello");
  logger.error("en error", new Exception("an exception"));
  waitUntilEmailIsSent();

  List<WiserMessage> wiserMsgList = WISER.getMessages();

  assertNotNull(wiserMsgList);
  assertEquals(numberOfOldMessages + 1, wiserMsgList.size());
  WiserMessage wm = wiserMsgList.get(numberOfOldMessages);
  MimeMessage mm = wm.getMimeMessage();
  assertEquals(TEST_SUBJECT, mm.getSubject());

  MimeMultipart mp = (MimeMultipart) mm.getContent();

  // verify strict adherence to xhtml1-strict.dtd
  SAXReader reader = new SAXReader();
  reader.setValidation(true);
  reader.setEntityResolver(new XHTMLEntityResolver());
  reader.read(mp.getBodyPart(0).getInputStream());
  // System.out.println(GreenMailUtil.getBody(mp.getBodyPart(0)));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:29,代码来源:SMTPAppender_SubethaSMTPTest.java

示例14: htmlLong

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Test
/**
 * Checks that even when many events are processed, the output is still
 * conforms to xhtml-strict.dtd.
 *
 * Note that SMTPAppender only keeps only 500 or so (=buffer size) events. So
 * the generated output will be rather short.
 */
public void htmlLong() throws Exception {
  smtpAppender.setLayout(buildHTMLLayout(loggerContext));
  smtpAppender.start();
  Logger logger = loggerContext.getLogger("test");
  logger.addAppender(smtpAppender);
  for (int i = 0; i < CoreConstants.TABLE_ROW_LIMIT * 3; i++) {
    logger.debug("hello " + i);
  }
  logger.error("en error", new Exception("an exception"));
  waitUntilEmailIsSent();
  List<WiserMessage> wiserMsgList = WISER.getMessages();

  assertNotNull(wiserMsgList);
  assertEquals(numberOfOldMessages + 1, wiserMsgList.size());
  WiserMessage wm = wiserMsgList.get(numberOfOldMessages);
  MimeMessage mm = wm.getMimeMessage();
  assertEquals(TEST_SUBJECT, mm.getSubject());

  MimeMultipart mp = (MimeMultipart) mm.getContent();

  // verify strict adherence to xhtml1-strict.dtd
  SAXReader reader = new SAXReader();
  reader.setValidation(true);
  reader.setEntityResolver(new XHTMLEntityResolver());
  reader.read(mp.getBodyPart(0).getInputStream());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:35,代码来源:SMTPAppender_SubethaSMTPTest.java

示例15: authenticated

import org.subethamail.wiser.WiserMessage; //导入方法依赖的package包/类
@Test
public void authenticated() throws Exception {
  MessageListenerAdapter mla = (MessageListenerAdapter) WISER.getServer().getMessageHandlerFactory();
  mla.setAuthenticationHandlerFactory(new TrivialAuthHandlerFactory());

  smtpAppender.setUsername("x");
  smtpAppender.setPassword("x");

  smtpAppender.setLayout(buildPatternLayout(loggerContext));
  smtpAppender.start();
  Logger logger = loggerContext.getLogger("test");
  logger.addAppender(smtpAppender);
  logger.debug("hello");
  logger.error("en error", new Exception("an exception"));
  waitUntilEmailIsSent();
  List<WiserMessage> wiserMsgList = WISER.getMessages();

  assertNotNull(wiserMsgList);
  assertEquals(numberOfOldMessages + 1, wiserMsgList.size());
  WiserMessage wm = wiserMsgList.get(numberOfOldMessages);
  // http://jira.qos.ch/browse/LBCLASSIC-67
  MimeMessage mm = wm.getMimeMessage();
  assertEquals(TEST_SUBJECT, mm.getSubject());

  MimeMultipart mp = (MimeMultipart) mm.getContent();
  String body = getBody(mp.getBodyPart(0));
  assertTrue(body.startsWith(HEADER.trim()));
  assertTrue(body.endsWith(FOOTER.trim()));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:30,代码来源:SMTPAppender_SubethaSMTPTest.java


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