Package org.apache.james.mime4j.dom.address

Examples of org.apache.james.mime4j.dom.address.Mailbox


        assertFalse(m1.equals(m4));
        assertFalse(m1.equals(null));
    }

    public void testMailboxHashCode() throws Exception {
        Mailbox m1 = new Mailbox("john.doe", "acme.org");
        Mailbox m2 = new Mailbox("john doe", "acme.org");
        Mailbox m3 = new Mailbox("john.doe", "Acme.Org");
        Mailbox m4 = new Mailbox("john.doe", null);
        assertTrue(m1.hashCode() == m1.hashCode());
        assertFalse(m1.hashCode() == m2.hashCode());
        assertTrue(m1.hashCode() == m3.hashCode());
        assertFalse(m1.hashCode() == m4.hashCode());
    }
View Full Code Here


    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

        formatter = AddressFormatter.DEFAULT;
    }

    public void testGroupSerialization() {
        List<Mailbox> al = new ArrayList<Mailbox>();
        al.add(new Mailbox("test", "example.com"));
        al.add(new Mailbox("Foo!", "foo", "example.com"));
        DomainList dl = new DomainList(new ArrayList<String>(
                Arrays.asList(new String[] {"foo.example.com"})), true);
        Mailbox mailbox = new Mailbox("Foo Bar", dl, "foo2", "example.com");
        assertSame(dl, mailbox.getRoute());
        al.add(mailbox);
        Group g = new Group("group", new MailboxList(al, false));
        String s = formatter.format(g, false);
        assertEquals("group: test@example.com, Foo! <foo@example.com>, Foo Bar <foo2@example.com>;", s);
    }
View Full Code Here

        String s = formatter.format(g, false);
        assertEquals("group: test@example.com, Foo! <foo@example.com>, Foo Bar <foo2@example.com>;", s);
    }

    public void testMailboxGetEncodedString() throws Exception {
        Mailbox m1 = new Mailbox("john.doe", "acme.org");
        assertEquals("john.doe@acme.org", formatter.encode(m1));
        Mailbox m2 = new Mailbox("john doe", "acme.org");
        assertEquals("\"john doe\"@acme.org", formatter.encode(m2));
        Mailbox m3 = new Mailbox("John Doe", "john.doe", "acme.org");
        assertEquals("John Doe <john.doe@acme.org>", formatter.encode(m3));
        Mailbox m4 = new Mailbox("John Doe @Home", "john.doe", "acme.org");
        assertEquals("\"John Doe @Home\" <john.doe@acme.org>", formatter.encode(m4));
        Mailbox m5 = new Mailbox("Hans M\374ller", "hans.mueller", "acme.org");
        assertEquals("=?ISO-8859-1?Q?Hans_M=FCller?= <hans.mueller@acme.org>", formatter.encode(m5));
    }
View Full Code Here

        assertEquals("=?ISO-8859-1?Q?Hans_M=FCller?= <hans.mueller@acme.org>", formatter.encode(m5));
    }

    public void testGroupGetEncodedString() throws Exception {
        List<Mailbox> al = new ArrayList<Mailbox>();
        al.add(new Mailbox("test", "example.com"));
        al.add(new Mailbox("Foo!", "foo", "example.com"));
        al.add(new Mailbox("Hans M\374ller", "hans.mueller", "acme.org"));
        Group g = new Group("group @work", new MailboxList(al, false));
        assertEquals("\"group @work\": test@example.com, "
                + "Foo! <foo@example.com>, =?ISO-8859-1?Q?Hans_M=FCller?="
                + " <hans.mueller@acme.org>;", formatter.encode(g));
    }
View Full Code Here

    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

    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

    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

    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

    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

TOP

Related Classes of org.apache.james.mime4j.dom.address.Mailbox

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.