Search in sources :

Example 21 with Mailbox

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();
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 22 with Mailbox

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());
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) Message(javax.mail.Message) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 23 with Mailbox

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();
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 24 with Mailbox

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();
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 25 with Mailbox

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());
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) Test(org.junit.Test)

Aggregations

Mailbox (org.jvnet.mock_javamail.Mailbox)44 Test (org.junit.Test)39 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)20 Message (javax.mail.Message)18 HashMap (java.util.HashMap)5 MimeMessage (javax.mail.internet.MimeMessage)3 Address (javax.mail.Address)2 Exchange (org.apache.camel.Exchange)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Folder (javax.mail.Folder)1 Session (javax.mail.Session)1 InternetAddress (javax.mail.internet.InternetAddress)1 MimeMultipart (javax.mail.internet.MimeMultipart)1 NotifyBuilder (org.apache.camel.builder.NotifyBuilder)1