Package org.apache.mailet.base.test

Examples of org.apache.mailet.base.test.FakeMail


        mm.addBodyPart(mp3);
        message.setSubject("test");
        message.setContent(mm);
        message.saveChanges();

        Mail mail = new FakeMail();
        mail.setMessage(message);

        mailet.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage,
                new String[] { "Bcc", "Content-Length", "Message-ID" });
        // String res = rawMessage.toString();

        Collection c = (Collection) mail
                .getAttribute(StripAttachment.SAVED_ATTACHMENTS_ATTRIBUTE_KEY);
        assertNotNull(c);

        assertEquals(1, c.size());
View Full Code Here


        message.saveChanges();

        // message.writeTo(System.out);
        // System.out.println("--------------------------\n\n\n");

        Mail mail = new FakeMail();
        mail.setMessage(message);

        mailet.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage,
                new String[] { "Bcc", "Content-Length", "Message-ID" });
        // String res = rawMessage.toString();

        Collection c = (Collection) mail
                .getAttribute(StripAttachment.SAVED_ATTACHMENTS_ATTRIBUTE_KEY);
        assertNotNull(c);

        assertEquals(1, c.size());
View Full Code Here

        mp3.setFileName("temp.zip");
        mm.addBodyPart(mp3);
        message.setSubject("test");
        message.setContent(mm);
        message.saveChanges();
        Mail mail = new FakeMail();
        mail.setMessage(message);

        assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
        assertEquals(3, ((MimeMultipart) mail.getMessage().getContent())
                .getCount());

        strip.service(mail);

        assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
        assertEquals(1, ((MimeMultipart) mail.getMessage().getContent())
                .getCount());

        onlyText.service(mail);

        assertFalse(mail.getMessage().getContent() instanceof MimeMultipart);
       
        assertEquals("simple text", mail.getMessage().getContent());

        // prova per caricare il mime message da input stream che altrimenti
        // javamail si comporta differentemente.
        String mimeSource = "Message-ID: <26194423.21197328775426.JavaMail.bago@bagovista>\r\nSubject: test\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=us-ascii\r\nContent-Transfer-Encoding: 7bit\r\n\r\nsimple text";

        MimeMessage mmNew = new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(mimeSource.getBytes("UTF-8")));

        mmNew.writeTo(System.out);
        mail.setMessage(mmNew);
       
        recover.service(mail);

        assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
        assertEquals(2, ((MimeMultipart) mail.getMessage().getContent())
                .getCount());

        Object actual = ((MimeMultipart) mail.getMessage().getContent())
                .getBodyPart(1).getContent();
        if (actual instanceof ByteArrayInputStream) {
            assertEquals(body2, toString((ByteArrayInputStream) actual));
        } else {
            assertEquals(body2, actual);
View Full Code Here

        FakeMailetConfig mci = new FakeMailetConfig("Test",new FakeMailContext());
        mci.setProperty("text",footer);

        mailet.init(mci);

        Mail mail = new FakeMail();
        mail.setMessage(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(asciisource.getBytes())));

        mailet.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(
                rawMessage,
                new String[] { "Bcc", "Content-Length", "Message-ID" });
        String res = rawMessage.toString();
        return res;
    }
View Full Code Here

    }

    // test if the Header was add
    public void testHeaderIsPresent() throws MessagingException {
        MimeMessage mockedMimeMessage = MailUtil.createMimeMessage(headerName, headerValue);
        FakeMail mockedMail = MailUtil.createMockMail2Recipients(mockedMimeMessage);
        setupMailet();

        mailet.service(mockedMail);

        assertEquals(HEADER_VALUE, mockedMail.getMessage().getHeader(
                HEADER_NAME)[0]);

    }
View Full Code Here

    public void testHeaderIsReplaced() throws MessagingException {
        setHeaderName(HEADER_NAME);
        setHeaderValue(headerValue);

        MimeMessage mockedMimeMessage = MailUtil.createMimeMessage(headerName, headerValue);
        FakeMail mockedMail = MailUtil.createMockMail2Recipients(mockedMimeMessage);
        setupMailet();

        mailet.service(mockedMail);

        assertEquals(HEADER_VALUE, mockedMail.getMessage().getHeader(
                HEADER_NAME)[0]);

    }
View Full Code Here

    public NullTest(String arg0) throws UnsupportedEncodingException {
        super(arg0);
    }

    private void setupMockedMail(MimeMessage m) throws ParseException {
        mockedMail = new FakeMail();
        mockedMail.setMessage(m);
        mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
                new MailAddress("test@james.apache.org"),
                new MailAddress("test2@james.apache.org") }));
View Full Code Here

    public SizeGreaterThanTest(String arg0) throws UnsupportedEncodingException {
        super(arg0);
    }

    private void setupMockedMail(long size) throws ParseException {
        mockedMail = new FakeMail();
        mockedMail.setMessageSize(size);
        mockedMail.setRecipients(Arrays.asList(new MailAddress[] {new MailAddress("test@email")}));

    }
View Full Code Here

    protected void setSubject(String subject) {
        this.subject = subject;
    }

    protected void setupMockedMail(MimeMessage m) {
        mockedMail = new FakeMail();
        mockedMail.setMessage(m);

    }
View Full Code Here

    protected void setRecipients(MailAddress[] recipients) {
        this.recipients = recipients;
    }

    protected void setupMockedMail() {
        mockedMail = new FakeMail();
        mockedMail.setRecipients(Arrays.asList(recipients));

    }
View Full Code Here

TOP

Related Classes of org.apache.mailet.base.test.FakeMail

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.