Package org.apache.james.mime4j.message

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


    public void testGetCc() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getCc());

        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Cc: john.doe@example.net"));
        m.setHeader(header);

        assertEquals("john.doe@example.net", ((Mailbox) m.getCc().get(0))
                .getAddress());
    }
View Full Code Here


    public void testGetBcc() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getBcc());

        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Bcc: john.doe@example.net"));
        m.setHeader(header);

        assertEquals("john.doe@example.net", ((Mailbox) m.getBcc().get(0))
                .getAddress());
    }
View Full Code Here

    public void testGetReplyTo() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getReplyTo());

        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Reply-To: john.doe@example.net"));
        m.setHeader(header);

        assertEquals("john.doe@example.net", ((Mailbox) m.getReplyTo().get(0))
                .getAddress());
    }
View Full Code Here

        assertNull(copy.getParent());
    }

    public void testCopyMessage() throws Exception {
        MessageImpl parent = new MessageImpl();
        Header header = new HeaderImpl();
        Body body = new BasicBodyFactory().textBody("test");

        MessageImpl original = new MessageImpl();
        original.setHeader(header);
        original.setBody(body);
View Full Code Here

        assertNull(copy.getParent());
    }

    public void testCopyBodyPart() throws Exception {
        MessageImpl parent = new MessageImpl();
        Header header = new HeaderImpl();
        Body body = new BasicBodyFactory().textBody("test");

        BodyPart original = new BodyPart();
        original.setHeader(header);
        original.setBody(body);
View Full Code Here

        Multipart multipart = new MultipartImpl("mixed");
        multipart.addBodyPart(bodyPart1);
        multipart.addBodyPart(bodyPart2);

        MessageImpl original = new MessageImpl();
        original.setHeader(new HeaderImpl());
        original.setBody(multipart);

        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        Message copy = builder.copy(original);
View Full Code Here

    public void testCopyHeader() throws Exception {
        Field f1 = DefaultFieldParser.parse("name1: value1");
        Field f2 = DefaultFieldParser.parse("name2: value");
        Field f3 = DefaultFieldParser.parse("name1: value2");

        Header original = new HeaderImpl();
        original.addField(f1);
        original.addField(f2);
        original.addField(f3);

        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        Header copy = builder.copy(original);

        // copy must have same fields as original
        assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());
        assertEquals(Arrays.asList(f1, f3), copy.getFields("name1"));

        // modify original
        original.removeFields("name1");
        assertEquals(Arrays.asList(f2), original.getFields());

        // copy may not be affected
        assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());
        assertEquals(Arrays.asList(f1, f3), copy.getFields("name1"));
    }
View Full Code Here

            final MimeTokenStream parser = new MimeTokenStream(config, new DefaultBodyDescriptorBuilder());

            parser.setRecursionMode(RecursionMode.M_NO_RECURSE);
            parser.parse(bIn);
            final HeaderImpl header = new HeaderImpl();

            EntityState next = parser.next();
            while (next != EntityState.T_BODY && next != EntityState.T_END_OF_STREAM && next != EntityState.T_START_MULTIPART) {
                if (next == EntityState.T_FIELD) {
                    header.addField(parser.getField());
                }
                next = parser.next();
            }
            final MaximalBodyDescriptor descriptor = (MaximalBodyDescriptor) parser.getBodyDescriptor();
            final PropertyBuilder propertyBuilder = new PropertyBuilder();
View Full Code Here

TOP

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

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.