Search in sources :

Example 31 with Mailbox

use of org.jvnet.mock_javamail.Mailbox in project camel by apache.

the class MailCustomContentTypeTest method testSendPlainMailContentTypeTinyTypeInHeader.

@Test
public void testSendPlainMailContentTypeTinyTypeInHeader() throws Exception {
    Mailbox.clearAll();
    // Camel will fixup the Content-Type if you do not have a space after the semi colon
    template.sendBodyAndHeader("direct:b", "Hello World", "contentType", "text/plain;charset=iso-8859-1");
    Mailbox box = Mailbox.get("claus@localhost");
    Message msg = box.get(0);
    // the content type should have a space after the semi colon
    assertEquals("text/plain; charset=iso-8859-1", msg.getContentType());
    assertEquals("Hello World", msg.getContent());
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) Message(javax.mail.Message) Test(org.junit.Test)

Example 32 with Mailbox

use of org.jvnet.mock_javamail.Mailbox in project camel by apache.

the class MailCustomContentTypeTest method testNullBody.

@Test
public void testNullBody() throws Exception {
    Mailbox.clearAll();
    template.sendBodyAndHeader("direct:b", null, "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("", msg.getContent());
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) Message(javax.mail.Message) Test(org.junit.Test)

Example 33 with Mailbox

use of org.jvnet.mock_javamail.Mailbox in project camel by apache.

the class MailCustomContentTypeTest method testSendHtmlMailIso88591.

@Test
public void testSendHtmlMailIso88591() throws Exception {
    Mailbox.clearAll();
    sendBody("direct:c", "<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=iso-8859-1", msg.getContentType());
    assertEquals("<html><body><h1>Hello</h1>World</body></html>", msg.getContent());
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) Message(javax.mail.Message) Test(org.junit.Test)

Example 34 with Mailbox

use of org.jvnet.mock_javamail.Mailbox in project camel by apache.

the class MailSearchTermNotSpamTest method testSearchTerm.

@Test
public void testSearchTerm() throws Exception {
    Mailbox mailbox = Mailbox.get("bill@localhost");
    assertEquals(6, mailbox.size());
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceivedInAnyOrder("I like riding the Camel", "Ordering Camel in Action", "Ordering ActiveMQ in Action", "We meet at 7pm the usual place");
    assertMockEndpointsSatisfied();
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 35 with Mailbox

use of org.jvnet.mock_javamail.Mailbox in project camel by apache.

the class MailPostProcessActionTest method testActionCalled.

@Test
public void testActionCalled() throws Exception {
    Mailbox mailbox = Mailbox.get("bill@localhost");
    assertEquals(1, mailbox.size());
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceivedInAnyOrder("TestText");
    assertMockEndpointsSatisfied();
    waitForActionCalled();
}
Also used : Mailbox(org.jvnet.mock_javamail.Mailbox) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) 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