Package org.apache.james.mime4j.util

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


        assertEquals('g', raw.byteAt(cursor.getPos()));
    }

    public void testParseRoute() throws Exception {
        String s = "  @a, @b, @c :me@home";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        DomainList route = parser.parseRoute(raw, cursor);
        assertNotNull(route);
        assertEquals(3, route.size());
        assertEquals("a", route.get(0));
        assertEquals("b", route.get(1));
        assertEquals("c", route.get(2));
        assertEquals('m', raw.byteAt(cursor.getPos()));
    }
View Full Code Here


        assertEquals('m', raw.byteAt(cursor.getPos()));
    }

    public void testParseNoRoute() throws Exception {
        String s = "stuff";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        DomainList route = parser.parseRoute(raw, cursor);
        assertNull(route);
    }
View Full Code Here

        assertNull(mailbox1);
    }

    public void testParseMailboxList() throws Exception {
        String s = "a , b, ,,, c, d,;garbage";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());
        List<Mailbox> mailboxes = parser.parseMailboxes(raw, cursor, RawFieldParser.INIT_BITSET(';'));
        assertEquals(4, mailboxes.size());

        Mailbox mailbox1 = mailboxes.get(0);
        assertEquals("a", mailbox1.getAddress());
        Mailbox mailbox2 = mailboxes.get(1);
        assertEquals("b", mailbox2.getAddress());
        Mailbox mailbox3 = mailboxes.get(2);
        assertEquals("c", mailbox3.getAddress());
        Mailbox mailbox4 = mailboxes.get(3);
        assertEquals("d", mailbox4.getAddress());
        assertEquals(';', raw.byteAt(cursor.getPos()));
    }
View Full Code Here

        assertEquals(';', raw.byteAt(cursor.getPos()));
    }

    public void testParseMailboxListEmpty() throws Exception {
        String s = "   ";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());
        List<Mailbox> mailboxes = parser.parseMailboxes(raw, cursor, RawFieldParser.INIT_BITSET(';'));
        assertEquals(0, mailboxes.size());
    }
View Full Code Here

        assertEquals(0, mailboxes.size());
    }

    public void testParseGroup() throws Exception {
        String s = "group: john.doe@acme.org, Mary Smith <mary@example.net>";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());
        Group group = parser.parseGroup(raw, cursor);
        assertEquals("group", group.getName());

        MailboxList mailboxes = group.getMailboxes();
View Full Code Here

import junit.framework.TestCase;

public class LenientDateTimeFieldTest extends TestCase {

    static DateTimeField parse(final String s) throws MimeException {
        ByteSequence raw = ContentUtil.encode(s);
        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        return DateTimeFieldLenientImpl.PARSER.parse(rawField, null);
    }
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

        parser = LenientAddressBuilder.DEFAULT;
    }

    public void testParseDomain() throws Exception {
        String s = "machine (comment).  example (dot). com  ; more stuff";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        String domain = parser.parseDomain(raw, cursor, RawFieldParser.INIT_BITSET(';'));
        assertEquals("machine.example.com", domain);
    }
View Full Code Here

        assertEquals("machine.example.com", domain);
    }

    public void testParseMailboxAddress() throws Exception {
        String s = "<  some  one @ some host . some where . com >";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
        assertEquals("some one@somehost.somewhere.com", mailbox.getAddress());
    }
View Full Code Here

        assertEquals("some one@somehost.somewhere.com", mailbox.getAddress());
    }

    public void testParseAddressQuotedLocalPart() throws Exception {
        String s = "<  \"some  one\"   @ some host . some where . com >";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
        assertEquals("some  one@somehost.somewhere.com", mailbox.getAddress());
    }
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.