Package org.apache.james.mime4j.util

Examples of org.apache.james.mime4j.util.ByteSequence


        Assert.assertEquals("stuff and some more stuff", result);
    }

    public void testTokenParsingMixedValuesAndQuotedValues() throws Exception {
        String s = "  stuff and    \" some more \"   \"stuff  ;";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());
        String result = parser.parseValue(raw, cursor, RawFieldParser.INIT_BITSET(';'));
        Assert.assertEquals("stuff and  some more  stuff  ;", result);
    }
View Full Code Here


        Assert.assertEquals("stuff and  some more  stuff  ;", result);
    }

    public void testTokenParsingQuotedValuesWithComments() throws Exception {
        String s = " (blah blah)  \"(stuff)(and)(some)(more)(stuff)\" (yada yada) ";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());
        String result = parser.parseValue(raw, cursor, RawFieldParser.INIT_BITSET(';'));
        Assert.assertEquals("(stuff)(and)(some)(more)(stuff)", result);
    }
View Full Code Here

        Assert.assertEquals("(stuff)(and)(some)(more)(stuff)", result);
    }

    public void testBasicParsing() throws Exception {
        String s = "raw: stuff;\r\n  more stuff";
        ByteSequence raw = ContentUtil.encode(s);

        RawField field = parser.parseField(raw);
        Assert.assertSame(raw, field.getRaw());
        Assert.assertEquals("raw", field.getName());
        Assert.assertEquals("stuff;  more stuff", field.getBody());
View Full Code Here

        Assert.assertEquals(s, field.toString());
    }

    public void testParsingNoBlankAfterColon() throws Exception {
        String s = "raw:stuff";
        ByteSequence raw = ContentUtil.encode(s);

        RawField field = parser.parseField(raw);
        Assert.assertSame(raw, field.getRaw());
        Assert.assertEquals("raw", field.getName());
        Assert.assertEquals("stuff", field.getBody());
View Full Code Here

        Assert.assertEquals(s, field.toString());
    }

    public void testParsingObsoleteSyntax() throws Exception {
        String s = "raw  \t  : stuff;\r\n  more stuff";
        ByteSequence raw = ContentUtil.encode(s);

        RawField field = parser.parseField(raw);
        Assert.assertSame(raw, field.getRaw());
        Assert.assertEquals("raw", field.getName());
        Assert.assertEquals("stuff;  more stuff", field.getBody());
View Full Code Here

        Assert.assertEquals(s, field.toString());
    }

    public void testParsingInvalidSyntax1() throws Exception {
        String s = "raw    stuff;\r\n  more stuff";
        ByteSequence raw = ContentUtil.encode(s);

        try {
            parser.parseField(raw);
            fail("MimeException should have been thrown");
        } catch (MimeException expected) {
View Full Code Here

        }
    }

    public void testParsingInvalidSyntax2() throws Exception {
        String s = "raw    \t \t";
        ByteSequence raw = ContentUtil.encode(s);

        try {
            parser.parseField(raw);
            fail("MimeException should have been thrown");
        } catch (MimeException expected) {
View Full Code Here

        }
    }

    public void testNameValueParseBasics() {
        String s = "test";
        ByteSequence buf = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        NameValuePair param = parser.parseParameter(buf, cursor);
        assertEquals("test", param.getName());
        assertEquals(null, param.getValue());
View Full Code Here

        assertEquals("", param.getName());
        assertEquals("stuff", param.getValue());
    }

    public void testNameValueListParseBasics() {
        ByteSequence buf = ContentUtil.encode(
                "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; test3=\"stuff");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        List<NameValuePair> params = parser.parseParameters(buf, cursor);

        assertEquals("test", params.get(0).getName());
        assertEquals(null, params.get(0).getValue());
        assertEquals("test1", params.get(1).getName());
        assertEquals("stuff", params.get(1).getValue());
        assertEquals("test2", params.get(2).getName());
        assertEquals("stuff; stuff", params.get(2).getValue());
        assertEquals("test3", params.get(3).getName());
        assertEquals("stuff", params.get(3).getValue());
        assertEquals(buf.length(), cursor.getPos());
        assertTrue(cursor.atEnd());
    }
View Full Code Here

        assertEquals(buf.length(), cursor.getPos());
        assertTrue(cursor.atEnd());
    }

    public void testNameValueListParseEmpty() {
        ByteSequence buf = ContentUtil.encode("    ");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        List<NameValuePair> params = parser.parseParameters(buf, cursor);
        assertEquals(0, params.size());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.util.ByteSequence

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.