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

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


    }

    public void testParseAddress() throws Exception {
        Address address = parser.parseAddress("Mary Smith <mary@example.net>");
        assertTrue(address instanceof Mailbox);
        Mailbox mbox = (Mailbox) address;
        assertEquals("Mary Smith", mbox.getName());
        assertEquals("mary@example.net", mbox.getAddress());

        address = parser.parseAddress("group: Mary Smith <mary@example.net>;");
        assertTrue(address instanceof Group);
        Group group = (Group) address;
        assertEquals("group", group.getName());
        MailboxList mailboxes = group.getMailboxes();
        assertEquals(1, mailboxes.size());
        mbox = mailboxes.get(0);
        assertEquals("Mary Smith", mbox.getName());
        assertEquals("mary@example.net", mbox.getAddress());
    }
View Full Code Here


    }

    public void testParseAddressList() throws Exception {
        AddressList addrList1 = parser.parseAddressList("John Doe <jdoe@machine(comment).  example>");
        assertEquals(1, addrList1.size());
        Mailbox mailbox1 = (Mailbox)addrList1.get(0);
        assertEquals("John Doe", mailbox1.getName());
        assertEquals("jdoe", mailbox1.getLocalPart());
        assertEquals("machine.example", mailbox1.getDomain());

        AddressList addrList2 = parser.parseAddressList("Mary Smith \t    \t\t  <mary@example.net>");
        assertEquals(1, addrList2.size());
        Mailbox mailbox2 = (Mailbox)addrList2.get(0);
        assertEquals("Mary Smith", mailbox2.getName());
        assertEquals("mary", mailbox2.getLocalPart());
        assertEquals("example.net", mailbox2.getDomain());
    }
View Full Code Here

        Group group = (Group)addrList.get(0);
        assertEquals("Marketing folks", group.getName());
        assertEquals(2, group.getMailboxes().size());

        Mailbox mailbox1 = group.getMailboxes().get(0);
        Mailbox mailbox2 = group.getMailboxes().get(1);

        assertEquals("Jane Smith", mailbox1.getName());
        assertEquals("jane", mailbox1.getLocalPart());
        assertEquals("example.net", mailbox1.getDomain());

        assertEquals(" Jack \"Jackie\" Jones ", mailbox2.getName());
        assertEquals("jjones", mailbox2.getLocalPart());
        assertEquals("example.com", mailbox2.getDomain());

        Mailbox mailbox = (Mailbox)addrList.get(1);
        assertEquals("john", mailbox.getLocalPart());
        assertEquals("example.net", mailbox.getDomain());
        assertEquals(2, mailbox.getRoute().size());
        assertEquals("example.net", mailbox.getRoute().get(0));
        assertEquals("example.com", mailbox.getRoute().get(1));
    }
View Full Code Here

    }

    public void testSimpleForm() throws Exception {
        AddressList addrList = parser.parseAddressList("\"a b c d e f g\" (comment) @example.net");
        assertEquals(1, addrList.size());
        Mailbox mailbox = (Mailbox)addrList.get(0);
        assertEquals("a b c d e f g", mailbox.getLocalPart());
        assertEquals("example.net", mailbox.getDomain());
    }
View Full Code Here

        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("group", group.getName());

        MailboxList mailboxes = group.getMailboxes();
        assertEquals(2, mailboxes.size());

        Mailbox mailbox1 = mailboxes.get(0);
        assertNull(mailbox1.getName());
        assertEquals("john.doe@acme.org", mailbox1.getAddress());

        Mailbox mailbox2 = mailboxes.get(1);
        assertEquals("Mary Smith", mailbox2.getName());
        assertEquals("mary@example.net", mailbox2.getAddress());
    }
View Full Code Here

    }

    public void testParseAddress() throws Exception {
        Address address = parser.parseAddress("Mary Smith <mary@example.net>");
        assertTrue(address instanceof Mailbox);
        Mailbox mbox = (Mailbox) address;
        assertEquals("Mary Smith", mbox.getName());
        assertEquals("mary@example.net", mbox.getAddress());

        address = parser.parseAddress("group: Mary Smith <mary@example.net>;");
        assertTrue(address instanceof Group);
        Group group = (Group) address;
        assertEquals("group", group.getName());
        MailboxList mailboxes = group.getMailboxes();
        assertEquals(1, mailboxes.size());
        mbox = mailboxes.get(0);
        assertEquals("Mary Smith", mbox.getName());
        assertEquals("mary@example.net", mbox.getAddress());
    }
View Full Code Here

    }

    public void testParseAddressList() throws Exception {
        AddressList addrList1 = parser.parseAddressList("John Doe <jdoe@machine(comment).  example>");
        assertEquals(1, addrList1.size());
        Mailbox mailbox1 = (Mailbox)addrList1.get(0);
        assertEquals("John Doe", mailbox1.getName());
        assertEquals("jdoe", mailbox1.getLocalPart());
        assertEquals("machine.example", mailbox1.getDomain());

        AddressList addrList2 = parser.parseAddressList("Mary Smith \t    \t\t  <mary@example.net>");
        assertEquals(1, addrList2.size());
        Mailbox mailbox2 = (Mailbox)addrList2.get(0);
        assertEquals("Mary Smith", mailbox2.getName());
        assertEquals("mary", mailbox2.getLocalPart());
        assertEquals("example.net", mailbox2.getDomain());
    }
View Full Code Here

        Group group = (Group)addrList.get(0);
        assertEquals("Marketing folks", group.getName());
        assertEquals(2, group.getMailboxes().size());

        Mailbox mailbox1 = group.getMailboxes().get(0);
        Mailbox mailbox2 = group.getMailboxes().get(1);

        assertEquals("Jane Smith", mailbox1.getName());
        assertEquals("jane", mailbox1.getLocalPart());
        assertEquals("example.net", mailbox1.getDomain());

        assertEquals(" Jack \"Jackie\" Jones ", mailbox2.getName());
        assertEquals("jjones", mailbox2.getLocalPart());
        assertEquals("example.com", mailbox2.getDomain());

        Mailbox mailbox = (Mailbox)addrList.get(1);
        assertEquals("john", mailbox.getLocalPart());
        assertEquals("example.net", mailbox.getDomain());
        assertEquals(2, mailbox.getRoute().size());
        assertEquals("example.net", mailbox.getRoute().get(0));
        assertEquals("example.com", mailbox.getRoute().get(1));
    }
View Full Code Here

    }

    public void testSimpleForm() throws Exception {
        AddressList addrList = parser.parseAddressList("\"a b c d e f g\" (comment) @example.net");
        assertEquals(1, addrList.size());
        Mailbox mailbox = (Mailbox)addrList.get(0);
        assertEquals("a b c d e f g", mailbox.getLocalPart());
        assertEquals("example.net", mailbox.getDomain());
    }
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.