JAMES-1979 Improve readability of SMTPAuthSuccessfulTest
With many thanks to:
Nguyen Thi Mai and Le Thi Huong Lai for their work on Quotas and In memory
subscriptions
Tran Thi & My Linh for their work on TooMuchLines
txc1996 & Van Thanh For improving readability of SMTPAuthIsSuccessfulTest
thienan090196 & Tran Thi & My Linh for their tests on RecipientIsLocalTest
>From Passerelle Numeriques VietNam
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/84fd7f03
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/84fd7f03
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/84fd7f03
Branch: refs/heads/master
Commit: 84fd7f03f25ffd53636afb76f3a57f071a3ac1ca
Parents: 4b11646
Author: Benoit Tellier <[email protected]>
Authored: Wed Dec 28 16:13:24 2016 +0700
Committer: benwa <[email protected]>
Committed: Wed Mar 29 08:00:16 2017 +0700
----------------------------------------------------------------------
.../matchers/SMTPAuthSuccessfulTest.java | 54 ++++++++++++++------
1 file changed, 39 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/84fd7f03/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
----------------------------------------------------------------------
diff --git
a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
index 5bd45eb..911d929 100644
---
a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
+++
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
@@ -17,29 +17,53 @@
* under the License. *
****************************************************************/
-
package org.apache.james.transport.matchers;
-import org.apache.mailet.base.GenericMatcher;
+import static org.assertj.core.api.Assertions.assertThat;
-public class SMTPAuthSuccessfulTest extends AbstractHasMailAttributeTest {
+import java.util.Collection;
- protected String getHasMailAttribute() {
- return "";
- }
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.FakeMailContext;
+import org.apache.mailet.base.test.FakeMatcherConfig;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SMTPAuthSuccessfulTest {
- protected GenericMatcher createMatcher() {
- return new SMTPAuthSuccessful();
+ private SMTPAuthSuccessful testee;
+
+ @Before
+ public void setUp() throws Exception {
+ testee = new SMTPAuthSuccessful();
+ testee.init(FakeMatcherConfig.builder().matcherName("matcherName")
+ .mailetContext(FakeMailContext.defaultContext())
+ .build());
}
- protected String getMatcherName() {
- return "SMTPAuthSuccessful";
+ @Test
+ public void matchShouldReturnRecipientsWhenAuthUserAttributeIsPresent()
throws Exception{
+ MailAddress recipient = new MailAddress("[email protected]");
+ FakeMail fakeMail = FakeMail.builder()
+ .recipient(recipient)
+ .attribute("org.apache.james.SMTPAuthUser", "cuong")
+ .build();
+
+ Collection<MailAddress> results = testee.match(fakeMail);
+
+ assertThat(results).containsOnly(recipient);
}
-
- protected void init() {
- super.init();
- String SMTP_AUTH_USER_ATTRIBUTE_NAME = "org.apache.james.SMTPAuthUser";
- setMailAttributeName(SMTP_AUTH_USER_ATTRIBUTE_NAME);
+
+ @Test
+ public void matchShouldNotReturnRecipientsWhenAuthUserAttributeIsAbsent()
throws Exception{
+ FakeMail fakeMail = FakeMail.builder()
+ .recipients(new MailAddress("[email protected]"))
+ .build();
+
+ Collection<MailAddress> results = testee.match(fakeMail);
+
+ assertThat(results).isNull();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]