use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailBatchConsumerTest method testBatchConsumer.
@Test
public void testBatchConsumer() throws Exception {
Mailbox mailbox = Mailbox.get("jones@localhost");
assertEquals(5, mailbox.size());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(5);
mock.expectsAscending(body());
mock.message(0).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(0);
mock.message(1).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(1);
mock.message(2).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(2);
mock.message(3).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(3);
mock.message(4).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(4);
mock.message(0).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(1).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(2).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(3).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(3).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(4).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(true);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 5);
assertMockEndpointsSatisfied();
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailCommitOnCompletionTest method testCommitOnCompletion.
@Test
public void testCommitOnCompletion() throws Exception {
Mailbox mailbox = Mailbox.get("jones@localhost");
assertEquals(5, mailbox.size());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hi Message 0", "Hi Message 1", "Hi Message 2", "Hi Message 3", "Hi Message 4");
mock.assertIsSatisfied();
// wait a bit because delete is on completion
Thread.sleep(1000);
assertEquals(0, mailbox.size());
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailComponentRecipientSetTest method testMultipleEndpoints.
@Test
public void testMultipleEndpoints() throws Exception {
Mailbox.clearAll();
template.sendBodyAndHeader("direct:a", "Hello World", "Subject", "Hello a");
template.sendBodyAndHeader("direct:b", "Bye World", "Subject", "Hello b");
template.sendBodyAndHeader("direct:c", "Hi World", "Subject", "Hello c");
Mailbox boxA = Mailbox.get("a@a.com");
assertEquals(1, boxA.size());
assertEquals("Hello a", boxA.get(0).getSubject());
assertEquals("Hello World", boxA.get(0).getContent());
assertEquals("me@me.com", boxA.get(0).getFrom()[0].toString());
assertEquals("spy@spy.com", boxA.get(0).getRecipients(Message.RecipientType.CC)[0].toString());
Mailbox boxB = Mailbox.get("b@b.com");
assertEquals(1, boxB.size());
assertEquals("Hello b", boxB.get(0).getSubject());
assertEquals("Bye World", boxB.get(0).getContent());
assertEquals("you@you.com", boxB.get(0).getFrom()[0].toString());
assertEquals("spy@spy.com", boxB.get(0).getRecipients(Message.RecipientType.CC)[0].toString());
Mailbox boxC = Mailbox.get("c@c.com");
assertEquals(1, boxC.size());
assertEquals("Hello c", boxC.get(0).getSubject());
assertEquals("Hi World", boxC.get(0).getContent());
assertEquals("me@me.com", boxC.get(0).getFrom()[0].toString());
assertEquals("you@you.com", boxC.get(0).getRecipients(Message.RecipientType.CC)[0].toString());
assertEquals("them@them.com", boxC.get(0).getRecipients(Message.RecipientType.CC)[1].toString());
// no spy as its overridden by endpoint
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailContentTypeTest 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("<html><body><h1>Hello</h1>World</body></html>", msg.getContent());
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailContentTypeTest method testSendPlainMail.
@Test
public void testSendPlainMail() throws Exception {
Mailbox.clearAll();
sendBody("direct:b", "Hello World");
Mailbox box = Mailbox.get("claus@localhost");
Message msg = box.get(0);
assertTrue(msg.getContentType().startsWith("text/plain"));
assertEquals("Hello World", msg.getContent());
}
Aggregations