use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailSortTermTwoTest method testSortTerm.
@Test
public void testSortTerm() throws Exception {
Mailbox mailbox = Mailbox.get("bill@localhost");
assertEquals(3, mailbox.size());
// This one has search term set
MockEndpoint mockDesc = getMockEndpoint("mock:resultDescending");
mockDesc.expectedBodiesReceived("Even later date", "Later date", "Earlier date");
context.startAllRoutes();
assertMockEndpointsSatisfied();
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailMultipleRecipientsUsingHeadersTest method testMailMultipleRecipientUsingHeaders.
@Test
public void testMailMultipleRecipientUsingHeaders() throws Exception {
Mailbox.clearAll();
// START SNIPPET: e1
Map<String, Object> map = new HashMap<String, Object>();
map.put("To", new String[] { "davsclaus@apache.org", "janstey@apache.org" });
map.put("From", "jstrachan@apache.org");
map.put("Subject", "Camel rocks");
String body = "Hello Riders.\nYes it does.\n\nRegards James.";
template.sendBodyAndHeaders("smtp://davsclaus@apache.org", body, map);
// END SNIPPET: e1
Mailbox box = Mailbox.get("davsclaus@apache.org");
Message msg = box.get(0);
assertEquals("davsclaus@apache.org", msg.getRecipients(Message.RecipientType.TO)[0].toString());
assertEquals("janstey@apache.org", msg.getRecipients(Message.RecipientType.TO)[1].toString());
assertEquals("jstrachan@apache.org", msg.getFrom()[0].toString());
assertEquals("Camel rocks", msg.getSubject());
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailPollEnrichTest method testPollEnrich.
@Test
public void testPollEnrich() throws Exception {
Mailbox mailbox = Mailbox.get("bill@localhost");
assertEquals(5, mailbox.size());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Message 0");
template.sendBody("direct:start", "");
mock.assertIsSatisfied();
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class MailPollEnrichTest method testPollEnrichNullBody.
@Test
public void testPollEnrichNullBody() throws Exception {
Mailbox mailbox = Mailbox.get("bill@localhost");
assertEquals(5, mailbox.size());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Message 0");
template.sendBody("direct:start", null);
mock.assertIsSatisfied();
}
use of org.jvnet.mock_javamail.Mailbox in project camel by apache.
the class ReportIncidentRoutesTest method testRendportIncident.
@Test
public void testRendportIncident() throws Exception {
// assert mailbox is empty before starting
Mailbox inbox = Mailbox.get("incident@localhost");
inbox.clear();
assertEquals("Should not have mails", 0, inbox.size());
// create input parameter
InputReportIncident input = new InputReportIncident();
input.setIncidentId("222");
input.setIncidentDate("2010-07-14");
input.setGivenName("Charles");
input.setFamilyName("Moulliard");
input.setSummary("Bla");
input.setDetails("Bla bla");
input.setEmail("cmoulliard@apache.org");
input.setPhone("0011 22 33 44");
// create the webservice client and send the request
String url = context.resolvePropertyPlaceholders(URL);
ReportIncidentEndpoint client = createCXFClient(url);
OutputReportIncident out = client.reportIncident(input);
// assert we got a OK back
assertEquals("0", out.getCode());
// let some time pass to allow Camel to pickup the file and send it as an email
Thread.sleep(3000);
// assert mail box
assertEquals("Should have got 1 mail", 1, inbox.size());
}
Aggregations