use of javax.mail.Message in project camel by apache.
the class MailCustomContentTypeTest method testSendPlainMailContentTypeInHeader.
@Test
public void testSendPlainMailContentTypeInHeader() throws Exception {
Mailbox.clearAll();
template.sendBodyAndHeader("direct:b", "Hello World", "contentType", "text/plain; charset=iso-8859-1");
Mailbox box = Mailbox.get("claus@localhost");
Message msg = box.get(0);
assertEquals("text/plain; charset=iso-8859-1", msg.getContentType());
assertEquals("Hello World", msg.getContent());
}
use of javax.mail.Message in project camel by apache.
the class MailCustomContentTypeTest method testSendPlainMailContentTypeInHeader2.
@Test
public void testSendPlainMailContentTypeInHeader2() throws Exception {
Mailbox.clearAll();
template.sendBodyAndHeader("direct:b", "Hello World", Exchange.CONTENT_TYPE, "text/plain; charset=iso-8859-1");
Mailbox box = Mailbox.get("claus@localhost");
Message msg = box.get(0);
assertEquals("text/plain; charset=iso-8859-1", msg.getContentType());
assertEquals("Hello World", msg.getContent());
}
use of javax.mail.Message in project camel by apache.
the class MailCustomContentTypeTest method testSendHtmlMail.
@Test
public void testSendHtmlMail() throws Exception {
Mailbox.clearAll();
sendBody("direct:a", "<html><body><h1>Hello</h1>World</body></html>");
Mailbox box = Mailbox.get("claus@localhost");
Message msg = box.get(0);
assertTrue(msg.getContentType().startsWith("text/html"));
assertEquals("text/html; charset=UTF-8", msg.getContentType());
assertEquals("<html><body><h1>Hello</h1>World</body></html>", msg.getContent());
}
use of javax.mail.Message in project camel by apache.
the class NestedMimeMessageConsumeTest method prepareMailbox.
private void prepareMailbox(String user) throws MessagingException {
// connect to mailbox
JavaMailSender sender = new DefaultJavaMailSender();
Store store = sender.getSession().getStore("pop3");
store.connect("localhost", 25, user, "secret");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
folder.expunge();
InputStream is = getClass().getResourceAsStream("/nested-multipart.elm");
Message hurzMsg = new MimeMessage(sender.getSession(), is);
Message[] messages = new Message[] { hurzMsg };
// insert one signed message
folder.appendMessages(messages);
folder.close(true);
}
use of javax.mail.Message in project camel by apache.
the class RawMailMessageTest method testGetRawJavaMailMessage.
@Test
public void testGetRawJavaMailMessage() throws Exception {
Mailbox.clearAll();
Map<String, Object> map = new HashMap<String, Object>();
map.put("To", "davsclaus@apache.org");
map.put("From", "jstrachan@apache.org");
map.put("Subject", "Camel rocks");
String body = "Hello Claus.\nYes it does.\n\nRegards James.";
getMockEndpoint("mock:mail").expectedMessageCount(1);
template.sendBodyAndHeaders("smtp://davsclaus@apache.org", body, map);
assertMockEndpointsSatisfied();
Exchange exchange = getMockEndpoint("mock:mail").getReceivedExchanges().get(0);
// START SNIPPET: e1
// get access to the raw javax.mail.Message as shown below
Message javaMailMessage = exchange.getIn(MailMessage.class).getMessage();
assertNotNull(javaMailMessage);
assertEquals("Camel rocks", javaMailMessage.getSubject());
// END SNIPPET: e1
}
Aggregations