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 public class RemoteAddrNotInNetworkTest extends AbstractRemoteAddrInNetworkTest { 29 30 private final String ALLOWED_NETWORK = "192.168.200.0/24"; 31 32 public RemoteAddrNotInNetworkTest(String arg0) 33 throws UnsupportedEncodingException { 34 super(arg0); 35 } 36 37 public void testRemoteAddrNotInNetworkMatched() throws MessagingException { 39 setRemoteAddr("192.168.0.1"); 40 41 setupAll(); 42 43 Collection matchedRecipients = matcher.match(mockedMail); 44 45 assertNotNull(matchedRecipients); 46 assertEquals(matchedRecipients.size(), mockedMail.getRecipients() 47 .size()); 48 } 49 50 public void testRemoteAddrNotInNetworkNotMatch() throws MessagingException { 52 setRemoteAddr("192.168.200.1"); 53 54 setupAll(); 55 56 Collection matchedRecipients = matcher.match(mockedMail); 57 58 assertNull(matchedRecipients); 59 } 60 61 protected AbstractNetworkMatcher createMatcher() { 62 return new RemoteAddrNotInNetwork(); 63 } 64 65 protected String getConfigOption() { 66 return "AllowedNetworkIs="; 67 } 68 69 protected String getAllowedNetworks() { 70 return ALLOWED_NETWORK; 71 } 72 } 73 | Popular Tags |