SieveAddressBuilder { public void addAddresses(String addressList) throws ParseException { final StringReader reader = new StringReader(addressList); worker.addAddressses(reader, addresses); } SieveAddressBuilder(); void reset(); void addAddresses(String addressList); Address[] getAddresses();  }
@Test public void testNotAddress() throws Exception { try { builder .addAddresses("What a load of rubbish - not an address in sight!"); Assert.fail("Parsing should fail when the input is not an address"); } catch (ParseException e) { } }
@Test public void testAddAddresses() throws Exception { Assert.assertNotNull(builder.getAddresses()); builder.addAddresses(COYOTE_ADDRESS); Address[] addresses = builder.getAddresses(); Assert.assertNotNull(addresses); Assert.assertEquals(1, addresses.length); Assert.assertEquals(COYOTE, addresses[0].getLocalPart()); Assert.assertEquals(DOMAIN, addresses[0].getDomain()); builder.addAddresses(HEROS); addresses = builder.getAddresses(); Assert.assertNotNull(addresses); Assert.assertEquals(3, addresses.length); Assert.assertEquals(COYOTE, addresses[0].getLocalPart()); Assert.assertEquals(DOMAIN, addresses[0].getDomain()); Assert.assertEquals(ROADRUNNER, addresses[1].getLocalPart()); Assert.assertEquals(DOMAIN, addresses[1].getDomain()); Assert.assertEquals(BUGS, addresses[2].getLocalPart()); Assert.assertEquals(DOMAIN, addresses[2].getDomain()); }