james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [11/11] james-project git commit: MAILET-122 Handle TAB in MailAddressCollectionReader
Date Fri, 02 Sep 2016 06:23:36 GMT
MAILET-122 Handle TAB in MailAddressCollectionReader


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

Branch: refs/heads/master
Commit: 4a255018269ce7303c51fbcf13b1f4d091b8a69a
Parents: 6866fad
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Sep 1 11:20:59 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Sep 2 13:22:37 2016 +0700

----------------------------------------------------------------------
 .../utils/MailAddressCollectionReader.java       |  2 +-
 .../util/MailAddressCollectionReaderTest.java    | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/4a255018/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
b/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
index 0c936ed..17ee09e 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
@@ -38,7 +38,7 @@ public class MailAddressCollectionReader {
 
     public static Set<MailAddress> read(String condition) {
         Preconditions.checkArgument(!Strings.isNullOrEmpty(condition));
-        return FluentIterable.from(Splitter.on(", ").split(condition)).transform(new Function<String,
MailAddress>() {
+        return FluentIterable.from(Splitter.onPattern(",( |\t)").split(condition)).transform(new
Function<String, MailAddress>() {
             @Override
             public MailAddress apply(String s) {
                 try {

http://git-wip-us.apache.org/repos/asf/james-project/blob/4a255018/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
index 116a031..46cc41e 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
@@ -74,6 +74,25 @@ public class MailAddressCollectionReaderTest {
     }
 
     @Test
+    public void readShouldParseTwoEmailTabSeparated() throws Exception {
+        MailAddress mailAddress1 = new MailAddress("valid@apache.org");
+        MailAddress mailAddress2 = new MailAddress("bis@apache.org");
+
+        assertThat(MailAddressCollectionReader.read(mailAddress1.toString() + ",\t" + mailAddress2.toString()))
+            .containsExactly(mailAddress1, mailAddress2);
+    }
+
+
+    @Test
+    public void readShouldParseTwoEmailTabAndSpaceCombinaison() throws Exception {
+        MailAddress mailAddress1 = new MailAddress("valid@apache.org");
+        MailAddress mailAddress2 = new MailAddress("bis@apache.org");
+
+        assertThat(MailAddressCollectionReader.read(mailAddress1.toString() + ",\t  \t\t
\t " + mailAddress2.toString()))
+            .containsExactly(mailAddress1, mailAddress2);
+    }
+
+    @Test
     public void readShouldRemoveDuplicates() throws Exception {
         MailAddress mailAddress = new MailAddress("valid@apache.org");
 


---------------------------------------------------------------------
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