Package org.apache.james.mime4j.util

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


        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

        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 testParseMailboxNullAddress() throws Exception {
        String s = "<>";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
        assertEquals("", mailbox.getAddress());
    }
View Full Code Here

        assertEquals("", mailbox.getAddress());
    }
   
    public void testParseMailboxEmptyAddress() throws Exception {
        String s = "<    >";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
        assertEquals("", mailbox.getAddress());
    }
View Full Code Here

        assertEquals("", 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

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

    public void testParseAddressTruncated() throws Exception {
        String s = "<  some  one  ";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

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

        assertEquals("some one", mailbox.getAddress());
    }

    public void testParseAddressTrailingComments() throws Exception {
        String s = "< someone@somehost.somewhere.com  > (garbage) ; ";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

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

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

    public void testParseAddressTrailingGarbage() throws Exception {
        String s = "< someone@somehost.somewhere.com  > garbage) ; ";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

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