Package org.apache.james.mime4j.dom

Examples of org.apache.james.mime4j.dom.Header


     *            name of the field to retrieve.
     * @return the header field or <code>null</code> if this entity has no
     *         header or the header contains no such field.
     */
    <F extends ParsedField> F obtainField(String fieldName) {
        Header header = getHeader();
        if (header == null)
            return null;

        @SuppressWarnings("unchecked")
        F field = (F) header.getField(fieldName);
        return field;
    }
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

    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

    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

    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

TOP

Related Classes of org.apache.james.mime4j.dom.Header

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.