use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailRecipientsPipeIssueTest method testMultiRecipients.
@Test
public void testMultiRecipients() throws Exception {
Mailbox.clearAll();
sendBody("direct:a", "Camel does really rock");
Mailbox inbox = Mailbox.get("camel|pipes@riders.org");
Message msg = inbox.get(0);
assertEquals("you@apache.org", msg.getFrom()[0].toString());
assertEquals("camel|pipes@riders.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("easy@riders.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
inbox = Mailbox.get("easy@riders.org");
msg = inbox.get(0);
assertEquals("you@apache.org", msg.getFrom()[0].toString());
assertEquals("camel|pipes@riders.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("easy@riders.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailRecipientsTest method testMultiRecipients.
@Test
public void testMultiRecipients() throws Exception {
Mailbox.clearAll();
sendBody("direct:a", "Camel does really rock");
Mailbox inbox = Mailbox.get("camel@riders.org");
Message msg = inbox.get(0);
assertEquals("you@apache.org", msg.getFrom()[0].toString());
assertEquals("camel@riders.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("easy@riders.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
assertEquals("me@you.org", msg.getRecipients(Message.RecipientType.CC)[0].toString());
assertEquals("someone@somewhere.org", msg.getRecipients(Message.RecipientType.BCC)[0].toString());
inbox = Mailbox.get("easy@riders.org");
msg = inbox.get(0);
assertEquals("you@apache.org", msg.getFrom()[0].toString());
assertEquals("camel@riders.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("easy@riders.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
assertEquals("me@you.org", msg.getRecipients(Message.RecipientType.CC)[0].toString());
assertEquals("someone@somewhere.org", msg.getRecipients(Message.RecipientType.BCC)[0].toString());
inbox = Mailbox.get("me@you.org");
msg = inbox.get(0);
assertEquals("you@apache.org", msg.getFrom()[0].toString());
assertEquals("camel@riders.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("easy@riders.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
assertEquals("me@you.org", msg.getRecipients(Message.RecipientType.CC)[0].toString());
assertEquals("someone@somewhere.org", msg.getRecipients(Message.RecipientType.BCC)[0].toString());
inbox = Mailbox.get("someone@somewhere.org");
msg = inbox.get(0);
assertEquals("you@apache.org", msg.getFrom()[0].toString());
assertEquals("camel@riders.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("easy@riders.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
assertEquals("me@you.org", msg.getRecipients(Message.RecipientType.CC)[0].toString());
assertEquals("someone@somewhere.org", msg.getRecipients(Message.RecipientType.BCC)[0].toString());
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailSortTermTest method testSortTerm.
@Test
public void testSortTerm() throws Exception {
Mailbox mailbox = Mailbox.get("bill@localhost");
assertEquals(3, mailbox.size());
// This one has search term *not* set
MockEndpoint mockAsc = getMockEndpoint("mock:resultAscending");
mockAsc.expectedBodiesReceived("Earlier date", "Later date");
context.startAllRoutes();
assertMockEndpointsSatisfied();
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class FromFileSendMailTest method testSendFileAsMail.
@Test
public void testSendFileAsMail() throws Exception {
Mailbox.clearAll();
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
result.message(0).body().isInstanceOf(GenericFile.class);
template.sendBodyAndHeader("file://target/mailtext", "Hi how are you", Exchange.FILE_NAME, "mail.txt");
assertMockEndpointsSatisfied();
Mailbox mailbox = Mailbox.get("james@localhost");
assertEquals(1, mailbox.size());
Object body = mailbox.get(0).getContent();
assertEquals("Hi how are you", body);
Object subject = mailbox.get(0).getSubject();
assertEquals("Hello World", subject);
}
Aggregations