james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [05/24] james-project git commit: JAMES-2366 Factorize a bit more code for RRTs tests
Date Tue, 03 Apr 2018 10:02:51 GMT
JAMES-2366 Factorize a bit more code for RRTs tests


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

Branch: refs/heads/master
Commit: 36983a1a06d2f850416bcacad926baa0bff75182
Parents: 3213280
Author: benwa <btellier@linagora.com>
Authored: Wed Mar 28 10:21:26 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Apr 3 16:58:33 2018 +0700

----------------------------------------------------------------------
 .../CassandraRecipientRewriteTableTest.java     | 43 --------------------
 .../hbase/HBaseRecipientRewriteTableTest.java   | 43 --------------------
 .../rrt/jdbc/JDBCRecipientRewriteTableTest.java | 43 --------------------
 .../rrt/jpa/JPARecipientRewriteTableTest.java   | 43 --------------------
 .../lib/AbstractRecipientRewriteTableTest.java  | 42 +++++++++++++++++--
 .../memory/MemoryRecipientRewriteTableTest.java | 43 --------------------
 6 files changed, 38 insertions(+), 219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/36983a1a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
index b57aceb..b53e60d 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
@@ -22,11 +22,8 @@ import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
-import org.apache.james.core.Domain;
-import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
-import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -59,44 +56,4 @@ public class CassandraRecipientRewriteTableTest extends AbstractRecipientRewrite
         return rrt;
     }
 
-    @Override
-    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.addErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.addRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.addAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
-
-    @Override
-    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.removeErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.removeRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.removeAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/36983a1a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
index 9e9ce74..c41f666 100644
--- a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
+++ b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
@@ -19,12 +19,9 @@
 package org.apache.james.rrt.hbase;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
-import org.apache.james.core.Domain;
 import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
-import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
-import org.apache.james.rrt.lib.Mapping.Type;
 import org.apache.james.system.hbase.TablePool;
 import org.junit.After;
 import org.junit.Before;
@@ -57,44 +54,4 @@ public class HBaseRecipientRewriteTableTest extends AbstractRecipientRewriteTabl
         rrt.configure(new DefaultConfigurationBuilder());
         return rrt;
     }
-
-    @Override
-    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.addErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.addRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.addAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
-
-    @Override
-    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.removeErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.removeRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.removeAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/36983a1a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
b/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
index 4ad97d4..3180e20 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
@@ -21,12 +21,9 @@ package org.apache.james.rrt.jdbc;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.dbcp.BasicDataSource;
 import org.apache.derby.jdbc.EmbeddedDriver;
-import org.apache.james.core.Domain;
 import org.apache.james.filesystem.api.mock.MockFileSystem;
-import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
-import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 
@@ -69,44 +66,4 @@ public class JDBCRecipientRewriteTableTest extends AbstractRecipientRewriteTable
         ds.setPassword("james");
         return ds;
     }
-
-    @Override
-    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.addErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.addRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.addAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
-
-    @Override
-    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.removeErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.removeRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.removeAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/36983a1a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
b/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
index b88712e..8fab241 100644
--- a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
+++ b/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
@@ -20,12 +20,9 @@ package org.apache.james.rrt.jpa;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.backends.jpa.JpaTestCluster;
-import org.apache.james.core.Domain;
-import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.jpa.model.JPARecipientRewrite;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
-import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 
@@ -56,44 +53,4 @@ public class JPARecipientRewriteTableTest extends AbstractRecipientRewriteTableT
         localVirtualUserTable.configure(defaultConfiguration);
         return localVirtualUserTable;
     }
-
-    @Override
-    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.addErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.addRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.addAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
-
-    @Override
-    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.removeErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.removeRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.removeAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/36983a1a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
index 6877e2e..3dad6a0 100644
--- a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
@@ -293,11 +293,45 @@ public abstract class AbstractRecipientRewriteTableTest {
 
     protected abstract AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception;
 
-    protected abstract void addMapping(String user, Domain domain, String mapping, Mapping.Type
type) throws
-            RecipientRewriteTableException;
 
-    protected abstract void removeMapping(String user, Domain domain, String mapping, Mapping.Type
type) throws
-            RecipientRewriteTableException;
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
+        switch (type) {
+            case Error:
+                virtualUserTable.addErrorMapping(user, domain, mapping);
+                break;
+            case Regex:
+                virtualUserTable.addRegexMapping(user, domain, mapping);
+                break;
+            case Address:
+                virtualUserTable.addAddressMapping(user, domain, mapping);
+                break;
+            case Domain:
+                virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
+                break;
+            default:
+                throw new RuntimeException("Invalid mapping type: " + type.asPrefix());
+        }
+    }
+
+
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
+        switch (type) {
+            case Error:
+                virtualUserTable.removeErrorMapping(user, domain, mapping);
+                break;
+            case Regex:
+                virtualUserTable.removeRegexMapping(user, domain, mapping);
+                break;
+            case Address:
+                virtualUserTable.removeAddressMapping(user, domain, mapping);
+                break;
+            case Domain:
+                virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
+                break;
+            default:
+                throw new RuntimeException("Invalid mapping type: " + type.asPrefix());
+        }
+    }
 
     private void removeMapping(String user, Domain domain, String rawMapping) throws RecipientRewriteTableException
{
         Type type = Mapping.detectType(rawMapping);

http://git-wip-us.apache.org/repos/asf/james-project/blob/36983a1a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
index 9de107b..0d32f1d 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
@@ -20,11 +20,8 @@
 package org.apache.james.rrt.memory;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
-import org.apache.james.core.Domain;
-import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
-import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 
@@ -48,44 +45,4 @@ public class MemoryRecipientRewriteTableTest extends AbstractRecipientRewriteTab
         rrt.configure(new DefaultConfigurationBuilder());
         return rrt;
     }
-
-    @Override
-    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.addErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.addRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.addAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
-
-    @Override
-    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
RecipientRewriteTableException {
-        switch (type) {
-        case Error:
-            virtualUserTable.removeErrorMapping(user, domain, mapping);
-            break;
-        case Regex:
-            virtualUserTable.removeRegexMapping(user, domain, mapping);
-            break;
-        case Address:
-            virtualUserTable.removeAddressMapping(user, domain, mapping);
-            break;
-        case Domain:
-            virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
-            break;
-        default:
-            throw new RuntimeException("Invalid mapping type: " + type);
-        }
-    }
 }


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