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 <matth...@apache.org> Authored: Fri Apr 20 15:13:27 2018 +0200 Committer: Matthieu Baechler <matth...@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("ad...@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("ad...@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("ad...@abc.abc"); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org