Package org.jvnet.mock_javamail

Examples of org.jvnet.mock_javamail.Mailbox


    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("text/html; charset=UTF-8", msg.getContentType());
        assertEquals("<html><body><h1>Hello</h1>World</body></html>", msg.getContent());
    }
View Full Code Here


    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());
    }
View Full Code Here

    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());
    }
View Full Code Here

    public void testSendPlainMailContentTypeInHeader() throws Exception {
        Mailbox.clearAll();

        template.sendBodyAndHeader("direct:b", "Hello World", "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("Hello World", msg.getContent());
    }
View Full Code Here

    public void testSendPlainMailContentTypeInHeader2() throws Exception {
        Mailbox.clearAll();

        template.sendBodyAndHeader("direct:b", "Hello World", Exchange.CONTENT_TYPE, "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("Hello World", msg.getContent());
    }
View Full Code Here

        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());
    }
View Full Code Here

    public void testRawMessageConsumerImap() throws Exception {
        testRawMessageConsumer("Imap");
    }

    private void testRawMessageConsumer(String type) throws Exception {
        Mailbox mailboxRaw = Mailbox.get("jonesRaw" + type + "@localhost");
        assertEquals(1, mailboxRaw.size());

        MockEndpoint mock = getMockEndpoint("mock://rawMessage" + type);
        mock.expectedMessageCount(1);
        mock.expectedBodyReceived().body().isNotNull();
        assertMockEndpointsSatisfied();
View Full Code Here

    public void testNormalMessageConsumerImap() throws Exception {
        testNormalMessageConsumer("Imap");
    }

    private void testNormalMessageConsumer(String type) throws Exception {
        Mailbox mailbox = Mailbox.get("jones" + type + "@localhost");
        assertEquals(1, mailbox.size());

        MockEndpoint mock = getMockEndpoint("mock://normalMessage" + type);
        mock.expectedMessageCount(1);
        mock.expectedBodyReceived().body().isNotNull();
        assertMockEndpointsSatisfied();
View Full Code Here

        super.setUp();
    }

    @Test
    public void testFetchSize() throws Exception {
        Mailbox mailbox = Mailbox.get("bill@localhost");
        assertEquals(5, mailbox.size());

        MockEndpoint mock = getMockEndpoint("mock:result");
        // no messages expected as we have a fetch size of zero
        mock.expectedMessageCount(0);
        // should be done within 2 seconds as no delay when started
        mock.setResultWaitTime(2000L);
        mock.assertIsSatisfied();

        assertEquals(5, mailbox.size());
    }
View Full Code Here

    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());
    }
View Full Code Here

TOP

Related Classes of org.jvnet.mock_javamail.Mailbox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.