Package org.apache.james.mime4j.util

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


        List<NameValuePair> params = parser.parseParameters(buf, cursor);
        assertEquals(0, params.size());
    }

    public void testNameValueListParseEscaped() {
        ByteSequence buf = ContentUtil.encode(
          "test1 =  \"\\\"stuff\\\"\"; test2= \"\\\\\"; test3 = \"stuff; stuff\"");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        List<NameValuePair> params = parser.parseParameters(buf, cursor);
        assertEquals(3, params.size());
        assertEquals("test1", params.get(0).getName());
        assertEquals("\"stuff\"", params.get(0).getValue());
        assertEquals("test2", params.get(1).getName());
View Full Code Here


        assertEquals("test3", params.get(2).getName());
        assertEquals("stuff; stuff", params.get(2).getValue());
    }

    public void testRawBodyParse() {
        ByteSequence buf = ContentUtil.encode(
                "  text/plain ; charset=ISO-8859-1; "
                + "boundary=foo; param1=value1; param2=\"value2\"; param3=value3");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        RawBody body = parser.parseRawBody(buf, cursor);
        assertNotNull(body);
        assertEquals("text/plain", body.getValue());
        List<NameValuePair> params = body.getParams();
        assertEquals(5, params.size());
View Full Code Here

        assertEquals("param3", params.get(4).getName());
        assertEquals("value3", params.get(4).getValue());
    }

    public void testRawBodyParseWithComments() {
        ByteSequence buf = ContentUtil.encode(
                "  text/(nothing special)plain ; charset=(latin)ISO-8859-1; "
                + "boundary=foo(bar);");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        RawBody body = parser.parseRawBody(buf, cursor);
        assertNotNull(body);
        assertEquals("text/plain", body.getValue());
        List<NameValuePair> params = body.getParams();
        assertEquals(2, params.size());
View Full Code Here

        assertEquals("boundary", params.get(1).getName());
        assertEquals("foo", params.get(1).getValue());
    }

    public void testRawBodyParseEmptyParam() {
        ByteSequence buf = ContentUtil.encode(
                "multipart/alternative;; boundary=\"boundary\"");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        RawBody body = parser.parseRawBody(buf, cursor);
        assertNotNull(body);
        assertEquals("multipart/alternative", body.getValue());
        List<NameValuePair> params = body.getParams();
        assertEquals(2, params.size());
View Full Code Here

        assertEquals("boundary", params.get(1).getName());
        assertEquals("boundary", params.get(1).getValue());
    }

    public void testRawBodyParseFolded() {
        ByteSequence buf = ContentUtil.encode(
                "multipart/alternative; boundary=\"simple\r\n boundary\"");
        ParserCursor cursor = new ParserCursor(0, buf.length());
        RawBody body = parser.parseRawBody(buf, cursor);
        assertNotNull(body);
        assertEquals("multipart/alternative", body.getValue());
        List<NameValuePair> params = body.getParams();
        assertEquals(1, params.size());
View Full Code Here

                new String(buf.toByteArray(), "US-ASCII"));
        RawField field = builder.build();
        assertNotNull(field);
        assertEquals("raw", field.getName());
        assertEquals("  stuff;   more stuff;   a lot more stuff", field.getBody());
        ByteSequence raw = field.getRaw();
        assertNotNull(raw);
        assertEquals("raw:   stuff;\r\n   more stuff;\r\n   a lot more stuff",
                new String(raw.toByteArray(), "US-ASCII"));
    }
View Full Code Here

                new String(buf.toByteArray(), "US-ASCII"));
        RawField field = builder.build();
        assertNotNull(field);
        assertEquals("raw", field.getName());
        assertEquals("stuff;   more stuff;   a lot more stuff", field.getBody());
        ByteSequence raw = field.getRaw();
        assertNotNull(raw);
        assertEquals("raw  : stuff;\r\n   more stuff;\r\n   a lot more stuff",
                new String(raw.toByteArray(), "US-ASCII"));
    }
View Full Code Here

                new String(buf.toByteArray(), "US-ASCII"));
        RawField field = builder.build();
        assertNotNull(field);
        assertEquals("raw", field.getName());
        assertEquals("  stuff;   more stuff;   a lot more stuff", field.getBody());
        ByteSequence raw = field.getRaw();
        assertNotNull(raw);
        assertEquals("raw:   stuff;\r\n   more stuff;\r\n   a lot more stuff",
                new String(raw.toByteArray(), "US-ASCII"));
    }
View Full Code Here

public class RawFieldTest extends TestCase {

    public void testPrivateConstructor() throws Exception {
        String s = "raw: stuff;\r\n  more stuff";
        ByteSequence raw = ContentUtil.encode(s);
        RawField field = new RawField(raw, 3, "raw", null);
        Assert.assertSame(raw, field.getRaw());
        Assert.assertEquals("raw", field.getName());
        Assert.assertEquals("stuff;  more stuff", field.getBody());
        Assert.assertEquals(s, field.toString());
View Full Code Here

        Assert.assertEquals("raw: ", field2.toString());
    }

    public void testTabAfterDelimiter() throws Exception {
        String s = "raw:\tstuff;\r\n  more stuff";
        ByteSequence raw = ContentUtil.encode(s);
        RawField field = new RawField(raw, 3, "raw", null);
        Assert.assertSame(raw, field.getRaw());
        Assert.assertEquals("raw", field.getName());
        Assert.assertEquals("stuff;  more stuff", field.getBody());
        Assert.assertEquals(s, field.toString());
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.