From 309accbf10a97cc0d138a3db5ece5c5ff566c877 Mon Sep 17 00:00:00 2001 From: tran tien duc Date: Thu, 25 Oct 2018 18:43:51 +0700 Subject: [PATCH 1/2] delete unused test life cycle callbacks I checked, the beforeAll and afterAll callback don't affect any at all to setup cassandra containers startup. The cassandra container starting is triggered by another tricky method call. It's DockerCassandraRule.getHost(), it will automatically start DockerCassandraSingleton by trigger static method call. --- .../cucumber/CassandraDownloadCucumberTest.java | 12 ------------ .../cucumber/CassandraGetMessagesMethodTest.java | 13 ------------- .../CassandraIMAPKeywordsInconsistenciesTest.java | 12 ------------ .../CassandraIMAPSetMessagesCompatibilityTest.java | 13 ------------- .../cucumber/CassandraMailboxSharingTest.java | 13 ------------- .../cucumber/CassandraMessageSharingTest.java | 13 ------------- .../CassandraSetMailboxesMethodCucumberTest.java | 13 ------------- .../CassandraSetMessagesMethodCucumberTest.java | 12 ------------ .../cucumber/CassandraUploadCucumberTest.java | 13 ------------- 9 files changed, 114 deletions(-) diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraDownloadCucumberTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraDownloadCucumberTest.java index f16a909ca65..40f59aff3ea 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraDownloadCucumberTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraDownloadCucumberTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -32,14 +30,4 @@ tags = {"not @Ignore"}, strict = true) public class CassandraDownloadCucumberTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraGetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraGetMessagesMethodTest.java index 885d8ef3b7e..b4d541b1eed 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraGetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraGetMessagesMethodTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -31,15 +29,4 @@ glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber"}, strict = true) public class CassandraGetMessagesMethodTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } - } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPKeywordsInconsistenciesTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPKeywordsInconsistenciesTest.java index 92e40d0d004..23149676e78 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPKeywordsInconsistenciesTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPKeywordsInconsistenciesTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -31,14 +29,4 @@ glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber"}, strict = true) public class CassandraIMAPKeywordsInconsistenciesTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPSetMessagesCompatibilityTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPSetMessagesCompatibilityTest.java index 9aca4eabe4d..debe2dcd48b 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPSetMessagesCompatibilityTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPSetMessagesCompatibilityTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -31,15 +29,4 @@ glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber"}, strict = true) public class CassandraIMAPSetMessagesCompatibilityTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } - } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMailboxSharingTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMailboxSharingTest.java index 102632796ff..2301cb6abfe 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMailboxSharingTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMailboxSharingTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -39,15 +37,4 @@ tags = {"not @Ignore"}, strict = true) public class CassandraMailboxSharingTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } - } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMessageSharingTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMessageSharingTest.java index 87faa1705f8..0abf0aaa202 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMessageSharingTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraMessageSharingTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -40,15 +38,4 @@ tags = {"not @Ignore"}, strict = true) public class CassandraMessageSharingTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } - } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMailboxesMethodCucumberTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMailboxesMethodCucumberTest.java index bda4f668ceb..e10bb8fe9b1 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMailboxesMethodCucumberTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMailboxesMethodCucumberTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -31,15 +29,4 @@ glue = { "org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber" }, strict = true) public class CassandraSetMailboxesMethodCucumberTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } - } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMessagesMethodCucumberTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMessagesMethodCucumberTest.java index 445ffa24119..c22136fefcd 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMessagesMethodCucumberTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraSetMessagesMethodCucumberTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -31,14 +29,4 @@ glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber"}, strict = true) public class CassandraSetMessagesMethodCucumberTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraUploadCucumberTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraUploadCucumberTest.java index 9d583243eef..6ba97cde2e0 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraUploadCucumberTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraUploadCucumberTest.java @@ -19,8 +19,6 @@ package org.apache.james.jmap.cassandra.cucumber; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; @@ -32,15 +30,4 @@ tags = {"not @Ignore"}, strict = true) public class CassandraUploadCucumberTest { - - @BeforeClass - public static void init() { - CucumberCassandraSingleton.cassandraServer.start(); - } - - @AfterClass - public static void after() { - CucumberCassandraSingleton.cassandraServer.stop(); - } - } From c0eaa5cb607c99ea686025bf3ebff612c29a8c1c Mon Sep 17 00:00:00 2001 From: tran tien duc Date: Fri, 26 Oct 2018 09:57:05 +0700 Subject: [PATCH 2/2] Explicitly starting cassandra server in CassandraStepDefs --- .../apache/james/backends/cassandra/DockerCassandra.java | 8 ++++++-- .../james/backends/cassandra/DockerCassandraRule.java | 2 +- .../james/jmap/cassandra/cucumber/CassandraStepdefs.java | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java index 70f97981b10..72b916f4ce5 100644 --- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java +++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java @@ -54,11 +54,15 @@ private static void displayDockerLog(OutputFrame outputFrame) { } public void start() { - cassandraContainer.start(); + if (!cassandraContainer.isRunning()) { + cassandraContainer.start(); + } } public void stop() { - cassandraContainer.stop(); + if (cassandraContainer.isRunning()) { + cassandraContainer.stop(); + } } public Host getHost() { diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java index b3eb35e7bd0..37bad5d3695 100644 --- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java +++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java @@ -34,7 +34,7 @@ public Statement apply(Statement base, Description description) { } public void start() { - + DockerCassandraSingleton.singleton.start(); } public void stop() { diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java index 633c1e319d5..cf5da7722bd 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java @@ -67,6 +67,7 @@ private CassandraStepdefs(MainStepdefs mainStepdefs, ImapStepdefs imapStepdefs) @Before public void init() throws Exception { + cassandraServer.start(); temporaryFolder.create(); embeddedElasticSearch.before(); mainStepdefs.messageIdFactory = new CassandraMessageId.Factory();