1 19 20 21 package org.apache.james.transport.matchers; 22 23 import java.io.UnsupportedEncodingException ; 24 import java.util.Collection ; 25 26 import javax.mail.MessagingException ; 27 28 import org.apache.mailet.MailAddress; 29 import org.apache.mailet.Matcher; 30 31 public class UserIsTest extends AbstractRecipientIsTest { 32 33 private final String USER = "test"; 34 35 public UserIsTest(String arg0) throws UnsupportedEncodingException { 36 super(arg0); 37 } 38 39 protected String getRecipientName() { 40 return USER; 41 } 42 43 public void testHostIsMatchedAllRecipients() throws MessagingException { 45 setRecipients(new MailAddress[] { new MailAddress( 46 "test@james.apache.org") }); 47 48 setupMockedMail(); 49 setupMatcher(); 50 51 Collection matchedRecipients = matcher.match(mockedMail); 52 53 assertNotNull(matchedRecipients); 54 assertEquals(matchedRecipients.size(), mockedMail.getRecipients() 55 .size()); 56 } 57 58 public void testHostIsMatchedOneRecipient() throws MessagingException { 60 setRecipients(new MailAddress[] { 61 new MailAddress("test@james.apache.org"), 62 new MailAddress("test2@james.apache.org") }); 63 64 setupAll(); 65 66 Collection matchedRecipients = matcher.match(mockedMail); 67 68 assertNotNull(matchedRecipients); 69 assertEquals(matchedRecipients.size(), 1); 70 } 71 72 public void testHostIsNotMatch() throws MessagingException { 74 setRecipients(new MailAddress[] { 75 new MailAddress("test2@james2.apache.org"), 76 new MailAddress("test2@james.apache.org") }); 77 78 setupMockedMail(); 79 setupMatcher(); 80 81 Collection matchedRecipients = matcher.match(mockedMail); 82 83 assertEquals(matchedRecipients.size(), 0); 84 } 85 86 protected Matcher createMatcher() { 87 return new UserIs(); 88 } 89 } 90 | Popular Tags |