This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 57d472b72282eaf087d3a4b1492243c008ea6204
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Thu Mar 5 11:52:26 2020 +0700

    JAMES-3088 Migrate CassandraUsersRepositoryTest
---
 .../cassandra/CassandraUsersRepositoryTest.java    | 48 +++++++++++++++++-----
 .../user/lib/AbstractUsersRepositoryTest.java      |  4 ++
 2 files changed, 41 insertions(+), 11 deletions(-)

diff --git 
a/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
 
b/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
index 8781f71..c039679 100644
--- 
a/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
+++ 
b/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
@@ -21,32 +21,58 @@ package org.apache.james.user.cassandra;
 
 import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
 import org.apache.james.backends.cassandra.CassandraClusterExtension;
+import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.user.lib.AbstractUsersRepository;
 import org.apache.james.user.lib.AbstractUsersRepositoryTest;
-import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-class CassandraUsersRepositoryTest extends AbstractUsersRepositoryTest {
+class CassandraUsersRepositoryTest {
 
     @RegisterExtension
     static CassandraClusterExtension cassandraCluster = new 
CassandraClusterExtension(CassandraUsersRepositoryModule.MODULE);
 
-    @BeforeEach
-    void setup() throws Exception {
-        super.setUp();
+    @Nested
+    class WhenEnableVirtualHosting implements 
AbstractUsersRepositoryTest.WithVirtualHostingContract {
+        @RegisterExtension
+        UserRepositoryExtension extension = 
UserRepositoryExtension.withVirtualHost();
+
+        private CassandraUsersRepository usersRepository;
+
+        @BeforeEach
+        void setUp(TestSystem testSystem) throws Exception {
+            usersRepository = getUsersRepository(testSystem.getDomainList(), 
extension.isSupportVirtualHosting());
+        }
+
+        @Override
+        public AbstractUsersRepository testee() {
+            return usersRepository;
+        }
     }
 
-    @AfterEach
-    void teardown() throws Exception {
-        super.tearDown();
+    @Nested
+    class WhenDisableVirtualHosting implements 
AbstractUsersRepositoryTest.WithOutVirtualHostingContract {
+        @RegisterExtension
+        UserRepositoryExtension extension = 
UserRepositoryExtension.withoutVirtualHosting();
+
+        private CassandraUsersRepository usersRepository;
+
+        @BeforeEach
+        void setUp(TestSystem testSystem) throws Exception {
+            usersRepository = getUsersRepository(testSystem.getDomainList(), 
extension.isSupportVirtualHosting());
+        }
+
+        @Override
+        public AbstractUsersRepository testee() {
+            return usersRepository;
+        }
     }
 
-    @Override
-    protected AbstractUsersRepository getUsersRepository() throws Exception {
+    private static CassandraUsersRepository getUsersRepository(DomainList 
domainList, boolean enableVirtualHosting) throws Exception {
         CassandraUsersRepository cassandraUsersRepository = new 
CassandraUsersRepository(domainList, 
cassandraCluster.getCassandraCluster().getConf());
         BaseHierarchicalConfiguration configuration = new 
BaseHierarchicalConfiguration();
-        configuration.addProperty("enableVirtualHosting", "true");
+        configuration.addProperty("enableVirtualHosting", 
String.valueOf(enableVirtualHosting));
         cassandraUsersRepository.configure(configuration);
         return cassandraUsersRepository;
     }
diff --git 
a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
 
b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
index d959987..93a20a8 100644
--- 
a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
+++ 
b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
@@ -81,6 +81,10 @@ public interface AbstractUsersRepositoryTest {
         public Object resolveParameter(ParameterContext parameterContext, 
ExtensionContext extensionContext) throws ParameterResolutionException {
             return testSystem;
         }
+
+        public boolean isSupportVirtualHosting() {
+            return supportVirtualHosting;
+        }
     }
 
     class TestSystem {


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