You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/11/08 03:11:59 UTC
[james-project] 12/36: JAMES-2904 CassandraExtension should have
only one constructor
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 1b547402d533fc91ea042bb4e3136c0259e8fa99
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Oct 4 10:03:32 2019 +0700
JAMES-2904 CassandraExtension should have only one constructor
---
.../src/test/java/org/apache/james/CassandraExtension.java | 7 +------
.../src/test/java/org/apache/james/FixingGhostMailboxTest.java | 10 ++++++----
.../org/apache/james/JamesServerWithRetryConnectionTest.java | 8 ++++----
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
index f7d1fc4..d2564f1 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
@@ -24,15 +24,10 @@ import org.junit.jupiter.api.extension.ExtensionContext;
import com.google.inject.Module;
public class CassandraExtension implements GuiceModuleTestExtension {
-
private final DockerCassandraRule cassandra;
public CassandraExtension() {
- this(new DockerCassandraRule());
- }
-
- public CassandraExtension(DockerCassandraRule cassandra) {
- this.cassandra = cassandra;
+ this.cassandra = new DockerCassandraRule();
}
@Override
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
index dd01a60..ffd8e4f 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
@@ -60,6 +60,7 @@ import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.modules.TestJMAPServerModule;
import org.apache.james.server.CassandraProbe;
import org.apache.james.task.TaskManager;
+import org.apache.james.util.Host;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.jmap.draft.JmapGuiceProbe;
import org.apache.james.utils.WebAdminGuiceProbe;
@@ -92,12 +93,12 @@ public class FixingGhostMailboxTest {
private static final String ALICE_SECRET = "aliceSecret";
private static final String BOB_SECRET = "bobSecret";
- public static final DockerCassandraRule cassandra = new DockerCassandraRule();
+ public static final CassandraExtension dockerCassandra = new CassandraExtension();
@RegisterExtension
static JamesServerExtension testExtension = new JamesServerBuilder()
.extension(new DockerElasticSearchExtension())
- .extension(new CassandraExtension(cassandra))
+ .extension(dockerCassandra)
.server(configuration -> GuiceJamesServer.forConfiguration(configuration)
.combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
.overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
@@ -138,10 +139,11 @@ public class FixingGhostMailboxTest {
.addUser(BOB, BOB_SECRET);
accessToken = authenticateJamesUser(baseUri(server), ALICE, ALICE_SECRET);
+ Host cassandraHost = dockerCassandra.getCassandra().getHost();
session = Cluster.builder()
.withoutJMXReporting()
- .addContactPoint(cassandra.getIp())
- .withPort(cassandra.getMappedPort(9042))
+ .addContactPoint(cassandraHost.getHostName())
+ .withPort(cassandraHost.getPort())
.build()
.connect(server.getProbe(CassandraProbe.class).getKeyspace());
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 4f6745b..8945a3c 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
@@ -46,13 +46,13 @@ class JamesServerWithRetryConnectionTest {
private static final int LIMIT_TO_10_MESSAGES = 10;
private static final long WAITING_TIME = TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS);
- private static final DockerCassandraRule cassandraRule = new DockerCassandraRule();
private static final DockerElasticSearchExtension dockerElasticSearch = new DockerElasticSearchExtension();
+ private static final CassandraExtension dockerCassandra = new CassandraExtension();
@RegisterExtension
static JamesServerExtension testExtension = new JamesServerBuilder()
.extension(dockerElasticSearch)
- .extension(new CassandraExtension(cassandraRule))
+ .extension(dockerCassandra)
.server(configuration -> GuiceJamesServer.forConfiguration(configuration)
.combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
.overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
@@ -83,9 +83,9 @@ class JamesServerWithRetryConnectionTest {
@Test
void serverShouldRetryToConnectToCassandraWhenStartService(GuiceJamesServer server) throws Exception {
- cassandraRule.pause();
+ dockerCassandra.getCassandra().pause();
- waitToStartContainer(WAITING_TIME, cassandraRule::unpause);
+ waitToStartContainer(WAITING_TIME, dockerCassandra.getCassandra()::unpause);
assertThatServerStartCorrectly(server);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org