Author: matthieu
Date: Mon Nov  2 13:42:11 2015
New Revision: 1711971

URL: http://svn.apache.org/viewvc?rev=1711971&view=rev
Log:
JAMES-1594 add tests on recursive mappings

Modified:
    
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
    
james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature

Modified: 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java?rev=1711971&r1=1711970&r2=1711971&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
 Mon Nov  2 13:42:11 2015
@@ -70,6 +70,16 @@ public class RewriteTablesStepdefs {
         rewriteTable.addAliasDomainMapping(aliasDomain, domain);
     }
 
+    @Given("recursive mapping is disable")
+    public void disableRecursiveMapping() {
+        rewriteTable.setRecursiveMapping(false);
+    }
+
+    @Given("recursive mapping is enable")
+    public void enableRecursiveMapping() {
+        rewriteTable.setRecursiveMapping(true);
+    }
+
     @When("user \"([^\"]*)\" at domain \"([^\"]*)\" removes a regexp mapping 
\"([^\"]*)\"")
     public void userAtDomainRemovesRegexpMapping(String user, String domain, 
String regexp) throws Throwable {
         rewriteTable.removeRegexMapping(user, domain, regexp);

Modified: 
james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature?rev=1711971&r1=1711970&r2=1711971&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature
 (original)
+++ 
james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature
 Mon Nov  2 13:42:11 2015
@@ -174,4 +174,46 @@ Feature: Rewrite Tables tests
     Given store "wildcard@localhost" address mapping as wildcard for domain 
"localhost"
     And store "aliasdomain" alias domain mapping for domain "localhost"
     When alias domain mapping "aliasdomain" for "localhost" domain is removed
-    Then mappings for user "test" at domain "aliasdomain" should be empty
\ No newline at end of file
+    Then mappings for user "test" at domain "aliasdomain" should be empty
+
+# Recursive mapping
+
+  Scenario: direct mapping should be returned when recursive mapping is disable
+    Given recursive mapping is disable
+    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
+    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
+    Then mappings for user "user1" at domain "domain1" should contains only 
"user2@domain2"
+
+  Scenario: recursive mapping should work when two levels
+    Given recursive mapping is enable
+    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
+    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
+    Then mappings for user "user1" at domain "domain1" should contains only 
"user3@domain3"
+
+  Scenario: recursive mapping should work when three levels
+    Given recursive mapping is enable
+    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
+    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
+    And store "user4@domain4" address mapping for user "user3" at domain 
"domain3"
+    Then mappings for user "user1" at domain "domain1" should contains only 
"user4@domain4"
+
+  Scenario: recursive mapping should throw exception when a loop exists
+    Given recursive mapping is enable
+    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
+    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
+    And store "user1@domain1" address mapping for user "user3" at domain 
"domain3"
+    Then retrieving mappings for user "user1" at domain "domain1" should raise 
a "ErrorMappingException" exception with message "554 Too many mappings to 
process"
+
+  Scenario: recursive mapping should work when a level is removed
+    Given recursive mapping is enable
+    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
+    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
+    And store "user4@domain4" address mapping for user "user3" at domain 
"domain3"
+    When user "user2" at domain "domain2" removes a address mapping 
"user3@domain3"
+    Then mappings for user "user1" at domain "domain1" should contains only 
"user2@domain2"
+
+  Scenario: recursive mapping should work when three levels on alias domains
+    Given store "domain2" alias domain mapping for domain "domain1"
+    And store "domain3" alias domain mapping for domain "domain2"
+    And store "domain4" alias domain mapping for domain "domain3"
+    Then mappings for user "test" at domain "domain4" should contains only 
"test@domain1"
\ No newline at end of file



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

Reply via email to