Package org.apache.james.mime4j.message

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


        assertEquals("received", header.getFields().get(1).getName());
        assertEquals("Content-type", header.getFields().get(2).getName());
    }

    public void testSetNonExistantField() throws Exception {
        Header header = new HeaderImpl();
        header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
        header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
        header.addField(DefaultFieldParser.parse("ReCeIvEd: from bar by foo for james"));

        header.setField(DefaultFieldParser.parse("Message-ID: <msg9901@apache.org>"));

        assertEquals(4, header.getFields().size());
        assertEquals(1, header.getFields("message-id").size());

        assertEquals("Message-ID", header.getFields().get(3).getName());
    }
View Full Code Here


    public void testGetDispositionType() throws Exception {
        BodyPart entity = new BodyPart();

        assertNull(entity.getDispositionType());

        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Content-Disposition: inline"));
        entity.setHeader(header);

        assertEquals("inline", entity.getDispositionType());
    }
View Full Code Here

    public void testGetFilename() throws Exception {
        BodyPart entity = new BodyPart();

        assertNull(entity.getFilename());

        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Content-Disposition: attachment; "
                + "filename=\"some file.dat\""));
        entity.setHeader(header);

        assertEquals("some file.dat", entity.getFilename());
    }
View Full Code Here

    private Header headerMultipartMixed = null;
    private Header headerMultipartDigest = null;

    @Override
    public void setUp() throws Exception {
        headerTextPlain = new HeaderImpl();
        headerMessageRFC822 = new HeaderImpl();
        headerEmpty = new HeaderImpl();
        headerMultipartMixed = new HeaderImpl();
        headerMultipartDigest = new HeaderImpl();

        headerTextPlain.addField(
                DefaultFieldParser.parse("Content-Type: text/plain"));
        headerMessageRFC822.addField(
                DefaultFieldParser.parse("Content-Type: message/RFC822"));
View Full Code Here

    public void testGetMessageId() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getMessageId());

        String id = "<msg17@localhost>";
        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Message-ID: " + id));
        m.setHeader(header);
        assertEquals(id, m.getMessageId());
    }
View Full Code Here

    public void testGetSubject() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getSubject());

        String subject = "testing 1 2";
        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Subject: " + subject));
        m.setHeader(header);
        assertEquals(subject, m.getSubject());

        header.setField(DefaultFieldParser.parse("Subject: =?windows-1252?Q?99_=80?="));
        assertEquals("99 \u20ac", m.getSubject());
    }
View Full Code Here

    public void testGetDate() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getDate());

        Header header = new HeaderImpl();
        header.setField(DefaultFieldParser.parse("Date: Thu, 1 Jan 1970 05:30:00 +0530"));
        m.setHeader(header);

        assertEquals(new Date(0), m.getDate());
    }
View Full Code Here

    public void testGetSender() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getSender());

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

        assertEquals("john.doe@example.net", m.getSender().getAddress());
    }
View Full Code Here

    public void testGetFrom() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getFrom());

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

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

    public void testGetTo() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNull(m.getTo());

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

        assertEquals("john.doe@example.net", ((Mailbox) m.getTo().get(0))
                .getAddress());
    }
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.