Package org.apache.james.mime4j.dom.field

Examples of org.apache.james.mime4j.dom.field.MimeVersionField


        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        return MimeVersionFieldLenientImpl.PARSER.parse(rawField, null);
    }

    static void check(String input, int expectedMajorVersion, int expectedMinorVersion) throws Exception {
        MimeVersionField f = parse("MIME-Version: " + input);
        assertEquals("Major version number", expectedMajorVersion, f.getMajorVersion());
        assertEquals("Minor version number", expectedMinorVersion, f.getMinorVersion());
    }
View Full Code Here


    public void testLineWithNestedComments() throws Exception {
        check("2(4.45 ( Another ()comment () blah (Wobble(mix)))Whatever).4", 2, 4);
    }

    public void testMalformed1() throws Exception {
        MimeVersionField f = parse("MIME-Version: 5  ");
        assertEquals(5, f.getMajorVersion());
        assertEquals(MimeVersionFieldImpl.DEFAULT_MINOR_VERSION, f.getMinorVersion());
        assertNull(f.getParseException());
    }
View Full Code Here

        assertEquals(MimeVersionFieldImpl.DEFAULT_MINOR_VERSION, f.getMinorVersion());
        assertNull(f.getParseException());
    }

    public void testMalformed2() throws Exception {
        MimeVersionField f = parse("MIME-Version: 5.  ");
        assertEquals(5, f.getMajorVersion());
        assertEquals(MimeVersionFieldImpl.DEFAULT_MINOR_VERSION, f.getMinorVersion());
        assertNull(f.getParseException());
    }
View Full Code Here

        assertEquals(MimeVersionFieldImpl.DEFAULT_MINOR_VERSION, f.getMinorVersion());
        assertNull(f.getParseException());
    }

    public void testMalformed3() throws Exception {
        MimeVersionField f = parse("MIME-Version: .5  ");
        assertEquals(MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION, f.getMajorVersion());
        assertEquals(5, f.getMinorVersion());
        assertNull(f.getParseException());
    }
View Full Code Here

        assertEquals(5, f.getMinorVersion());
        assertNull(f.getParseException());
    }

    public void testMalformed4() throws Exception {
        MimeVersionField f = parse("MIME-Version: crap ");
        assertEquals(MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION, f.getMajorVersion());
        assertEquals(MimeVersionFieldImpl.DEFAULT_MINOR_VERSION, f.getMinorVersion());
        assertNull(f.getParseException());
    }
View Full Code Here

     * header.
     * Defaults to one.
     * @return positive integer
     */
    public int getMimeMajorVersion() {
        MimeVersionField mimeVersionField = (MimeVersionField) fields.get(MIME_VERSION);
        return mimeVersionField != null ? mimeVersionField.getMajorVersion() :
            MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION;
    }
View Full Code Here

     * header.
     * Defaults to zero.
     * @return positive integer
     */
    public int getMimeMinorVersion() {
        MimeVersionField mimeVersionField = (MimeVersionField) fields.get(MIME_VERSION);
        return mimeVersionField != null ? mimeVersionField.getMinorVersion() :
            MimeVersionFieldImpl.DEFAULT_MINOR_VERSION;
    }
View Full Code Here

        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        return MimeVersionFieldImpl.PARSER.parse(rawField, null);
    }

    static void check(String input, int expectedMajorVersion, int expectedMinorVersion) throws Exception {
        MimeVersionField f = parse("MIME-Version: " + input);
        assertEquals("Major version number", expectedMajorVersion, f.getMajorVersion());
        assertEquals("Minor version number", expectedMinorVersion, f.getMinorVersion());
    }
View Full Code Here

    public void testLineWithNestedComments() throws Exception {
        check("2(4.45 ( Another ()comment () blah (Wobble(mix)))Whatever).4", 2, 4);
    }

    public void testEmptyLine() throws Exception {
        MimeVersionField f = parse("MIME-Version: (This is just a comment)");
        assertEquals(MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION, f.getMajorVersion());
        assertEquals(MimeVersionFieldImpl.DEFAULT_MINOR_VERSION, f.getMinorVersion());
        assertNotNull(f.getParseException());
    }
View Full Code Here

    }

    public void testMimeVersion() throws Exception {
        MessageImpl m = new MessageImpl();
        assertNotNull(m.getHeader());
        MimeVersionField field = (MimeVersionField) m.getHeader().getField(FieldName.MIME_VERSION);
        assertNotNull(field);
        assertEquals(1, field.getMajorVersion());
        assertEquals(0, field.getMinorVersion());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.field.MimeVersionField

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.