You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2016/08/30 18:01:43 UTC
[08/10] james-project git commit: JAMES-1773 Propose missing tests
(handling units)
JAMES-1773 Propose missing tests (handling units)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7fadba1e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7fadba1e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7fadba1e
Branch: refs/heads/master
Commit: 7fadba1e6cbf1812babd3e3e942d59783aca8018
Parents: d77682f
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Aug 17 12:41:17 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Aug 31 00:59:27 2016 +0700
----------------------------------------------------------------------
.../transport/matchers/SizeGreaterThanTest.java | 37 +++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/7fadba1e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
index 3f4f805..22ac107 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.james.transport.matchers;
import static org.assertj.core.api.Assertions.assertThat;
@@ -73,6 +72,42 @@ public class SizeGreaterThanTest {
}
@Test
+ public void matchShouldNotMatchMailsWithSpecifiedSize() throws MessagingException {
+ fakeMail.setMessageSize(1024);
+ FakeMatcherConfig matcherConfiguration = new FakeMatcherConfig("SizeGreaterThan=1k", FakeMailContext.defaultContext());
+ matcher.init(matcherConfiguration);
+
+ assertThat(matcher.match(fakeMail)).isNull();
+ }
+
+ @Test
+ public void matchShouldMatchMailsWithSizeSuperiorToSpecifiedSize() throws MessagingException {
+ fakeMail.setMessageSize(1025);
+ FakeMatcherConfig matcherConfiguration = new FakeMatcherConfig("SizeGreaterThan=1k", FakeMailContext.defaultContext());
+ matcher.init(matcherConfiguration);
+
+ assertThat(matcher.match(fakeMail)).containsExactly(mailAddress);
+ }
+
+ @Test
+ public void matchShouldReturnNullWhenUnderLimitNoUnit() throws MessagingException {
+ fakeMail.setMessageSize(4);
+ FakeMatcherConfig matcherConfiguration = new FakeMatcherConfig("SizeGreaterThan=4", FakeMailContext.defaultContext());
+ matcher.init(matcherConfiguration);
+
+ assertThat(matcher.match(fakeMail)).isNull();
+ }
+
+ @Test
+ public void matchShouldMatchOverLimitWhenNoUnit() throws MessagingException {
+ fakeMail.setMessageSize(5);
+ FakeMatcherConfig matcherConfiguration = new FakeMatcherConfig("SizeGreaterThan=4", FakeMailContext.defaultContext());
+ matcher.init(matcherConfiguration);
+
+ assertThat(matcher.match(fakeMail)).containsExactly(mailAddress);
+ }
+
+ @Test
public void initShouldThrowOnInvalidUnits() throws Exception {
expectedException.expect(MessagingException.class);
FakeMatcherConfig matcherConfiguration = new FakeMatcherConfig("SizeGreaterThan=1mb", FakeMailContext.defaultContext());
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org