james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject svn commit: r1711968 - in /james/project/trunk/server/data: data-file/src/test/java/org/apache/james/rrt/file/ data-hbase/src/test/java/org/apache/james/rrt/hbase/ data-jdbc/src/test/java/org/apache/james/rrt/jdbc/ data-jpa/src/test/java/org/apache/jam...
Date Mon, 02 Nov 2015 13:41:32 GMT
Author: matthieu
Date: Mon Nov  2 13:41:32 2015
New Revision: 1711968

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

Modified:
    james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/RewriteTablesTest.java
    james/project/trunk/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/RewriteTablesTest.java
    james/project/trunk/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/RewriteTablesTest.java
    james/project/trunk/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/RewriteTablesTest.java
    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-file/src/test/java/org/apache/james/rrt/file/RewriteTablesTest.java
URL: http://svn.apache.org/viewvc/james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/RewriteTablesTest.java?rev=1711968&r1=1711967&r2=1711968&view=diff
==============================================================================
--- james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/RewriteTablesTest.java
(original)
+++ james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/RewriteTablesTest.java
Mon Nov  2 13:41:32 2015
@@ -28,7 +28,8 @@ import cucumber.api.junit.Cucumber;
 @RunWith(Cucumber.class)
 @CucumberOptions(
         features = { "classpath:cucumber/" },
-        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.file" }
+        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.file" },
+        tags = { "~@ignore" }
     )
 public class RewriteTablesTest {
 }

Modified: james/project/trunk/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/RewriteTablesTest.java
URL: http://svn.apache.org/viewvc/james/project/trunk/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/RewriteTablesTest.java?rev=1711968&r1=1711967&r2=1711968&view=diff
==============================================================================
--- james/project/trunk/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/RewriteTablesTest.java
(original)
+++ james/project/trunk/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/RewriteTablesTest.java
Mon Nov  2 13:41:32 2015
@@ -28,7 +28,8 @@ import cucumber.api.junit.Cucumber;
 @RunWith(Cucumber.class)
 @CucumberOptions(
         features = { "classpath:cucumber/" },
-        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.hbase" }
+        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.hbase" },
+        tags = { "~@ignore" }
     )
 public class RewriteTablesTest {
 }

Modified: james/project/trunk/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/RewriteTablesTest.java
URL: http://svn.apache.org/viewvc/james/project/trunk/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/RewriteTablesTest.java?rev=1711968&r1=1711967&r2=1711968&view=diff
==============================================================================
--- james/project/trunk/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/RewriteTablesTest.java
(original)
+++ james/project/trunk/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/RewriteTablesTest.java
Mon Nov  2 13:41:32 2015
@@ -26,7 +26,8 @@ import cucumber.api.junit.Cucumber;
 @RunWith(Cucumber.class)
 @CucumberOptions(
         features = { "classpath:cucumber/" },
-        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.jdbc" }
+        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.jdbc" },
+        tags = { "~@ignore" }
     )
 public class RewriteTablesTest {
 }

Modified: james/project/trunk/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/RewriteTablesTest.java
URL: http://svn.apache.org/viewvc/james/project/trunk/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/RewriteTablesTest.java?rev=1711968&r1=1711967&r2=1711968&view=diff
==============================================================================
--- james/project/trunk/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/RewriteTablesTest.java
(original)
+++ james/project/trunk/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/RewriteTablesTest.java
Mon Nov  2 13:41:32 2015
@@ -26,7 +26,8 @@ import cucumber.api.junit.Cucumber;
 @RunWith(Cucumber.class)
 @CucumberOptions(
         features = { "classpath:cucumber/" },
-        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.jpa" }
+        glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.jpa" },
+        tags = { "~@ignore" }
     )
 public class RewriteTablesTest {
 }

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=1711968&r1=1711967&r2=1711968&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:41:32 2015
@@ -19,10 +19,11 @@
 package org.apache.james.rrt.lib;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
 
 import java.util.List;
 
-import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 
 import cucumber.api.java.en.Given;
@@ -53,6 +54,11 @@ public class RewriteTablesStepdefs {
         rewriteTable.addAddressMapping(user, domain, address);
     }
 
+    @Given("store \"([^\"]*)\" error mapping for user \"([^\"]*)\" at domain \"([^\"]*)\"")
+    public void storeErrorMappingForUserAtDomain(String error, String user, String domain)
throws Throwable {
+        rewriteTable.addErrorMapping(user, domain, error);
+    }
+
     @When("user \"([^\"]*)\" at domain \"([^\"]*)\" removes a regexp mapping \"([^\"]*)\"")
     public void userAtDomainRemovesRegexpMapping(String user, String domain, String regexp)
