james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [4/4] james-project git commit: JAMES-2441 Ensure DockerCassandraRule is used as a class rule
Date Wed, 04 Jul 2018 08:59:08 GMT
JAMES-2441 Ensure DockerCassandraRule is used as a class rule


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

Branch: refs/heads/master
Commit: 90294f66e39efd44ef77e64fb2cd790aedf58df1
Parents: fffdff9
Author: benwa <btellier@linagora.com>
Authored: Wed Jul 4 11:14:45 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Jul 4 15:58:29 2018 +0700

----------------------------------------------------------------------
 .../org/apache/james/CassandraNodeConfTest.java | 29 +++++++++++---------
 .../org/apache/james/CassandraWithTikaTest.java | 14 +++++-----
 .../java/org/apache/james/ESReporterTest.java   |  8 ++++--
 .../james/JamesCapabilitiesServerTest.java      |  8 ++++--
 .../JamesServerWithRetryConnectionTest.java     |  9 +++---
 5 files changed, 39 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/90294f66/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
index 1950bd8..6747acf 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraNodeConfTest.java
@@ -30,6 +30,7 @@ import org.apache.james.backends.cassandra.init.configuration.ClusterConfigurati
 import org.apache.james.util.Host;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.testcontainers.DockerClientFactory;
@@ -43,11 +44,11 @@ public class CassandraNodeConfTest {
         return DockerClientFactory.instance().dockerHostIpAddress();
     }
 
-    private final DockerCassandraRule dockerCassandraRule = new DockerCassandraRule();
+    @ClassRule
+    public static final DockerCassandraRule dockerCassandraRule = new DockerCassandraRule();
 
     @Rule
-    public CassandraJmapTestRule cassandraJmapTestRule = new CassandraJmapTestRule(dockerCassandraRule,
-            new EmbeddedElasticSearchRule());
+    public CassandraJmapTestRule cassandraJmapTestRule = CassandraJmapTestRule.defaultTestRule();
 
     private GuiceJamesServer jamesServer;
     private SocketChannel socketChannel;
