protected void setUp() throws Exception {
parser = AddressBuilder.DEFAULT;
}
public void testParseMailbox() throws ParseException {
Mailbox mailbox1 = parser.parseMailbox("John Doe <jdoe@machine(comment). example>");
assertEquals("John Doe", mailbox1.getName());
assertEquals("jdoe", mailbox1.getLocalPart());
assertEquals("machine.example", mailbox1.getDomain());
Mailbox mailbox2 = parser.parseMailbox("Mary Smith \t \t\t <mary@example.net>");
assertEquals("Mary Smith", mailbox2.getName());
assertEquals("mary", mailbox2.getLocalPart());
assertEquals("example.net", mailbox2.getDomain());
Mailbox mailbox3 = parser.parseMailbox("john.doe@acme.org");
assertNull(mailbox3.getName());
assertEquals("john.doe@acme.org", mailbox3.getAddress());
Mailbox mailbox4 = parser.parseMailbox("Mary Smith <mary@example.net>");
assertEquals("Mary Smith", mailbox4.getName());
assertEquals("mary@example.net", mailbox4.getAddress());
// non-ascii should be allowed in quoted strings
Mailbox mailbox5 = parser.parseMailbox(
"\"Hans M\374ller\" <hans.mueller@acme.org>");
assertEquals("Hans M\374ller", mailbox5.getName());
assertEquals("hans.mueller@acme.org", mailbox5.getAddress());
}