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 2017/11/01 11:00:13 UTC
[15/15] james-project git commit: MAILBOX-315 Increase MPT Cassandra
testing speed by running James in a class rule
MAILBOX-315 Increase MPT Cassandra testing speed by running James in 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/b1f1077e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b1f1077e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b1f1077e
Branch: refs/heads/master
Commit: b1f1077e8cafc462de55d1327af0da410db2bc1a
Parents: b4aa905
Author: benwa <bt...@linagora.com>
Authored: Mon Oct 30 15:19:39 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Nov 1 17:57:22 2017 +0700
----------------------------------------------------------------------
.../GenericSimpleScriptedTestProtocol.java | 12 +++-
.../cassandra/CassandraAuthenticatePlain.java | 27 +++-----
.../cassandra/CassandraAuthenticatedState.java | 27 +++-----
.../cassandra/CassandraConcurrentSessions.java | 27 +++-----
.../cassandra/CassandraCondstore.java | 33 ++++------
.../imapmailbox/cassandra/CassandraCopy.java | 31 +++------
.../imapmailbox/cassandra/CassandraEvents.java | 31 +++------
.../imapmailbox/cassandra/CassandraExpunge.java | 31 +++------
.../imapmailbox/cassandra/CassandraFetch.java | 31 +++------
.../cassandra/CassandraFetchBodySection.java | 33 +++-------
.../cassandra/CassandraFetchBodyStructure.java | 33 +++-------
.../cassandra/CassandraFetchHeaders.java | 31 +++------
.../imapmailbox/cassandra/CassandraListing.java | 31 +++------
.../CassandraListingWithSharingTest.java | 28 ++------
.../cassandra/CassandraMailboxAnnotation.java | 27 +++-----
.../cassandra/CassandraMailboxTestModule.java | 52 ---------------
.../CassandraMailboxWithLongNameError.java | 31 +++------
.../imapmailbox/cassandra/CassandraMove.java | 31 +++------
.../CassandraNonAuthenticatedState.java | 31 +++------
.../cassandra/CassandraPartialFetch.java | 31 +++------
.../cassandra/CassandraQuotaTest.java | 27 +++-----
.../imapmailbox/cassandra/CassandraRename.java | 27 +++-----
.../imapmailbox/cassandra/CassandraSearch.java | 31 +++------
.../cassandra/CassandraSecurity.java | 31 +++------
.../imapmailbox/cassandra/CassandraSelect.java | 31 +++------
.../cassandra/CassandraSelectedInbox.java | 31 +++------
.../cassandra/CassandraSelectedState.java | 27 +++-----
.../cassandra/CassandraUidSearch.java | 31 +++------
.../cassandra/CassandraUidSearchOnIndex.java | 31 +++------
.../cassandra/CassandraUserFlagsSupport.java | 31 +++------
.../cassandra/host/CassandraHostSystem.java | 2 +-
.../cassandra/host/CassandraHostSystemRule.java | 69 ++++++++++++++++++++
.../mpt/imapmailbox/suite/UidSearchOnIndex.java | 2 +
33 files changed, 320 insertions(+), 660 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/core/src/main/java/org/apache/james/mpt/script/GenericSimpleScriptedTestProtocol.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/script/GenericSimpleScriptedTestProtocol.java b/mpt/core/src/main/java/org/apache/james/mpt/script/GenericSimpleScriptedTestProtocol.java
index 64a562f..ed6bd5f 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/script/GenericSimpleScriptedTestProtocol.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/script/GenericSimpleScriptedTestProtocol.java
@@ -30,9 +30,13 @@ import org.apache.james.mpt.api.HostSystem;
import org.apache.james.mpt.api.Session;
import org.apache.james.mpt.protocol.FileProtocolSessionBuilder;
import org.apache.james.mpt.protocol.ProtocolSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class GenericSimpleScriptedTestProtocol<T extends HostSystem, SELF extends GenericSimpleScriptedTestProtocol<?, ?>> {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GenericSimpleScriptedTestProtocol.class);
+
public interface PrepareCommand<T extends HostSystem> {
void prepare(T system) throws Exception;
}
@@ -48,7 +52,11 @@ public class GenericSimpleScriptedTestProtocol<T extends HostSystem, SELF extend
}
public void prepare(HostSystem system) throws Exception {
- system.addUser(user, password);
+ try {
+ system.addUser(user, password);
+ } catch (Exception e) {
+ LOGGER.info("User {} already exists");
+ }
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlain.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlain.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlain.java
index a8e83d9..091074a 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlain.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlain.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.AuthenticatePlain;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraAuthenticatePlain extends AuthenticatePlain {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedState.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedState.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedState.java
index be1d1d8..fd55329 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedState.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedState.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.AuthenticatedState;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraAuthenticatedState extends AuthenticatedState {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessions.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessions.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessions.java
index f235e5c..0b04ebc 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessions.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessions.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.ConcurrentSessions;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraConcurrentSessions extends ConcurrentSessions {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstore.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstore.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstore.java
index c5648d5..ba5f947 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstore.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstore.java
@@ -21,36 +21,31 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.host.JamesImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Condstore;
import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
public class CassandraCondstore extends Condstore {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ /**
+ * The underlying tests are playing with capabilities, which are configured when starting James.
+ * Hence, we can't use the RuleChain as a @ClassRule in this implementation.
+ */
+ @Rule
+ public RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private JamesImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(JamesImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected JamesImapHostSystem createJamesImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopy.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopy.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopy.java
index 45aa8f9..4677a2e 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopy.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopy.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Copy;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraCopy extends Copy {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEvents.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEvents.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEvents.java
index 28007e6..05fafb8 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEvents.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEvents.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Events;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraEvents extends Events {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpunge.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpunge.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpunge.java
index a7ae30e..df9eb51 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpunge.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpunge.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Expunge;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraExpunge extends Expunge {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetch.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetch.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetch.java
index d5f6ddb..8a18b97 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetch.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetch.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Fetch;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraFetch extends Fetch {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySection.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySection.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySection.java
index 47fcb3f..24381b5 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySection.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySection.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.FetchBodySection;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraFetchBodySection extends FetchBodySection {
-
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructure.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructure.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructure.java
index c0b2a31..0489151 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructure.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructure.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.FetchBodyStructure;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraFetchBodyStructure extends FetchBodyStructure {
-
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeaders.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeaders.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeaders.java
index bd3be46..976cb7d 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeaders.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeaders.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.FetchHeaders;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraFetchHeaders extends FetchHeaders {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListing.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListing.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListing.java
index c29de81..4776f25 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListing.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListing.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Listing;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraListing extends Listing {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
index 6d7fb6d..2aa398b 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
@@ -21,35 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.ListingWithSharingTest;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraListingWithSharingTest extends ListingWithSharingTest {
- @ClassRule
- public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
- private ImapHostSystem system;
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotation.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotation.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotation.java
index 0bec8c3..1d4fdbe 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotation.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotation.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.MailboxAnnotation;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraMailboxAnnotation extends MailboxAnnotation {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxTestModule.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxTestModule.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxTestModule.java
deleted file mode 100644
index d22246b..0000000
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxTestModule.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
-
-package org.apache.james.mpt.imapmailbox.cassandra;
-
-import org.apache.james.mpt.api.HostSystem;
-import org.apache.james.mpt.api.ImapHostSystem;
-import org.apache.james.mpt.host.JamesImapHostSystem;
-import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystem;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-
-public class CassandraMailboxTestModule extends AbstractModule {
-
- private final String cassandraHost;
- private final int cassandraPort;
-
- public CassandraMailboxTestModule(String cassandraHost, int cassandraPort) {
- this.cassandraHost = cassandraHost;
- this.cassandraPort = cassandraPort;
- }
-
- @Override
- protected void configure() {
- bind(HostSystem.class).to(JamesImapHostSystem.class);
- bind(ImapHostSystem.class).to(JamesImapHostSystem.class);
- }
-
- @Provides
- @Singleton
- public JamesImapHostSystem provideHostSystem() throws Exception {
- return new CassandraHostSystem(cassandraHost, cassandraPort);
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameError.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameError.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameError.java
index 189118b..a8a9edb 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameError.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameError.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.MailboxWithLongNameError;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraMailboxWithLongNameError extends MailboxWithLongNameError {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMove.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMove.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMove.java
index c2691f5..3de3b62 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMove.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMove.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Move;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraMove extends Move {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedState.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedState.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedState.java
index 3338b00..6851f2f 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedState.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedState.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.NonAuthenticatedState;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraNonAuthenticatedState extends NonAuthenticatedState {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetch.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetch.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetch.java
index ef45eff..d767297 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetch.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetch.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.PartialFetch;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraPartialFetch extends PartialFetch {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
index 759a484..00ba775 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.QuotaTest;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraQuotaTest extends QuotaTest {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRename.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRename.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRename.java
index b7b5746..7e9c43f 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRename.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRename.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Rename;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraRename extends Rename {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearch.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearch.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearch.java
index e40b985..aa85a52 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearch.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearch.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Search;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraSearch extends Search {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurity.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurity.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurity.java
index ea10c9a..49874ae 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurity.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurity.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Security;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraSecurity extends Security {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelect.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelect.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelect.java
index 2e6e95e..cd42204 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelect.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelect.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.Select;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraSelect extends Select {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInbox.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInbox.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInbox.java
index 97b251b..dc71a87 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInbox.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInbox.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.SelectedInbox;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraSelectedInbox extends SelectedInbox {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedState.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedState.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedState.java
index 7b30c55..7c1e4ac 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedState.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedState.java
@@ -21,36 +21,27 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.SelectedState;
import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraSelectedState extends SelectedState {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
+ return cassandraHostSystemRule.getImapHostSystem();
}
@After
public void tearDown() throws Exception {
- system.afterTest();
+ cassandraHostSystemRule.clean();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearch.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearch.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearch.java
index f97610c..92069eb 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearch.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearch.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.UidSearch;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraUidSearch extends UidSearch {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndex.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndex.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndex.java
index 92afdbe..5fda286 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndex.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndex.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.UidSearchOnIndex;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraUidSearchOnIndex extends UidSearchOnIndex {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupport.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupport.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupport.java
index c55ceb9..4bdb14f 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupport.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupport.java
@@ -21,36 +21,21 @@ package org.apache.james.mpt.imapmailbox.cassandra;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
import org.apache.james.mpt.imapmailbox.suite.UserFlagsSupport;
-import org.junit.After;
-import org.junit.Before;
import org.junit.ClassRule;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import org.junit.rules.RuleChain;
public class CassandraUserFlagsSupport extends UserFlagsSupport {
- @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+ private static CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
+
+ @ClassRule
+ public static RuleChain ruleChaine = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
- private ImapHostSystem system;
-
- @Before
- public void setUp() throws Exception {
- Injector injector = Guice.createInjector(new CassandraMailboxTestModule(cassandraServer.getIp(), cassandraServer.getBindingPort()));
- system = injector.getInstance(ImapHostSystem.class);
- system.beforeTest();
- super.setUp();
- }
-
@Override
protected ImapHostSystem createImapHostSystem() {
- return system;
- }
-
- @After
- public void tearDown() throws Exception {
- system.afterTest();
+ return cassandraHostSystemRule.getImapHostSystem();
}
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index 465a2f2..ca39444 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -154,7 +154,7 @@ public class CassandraHostSystem extends JamesImapHostSystem {
}
@Override
- protected MailboxManager getMailboxManager() {
+ public MailboxManager getMailboxManager() {
return mailboxManager;
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystemRule.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystemRule.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystemRule.java
new file mode 100644
index 0000000..4dd951f
--- /dev/null
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystemRule.java
@@ -0,0 +1,69 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mpt.imapmailbox.cassandra.host;
+
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mpt.host.JamesImapHostSystem;
+import org.junit.rules.ExternalResource;
+
+import com.github.fge.lambdas.Throwing;
+import com.google.common.base.Throwables;
+
+public class CassandraHostSystemRule extends ExternalResource {
+
+ private static final String USERNAME = "mpt";
+
+ private final DockerCassandraRule cassandraServer;
+ private CassandraHostSystem system;
+
+ public CassandraHostSystemRule(DockerCassandraRule cassandraServer) {
+ this.cassandraServer = cassandraServer;
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ system = new CassandraHostSystem(cassandraServer.getIp(), cassandraServer.getBindingPort());
+ system.beforeTest();
+ }
+
+ @Override
+ protected void after() {
+ try {
+ clean();
+ } catch (Exception e) {
+ Throwables.propagate(e);
+ }
+ }
+
+ public void clean() throws Exception {
+ MailboxManager mailboxManager = system.getMailboxManager();
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ mailboxManager.list(systemSession)
+ .forEach(Throwing.consumer(
+ mailboxPath -> mailboxManager.deleteMailbox(
+ mailboxPath,
+ mailboxManager.createSystemSession(mailboxPath.getUser()))));
+ }
+
+ public JamesImapHostSystem getImapHostSystem() {
+ return system;
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b1f1077e/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/UidSearchOnIndex.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/UidSearchOnIndex.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/UidSearchOnIndex.java
index 3f19ad0..231768d 100644
--- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/UidSearchOnIndex.java
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/UidSearchOnIndex.java
@@ -25,6 +25,7 @@ import org.apache.james.mpt.api.ImapHostSystem;
import org.apache.james.mpt.imapmailbox.ImapTestConstants;
import org.apache.james.mpt.imapmailbox.suite.base.BasicImapCommands;
import org.apache.james.mpt.script.SimpleScriptedTestProtocol;
+import org.junit.Before;
import org.junit.Test;
public abstract class UidSearchOnIndex implements ImapTestConstants {
@@ -34,6 +35,7 @@ public abstract class UidSearchOnIndex implements ImapTestConstants {
private ImapHostSystem system;
private SimpleScriptedTestProtocol simpleScriptedTestProtocol;
+ @Before
public void setUp() throws Exception {
system = createImapHostSystem();
simpleScriptedTestProtocol = new SimpleScriptedTestProtocol("/org/apache/james/imap/scripts/", system)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org