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 import org.apache.mailet.MailAddress;
29 import org.apache.mailet.Matcher;
30
31 public class SenderIsTest extends AbstractSenderIsTest {
32
33 private final String SENDER_NAME = "test@james.apache.org";
34
35 public SenderIsTest(String arg0) throws UnsupportedEncodingException {
36 super(arg0);
37 }
38
39
40 public void testSenderIsMatchedAllRecipients() throws MessagingException {
41 setSender(new MailAddress(SENDER_NAME));
42
43 setupMockedMail();
44 setupMatcher();
45
46 Collection matchedRecipients = matcher.match(mockedMail);
47
48 assertNotNull(matchedRecipients);
49 assertEquals(matchedRecipients.size(), mockedMail.getRecipients()
50 .size());
51 }
52
53
54 public void testSenderIsNotMatchedAllRecipients() throws MessagingException {
55 setSender(new MailAddress("t@james.apache.org"));
56
57 setupMockedMail();
58 setupMatcher();
59
60 Collection matchedRecipients = matcher.match(mockedMail);
61
62 assertNull(matchedRecipients);
63 }
64
65 protected Matcher createMatcher() {
66 return new SenderIs();
67 }
68
69 protected String getConfigOption() {
70 return "SenderIs=";
71 }
72
73 protected String getConfigValue() {
74 return SENDER_NAME;
75 }
76 }