throws Throwable {
         rewriteTable.removeRegexMapping(user, domain, regexp);
@@ -63,6 +69,11 @@ public class RewriteTablesStepdefs {
         rewriteTable.removeAddressMapping(user, domain, address);
     }
 
+    @When("user \"([^\"]*)\" at domain \"([^\"]*)\" removes a error mapping \"([^\"]*)\"")
+    public void userAtDomainRemovesErrorMapping(String user, String domain, String error)
throws Throwable {
+        rewriteTable.removeErrorMapping(user, domain, error);
+    }
+
     @Then("mappings should be empty")
     public void assertMappingsIsEmpty() throws Throwable {
         assertThat(rewriteTable.getAllMappings()).isNullOrEmpty();
@@ -82,4 +93,14 @@ public class RewriteTablesStepdefs {
     public void assertException(String exceptionClass) throws Throwable {
         assertThat(exception.getClass().getSimpleName()).isEqualTo(exceptionClass);
     }
+
+    @Then("retrieving mappings for user \"([^\"]*)\" at domain \"([^\"]*)\" should raise
a \"([^\"]*)\" exception with message \"([^\"]*)\"")
+    public void retrievingMappingsForUserAtDomainShouldRaiseAnException(String user, String
domain, String exception, String message) throws Exception {
+        try {
+            rewriteTable.getMappings(user, domain);
+            fail(String.format("Expecting an exception '%s' with message '%s' to be thrown",
exception, message));
+        } catch (ErrorMappingException e) {
+            assertThat(e).hasMessage(message);
+        }
+    }
 }

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=1711968&r1=1711967&r2=1711968&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:41:32 2015
@@ -49,4 +49,41 @@ Feature: Rewrite Tables tests
     Given store "test@localhost2" address mapping for user "test" at domain "localhost"
     And store "test@james" address mapping for user "test" at domain "localhost"
     When user "test" at domain "localhost" removes a address mapping "test@james"
-    Then mappings for user "test" at domain "localhost" should contains only "test@localhost2"
\ No newline at end of file
+    Then mappings for user "test" at domain "localhost" should contains only "test@localhost2"
+
+# Error mapping
+
+  Scenario: stored error mapping should be retrieved when one mapping matching
+    Given store "bounce!" error mapping for user "test" at domain "localhost"
+    Then retrieving mappings for user "test" at domain "localhost" should raise a "ErrorMappingException"
exception with message "bounce!"
+
+# Bad messsage: "bounce!;test@localhost2" instead of "bounce!"
+  @ignore
+  Scenario: stored error mapping should be retrieved when two mappings matching
+    Given store "bounce!" error mapping for user "test" at domain "localhost"
+    And store "error" error mapping for user "test" at domain "localhost"
+    Then retrieving mappings for user "test" at domain "localhost" should raise a "ErrorMappingException"
exception with message "bounce!"
+
+  Scenario: stored error mapping should not be retrieved by another user
+    Given store "bounce!" error mapping for user "test" at domain "localhost"
+    And store "error" error mapping for user "test" at domain "localhost"
+    Then mappings for user "test2" at domain "localhost" should be empty
+
+  Scenario: removing a stored error mapping should work
+    Given store "bounce!" error mapping for user "test" at domain "localhost"
+    When user "test" at domain "localhost" removes a error mapping "bounce!"
+    Then mappings for user "test" at domain "localhost" should be empty
+
+# Should fail, but not currently
+  @ignore
+  Scenario: an exception should be thrown when an error mapping is not the first stored
+    Given store "test@localhost2" address mapping for user "test" at domain "localhost"
+    And store "bounce!" error mapping for user "test" at domain "localhost"
+    Then retrieving mappings for user "test" at domain "localhost" should raise a "ErrorMappingException"
exception with message "bounce!"
+
+# Bad messsage: "bounce!;test@localhost2" instead of "bounce!"
+  @ignore
+  Scenario: an exception should be thrown when an error mapping is the first stored
+    Given store "bounce!" error mapping for user "test" at domain "localhost"
+    And store "test@localhost2" address mapping for user "test" at domain "localhost"
+    Then retrieving mappings for user "test" at domain "localhost" should raise a "ErrorMappingException"
exception with message "bounce!"



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