Package org.apache.james.mime4j.util

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


        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

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

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

        assertEquals("somehost.com@somehost.com", route.get(0));
    }
   
    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, null);
        assertNull(route);
    }
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.