use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailFetchSizeZeroTest method testFetchSize.
@Test
public void testFetchSize() throws Exception {
Mailbox mailbox = Mailbox.get("bill@localhost");
assertEquals(5, mailbox.size());
MockEndpoint mock = getMockEndpoint("mock:result");
// no messages expected as we have a fetch size of zero
mock.expectedMessageCount(0);
// should be done within 2 seconds as no delay when started
mock.setResultWaitTime(2000L);
mock.assertIsSatisfied();
assertEquals(5, mailbox.size());
}
use of org.jvnet.mock_javamail.Mailbox 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 org.jvnet.mock_javamail.Mailbox 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 org.jvnet.mock_javamail.Mailbox 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 org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailUsingCustomSessionTest method testSendAndReceiveMailsWithCustomSession.
@Test
public void testSendAndReceiveMailsWithCustomSession() throws Exception {
MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
mockEndpoint.expectedBodiesReceived("hello camel!");
Map<String, Object> headers = new HashMap<>();
headers.put("subject", "Hello Camel");
template.sendBodyAndHeaders("smtp://james@localhost?session=#myCustomMailSession", "hello camel!", headers);
mockEndpoint.assertIsSatisfied();
Mailbox mailbox = Mailbox.get("james@localhost");
assertEquals("Expected one mail for james@localhost", 1, mailbox.size());
Message message = mailbox.get(0);
assertEquals("hello camel!", message.getContent());
assertEquals("camel@localhost", message.getFrom()[0].toString());
}
Aggregations