james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [1/4] james-project git commit: MAILET-129 Increase coverage and remove unused method
Date Thu, 08 Sep 2016 14:32:11 GMT
Repository: james-project
Updated Branches:
  refs/heads/master f88464d77 -> e17d56791


MAILET-129 Increase coverage and remove unused method


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0a418789
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0a418789
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0a418789

Branch: refs/heads/master
Commit: 0a4187893d9243c88db0d01f92f532f55924f172
Parents: e1e037d
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Wed Sep 7 15:58:00 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Thu Sep 8 16:29:53 2016 +0200

----------------------------------------------------------------------
 .../matchers/AbstractNetworkMatcher.java        |  4 ----
 .../matchers/RemoteAddrInNetworkTest.java       | 20 ++++++++++++++++++++
 .../matchers/RemoteAddrNotInNetworkTest.java    | 20 ++++++++++++++++++++
 3 files changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0a418789/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
index 8c8b43f..3739a4f 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
@@ -85,10 +85,6 @@ public abstract class AbstractNetworkMatcher extends GenericMatcher {
         return networks;
     }
 
-    protected boolean matchNetwork(java.net.InetAddress addr) {
-        return authorizedNetworks != null && authorizedNetworks.matchInetNetwork(addr);
-    }
-
     protected boolean matchNetwork(String addr) {
         return authorizedNetworks != null && authorizedNetworks.matchInetNetwork(addr);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a418789/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
index 624eb0e..336fbe9 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
@@ -74,4 +74,24 @@ public class RemoteAddrInNetworkTest {
 
         assertThat(actual).isNull();
     }
+
+    @Test
+    public void matchShouldNotMatchWhenNoCondition() throws MessagingException {
+        FakeMatcherConfig matcherConfig = new FakeMatcherConfig("", FakeMailContext.defaultContext());
+        RemoteAddrInNetwork testee = new RemoteAddrInNetwork();
+        testee.init(matcherConfig);
+
+        Collection<MailAddress> actual = testee.match(fakeMail);
+
+        assertThat(actual).isNull();
+    }
+
+    @Test
+    public void matchShouldNotMatchWhenInvalidAddress() throws MessagingException {
+        fakeMail.setRemoteAddr("invalid");
+
+        Collection<MailAddress> actual = matcher.match(fakeMail);
+
+        assertThat(actual).isNull();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a418789/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
index 484566f..2605084 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
@@ -74,4 +74,24 @@ public class RemoteAddrNotInNetworkTest {
 
         assertThat(actual).isNull();
     }
+
+    @Test
+    public void matchShouldMatchWhenNoCondition() throws MessagingException {
+        FakeMatcherConfig matcherConfig = new FakeMatcherConfig("", FakeMailContext.defaultContext());
+        RemoteAddrNotInNetwork testee = new RemoteAddrNotInNetwork();
+        testee.init(matcherConfig);
+
+        Collection<MailAddress> actual = testee.match(fakeMail);
+
+        assertThat(actual).containsOnly(testRecipient);
+    }
+
+    @Test
+    public void matchShouldMatchWhenInvalidAddress() throws MessagingException {
+        fakeMail.setRemoteAddr("invalid");
+
+        Collection<MailAddress> actual = matcher.match(fakeMail);
+
+        assertThat(actual).containsOnly(testRecipient);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message