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 ma...@apache.org on 2018/04/24 12:50:52 UTC

[23/27] james-project git commit: JAMES-2366 add some tests on regex mapping rewriting

JAMES-2366 add some tests on regex mapping rewriting


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

Branch: refs/heads/master
Commit: a7a8735e3169e925bf755c8b02d570b186359a04
Parents: ff8107e
Author: Matthieu Baechler <ma...@apache.org>
Authored: Fri Apr 20 15:13:27 2018 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Tue Apr 24 14:49:33 2018 +0200

----------------------------------------------------------------------
 .../org/apache/james/rrt/lib/RegexRewriterTest.java  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a7a8735e/server/data/data-api/src/test/java/org/apache/james/rrt/lib/RegexRewriterTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/test/java/org/apache/james/rrt/lib/RegexRewriterTest.java b/server/data/data-api/src/test/java/org/apache/james/rrt/lib/RegexRewriterTest.java
index f234dad..b8682a3 100644
--- a/server/data/data-api/src/test/java/org/apache/james/rrt/lib/RegexRewriterTest.java
+++ b/server/data/data-api/src/test/java/org/apache/james/rrt/lib/RegexRewriterTest.java
@@ -74,4 +74,19 @@ public class RegexRewriterTest {
         assertThat(new UserRewritter.RegexRewriter().regexMap(mailAddress, "prefix_(.*)_(.*)@test:admin@${1}.${2}"))
             .contains("admin@abc.def");
     }
+
+    @Test
+    public void regexMapShouldCorrectlyReplaceSeveralOutOfOrderMatchingGroups() throws Exception {
+        MailAddress mailAddress = new MailAddress("prefix_abc_def@test");
+        assertThat(new UserRewritter.RegexRewriter().regexMap(mailAddress, "prefix_(.*)_(.*)@test:admin@${2}.${1}"))
+            .contains("admin@def.abc");
+    }
+
+
+    @Test
+    public void regexMapShouldCorrectlyReplaceRepeatingMatchingGroups() throws Exception {
+        MailAddress mailAddress = new MailAddress("prefix_abc_def@test");
+        assertThat(new UserRewritter.RegexRewriter().regexMap(mailAddress, "prefix_(.*)_(.*)@test:admin@${1}.${1}"))
+            .contains("admin@abc.abc");
+    }
 }


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