Package org.apache.james.mime4j.message

Examples of org.apache.james.mime4j.message.DefaultMessageWriter


    public void testBinaryAttachmentNoPreamble() throws Exception {
        Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES);
        assertTrue("Is multipart", message.isMultipart());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DefaultMessageWriter writer = new DefaultMessageWriter();
        writer.writeMessage(message, out);
        assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES, out.toByteArray());
    }
View Full Code Here


    public void testBinaryAttachmentPreambleEpilogue() throws Exception {
        Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES);
        assertTrue("Is multipart", message.isMultipart());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DefaultMessageWriter writer = new DefaultMessageWriter();
        writer.writeMessage(message, out);
        assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES, out.toByteArray());
    }
View Full Code Here

        // assertEquals(hello, field.getBody());
        assertEquals(SWISS_GERMAN_HELLO, field.getBody());

        ByteArrayOutputStream outstream = new ByteArrayOutputStream();

        DefaultMessageWriter writer = new DefaultMessageWriter();
        writer.writeHeader(header, outstream);
        byte[] b = outstream.toByteArray();
        ByteArrayBuffer buf = new ByteArrayBuffer(b.length);
        buf.append(b, 0, b.length);
        String s = ContentUtil.decode(buf);
View Full Code Here

    public void testWriteTo() throws Exception {
        byte[] inputByte = getRawMessageAsByteArray();

        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        DefaultMessageWriter writer = new DefaultMessageWriter();

        Message m = builder.parseMessage(new ByteArrayInputStream(inputByte));
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        writer.writeMessage(m, out);

        InputStream output = new ByteArrayInputStream(out.toByteArray());

        int b = -1;
        int i = 0;
View Full Code Here

        String testheader = headerName + ": " + headerValue;

        byte[] inputByte = getRawMessageAsByteArray();

        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        DefaultMessageWriter writer = new DefaultMessageWriter();

        Message m = builder.parseMessage(new ByteArrayInputStream(inputByte));
        m.getHeader().addField(DefaultFieldParser.parse(testheader));

        assertEquals("header added", m.getHeader().getField(headerName)
                .getBody(), headerValue);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        writer.writeMessage(m, out);
        List<?> lines = IOUtils.readLines((new BufferedReader(
                new InputStreamReader(new ByteArrayInputStream(out
                        .toByteArray())))));

        assertTrue("header added", lines.contains(testheader));
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.message.DefaultMessageWriter

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.