1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 RemoteAddrInNetworkTest extends AbstractRemoteAddrInNetworkTest {
29
30 private final String ALLOWED_NETWORK = "192.168.200.0/24";
31
32 public RemoteAddrInNetworkTest(String arg0)
33 throws UnsupportedEncodingException {
34 super(arg0);
35 }
36
37
38 public void testRemoteAddrInNetworkMatched() throws MessagingException {
39 setRemoteAddr("192.168.200.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
51 public void testRemoteAddrInNetworkNotMatch() throws MessagingException {
52 setRemoteAddr("192.168.1.1");
53
54 setupAll();
55
56 Collection matchedRecipients = matcher.match(mockedMail);
57
58 assertNull(matchedRecipients);
59 }
60
61 protected AbstractNetworkMatcher createMatcher() {
62 return new RemoteAddrInNetwork();
63 }
64
65 protected String getConfigOption() {
66 return "AllowedNetworkIs=";
67 }
68
69 protected String getAllowedNetworks() {
70 return ALLOWED_NETWORK;
71 }
72 }