@@ -67,7 +68,7 @@ public class CassandraNodeConfTest {
 
     @Test
     public void serverShouldStartServiceWhenNodeIsReachable() throws Exception {
-        jamesServer = cassandraJmapTestRule.jmapServer();
+        jamesServer = cassandraJmapTestRule.jmapServer(dockerCassandraRule.getModule());
 
         assertThatServerStartCorrectly();
     }
@@ -77,11 +78,12 @@ public class CassandraNodeConfTest {
         String unreachableNode = "10.2.3.42";
 
 
-        jamesServer = cassandraJmapTestRule.jmapServer(
-            (binder) -> binder.bind(ClusterConfiguration.class)
-                .toInstance(clusterWithHosts(
-                    Host.from(unreachableNode, 9042),
-                    dockerCassandraRule.getHost())));
+        jamesServer = cassandraJmapTestRule.jmapServer(dockerCassandraRule.getModule())
+            .overrideWith(
+                (binder) -> binder.bind(ClusterConfiguration.class)
+                    .toInstance(clusterWithHosts(
+                        Host.from(unreachableNode, 9042),
+                        dockerCassandraRule.getHost())));
 
         assertThatServerStartCorrectly();
     }
@@ -89,10 +91,11 @@ public class CassandraNodeConfTest {
 
     @Test
     public void configShouldWorkWithNonDefaultPort() throws Exception {
-        jamesServer = cassandraJmapTestRule.jmapServer(
-            (binder) -> binder.bind(ClusterConfiguration.class)
-                .toInstance(clusterWithHosts(
-                    Host.from(getDockerHostIp(), dockerCassandraRule.getMappedPort(CASSANDRA_PORT)))));
+        jamesServer = cassandraJmapTestRule.jmapServer(dockerCassandraRule.getModule())
+            .overrideWith(
+                (binder) -> binder.bind(ClusterConfiguration.class)
+                    .toInstance(clusterWithHosts(
+                        Host.from(getDockerHostIp(), dockerCassandraRule.getMappedPort(CASSANDRA_PORT)))));
 
         assertThatServerStartCorrectly();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/90294f66/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraWithTikaTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraWithTikaTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraWithTikaTest.java
index 54b5bbf..eef9a48 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraWithTikaTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraWithTikaTest.java
@@ -21,22 +21,22 @@ package org.apache.james;
 
 import java.io.IOException;
 
+import org.junit.ClassRule;
 import org.junit.Rule;
 
 public class CassandraWithTikaTest extends AbstractJmapJamesServerTest {
 
-    private final GuiceTikaRule guiceTikaRule = new GuiceTikaRule();
+    @ClassRule
+    public static final DockerCassandraRule cassandra = new DockerCassandraRule();
+    @ClassRule
+    public static final GuiceTikaRule guiceTikaRule = new GuiceTikaRule();
 
     @Rule
-    public CassandraJmapTestRule cassandraJmap = new CassandraJmapTestRule(
-        AggregateGuiceModuleTestRule.of(
-            new EmbeddedElasticSearchRule(),
-            new DockerCassandraRule(),
-            guiceTikaRule));
+    public CassandraJmapTestRule cassandraJmap = CassandraJmapTestRule.defaultTestRule();
 
     @Override
     protected GuiceJamesServer createJamesServer() throws IOException {
-        return cassandraJmap.jmapServer(binder -> guiceTikaRule.getModule());
+        return cassandraJmap.jmapServer(guiceTikaRule.getModule(), cassandra.getModule());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/90294f66/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
index b0f555e..1c9995f 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
@@ -41,6 +41,7 @@ import org.elasticsearch.client.Client;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -63,19 +64,22 @@ public class ESReporterTest {
     private static final String USERNAME = "user1@" + DOMAIN;
     private static final String PASSWORD = "secret";
 
+    @ClassRule
+    public static final DockerCassandraRule cassandra = new DockerCassandraRule();
+
     private EmbeddedElasticSearchRule embeddedElasticSearchRule = new EmbeddedElasticSearchRule();
 
     private Timer timer;
 
     @Rule
-    public CassandraJmapTestRule cassandraJmap = new CassandraJmapTestRule(embeddedElasticSearchRule,
new DockerCassandraRule());
+    public CassandraJmapTestRule cassandraJmap = new CassandraJmapTestRule(embeddedElasticSearchRule);
 
     private GuiceJamesServer server;
     private AccessToken accessToken;
 
     @Before
     public void setup() throws Exception {
-        server = cassandraJmap.jmapServer();
+        server = cassandraJmap.jmapServer(cassandra.getModule());
         server.start();
         server.getProbe(DataProbeImpl.class)
             .fluent()

http://git-wip-us.apache.org/repos/asf/james-project/blob/90294f66/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index 45cc1a8..2b39d71 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -36,6 +36,7 @@ import org.apache.james.modules.TestElasticSearchModule;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.server.core.configuration.Configuration;
 import org.junit.After;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -48,15 +49,16 @@ public class JamesCapabilitiesServerTest {
     private GuiceJamesServer server;
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder,
MailboxElasticSearchConstants.DEFAULT_MAILBOX_INDEX);
-    private DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
+    @ClassRule
+    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     
     @Rule
-    public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch).around(cassandraServer);
+    public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
 
     @After
     public void teardown() {
         server.stop();
-        
     }
     
     private GuiceJamesServer createCassandraJamesServer(final MailboxManager mailboxManager)
throws IOException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/90294f66/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
index 678dcc2..87397dd 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.testcontainers.shaded.com.google.common.base.Throwables;
@@ -40,12 +41,12 @@ public class JamesServerWithRetryConnectionTest {
     private static final int IMAP_PORT = 1143;
     private static final long WAITING_TIME = TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS);
 
-    private final DockerCassandraRule dockerCassandraRule = new DockerCassandraRule();
+    @ClassRule
+    public static DockerCassandraRule dockerCassandraRule = new DockerCassandraRule();
     private final DockerElasticSearchRule dockerElasticSearchRule = new DockerElasticSearchRule();
 
     @Rule
-    public CassandraJmapTestRule cassandraJmapTestRule = new CassandraJmapTestRule(dockerCassandraRule,
-            dockerElasticSearchRule);
+    public CassandraJmapTestRule cassandraJmapTestRule = new CassandraJmapTestRule(dockerElasticSearchRule);
 
     private GuiceJamesServer jamesServer;
     private SocketChannel socketChannel;
@@ -68,7 +69,7 @@ public class JamesServerWithRetryConnectionTest {
 
     @Test
     public void serverShouldStartAtDefault() throws Exception {
-        jamesServer = cassandraJmapTestRule.jmapServer();
+        jamesServer = cassandraJmapTestRule.jmapServer(dockerCassandraRule.getModule());
         assertThatServerStartCorrectly();
     }
 


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