james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [21/22] james-project git commit: JAMES-2595 get rid of JamesWithSpamAssassin
Date Wed, 21 Nov 2018 10:07:31 GMT
JAMES-2595 get rid of JamesWithSpamAssassin


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

Branch: refs/heads/master
Commit: 9dd5640feb5b9b7cc16bf82d6a9db0626404ff81
Parents: 14c9128
Author: duc <dtran@linagora.com>
Authored: Mon Nov 19 22:48:29 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Nov 21 16:50:59 2018 +0700

----------------------------------------------------------------------
 .../org/apache/james/CassandraExtension.java    |   4 +-
 .../james/JamesServerExtensionBuilder.java      |   6 +-
 .../jmap/cassandra/CassandraJmapExtension.java  | 124 ------------------
 .../CassandraSpamAssassinContractTest.java      |  35 ++++-
 .../integration/JamesWithSpamAssassin.java      |  41 ------
 .../integration/SpamAssassinContract.java       |  97 +++++++-------
 .../SpamAssassinModuleExtension.java            |  54 ++++++++
 .../james/jmap/memory/MemoryJmapExtension.java  |  99 --------------
 .../memory/MemorySpamAssassinContractTest.java  |  36 ++++-
 .../jmap/rabbitmq/RabbitMQJmapExtension.java    | 130 -------------------
 .../RabbitMQSpamAssassinContractTest.java       |  36 ++++-
 .../spamassassin/SpamAssassinExtension.java     |   8 +-
 12 files changed, 217 insertions(+), 453 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
index 41767e3..eac342c 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraExtension.java
@@ -23,11 +23,11 @@ import org.junit.jupiter.api.extension.ExtensionContext;
 
 import com.google.inject.Module;
 
-class CassandraExtension implements GuiceModuleTestExtension {
+public class CassandraExtension implements GuiceModuleTestExtension {
 
     private final DockerCassandraRule cassandra;
 
-    CassandraExtension() {
+    public CassandraExtension() {
         this(new DockerCassandraRule());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
index 7caa047..8d521c0 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
@@ -34,12 +34,12 @@ public class JamesServerExtensionBuilder {
     private static final boolean DEFAULT_AUTO_START = true;
 
     @FunctionalInterface
-    interface ConfigurationProvider {
+    public interface ConfigurationProvider {
         Configuration buildConfiguration(File tempDirectory);
     }
 
     @FunctionalInterface
-    interface ServerProvider {
+    public interface ServerProvider {
         GuiceJamesServer buildServer(Configuration configuration);
     }
 
@@ -49,7 +49,7 @@ public class JamesServerExtensionBuilder {
     private Optional<ConfigurationProvider> configuration;
     private Optional<Boolean> autoStart;
 
-    JamesServerExtensionBuilder() {
+    public JamesServerExtensionBuilder() {
         configuration = Optional.empty();
         extensions = ImmutableList.builder();
         folderRegistrableExtension = new TemporaryFolderRegistrableExtension();

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
deleted file mode 100644
index 4cf4286..0000000
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
+++ /dev/null
@@ -1,124 +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.jmap.cassandra;
-
-import static org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE;
-
-import java.io.IOException;
-
-import org.apache.james.DockerCassandraRule;
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.jmap.methods.integration.JamesWithSpamAssassin;
-import org.apache.james.jmap.methods.integration.SpamAssassinModule;
-import org.apache.james.mailbox.extractor.TextExtractor;
-import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.modules.TestESMetricReporterModule;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.server.core.configuration.Configuration;
-import org.apache.james.spamassassin.SpamAssassinExtension;
-import org.apache.james.util.Runnables;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-import org.junit.rules.TemporaryFolder;
-
-public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallback,
-    BeforeEachCallback, AfterEachCallback, ParameterResolver {
-
-    private static final int LIMIT_TO_20_MESSAGES = 20;
-
-    private final TemporaryFolder temporaryFolder;
-    private final DockerCassandraRule cassandra;
-    private final EmbeddedElasticSearch elasticSearch;
-    private final SpamAssassinExtension spamAssassinExtension;
-    private JamesWithSpamAssassin james;
-
-    public CassandraJmapExtension() {
-        this.temporaryFolder = new TemporaryFolder();
-        this.cassandra = new DockerCassandraRule();
-        this.elasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-        this.spamAssassinExtension = new SpamAssassinExtension();
-    }
-
-    private JamesWithSpamAssassin james() throws IOException {
-        Configuration configuration = Configuration.builder()
-            .workingDirectory(temporaryFolder.newFolder())
-            .configurationFromClasspath()
-            .build();
-        return new JamesWithSpamAssassin(
-            GuiceJamesServer.forConfiguration(configuration)
-                    .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
-                    .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
-                    .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
-                    .overrideWith(new TestESMetricReporterModule())
-                    .overrideWith(cassandra.getModule())
-                    .overrideWith(new TestElasticSearchModule(elasticSearch))
-                    .overrideWith(new SpamAssassinModule(spamAssassinExtension)),
-            spamAssassinExtension);
-    }
-
-    @Override
-    public void beforeAll(ExtensionContext context) throws Exception {
-        temporaryFolder.create();
-
-        Runnables.runParallel(
-            cassandra::start,
-            elasticSearch::before);
-    }
-
-    @Override
-    public void afterAll(ExtensionContext context) {
-        elasticSearch.after();
-
-        Runnables.runParallel(
-            () -> spamAssassinExtension.afterAll(context),
-            cassandra::stop,
-            elasticSearch::after);
-    }
-
-    @Override
-    public void beforeEach(ExtensionContext context) throws Exception {
-        james = james();
-        spamAssassinExtension.start();
-        james.getJmapServer().start();
-    }
-
-    @Override
-    public void afterEach(ExtensionContext context) {
-        james.getJmapServer().stop();
-        spamAssassinExtension.stop();
-    }
-
-    @Override
-    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return parameterContext.getParameter().getType() == JamesWithSpamAssassin.class;
-    }
-
-    @Override
-    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return james;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSpamAssassinContractTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSpamAssassinContractTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSpamAssassinContractTest.java
index a6a0eec..0772c1c 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSpamAssassinContractTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSpamAssassinContractTest.java
@@ -18,10 +18,39 @@
  ****************************************************************/
 package org.apache.james.jmap.cassandra;
 
+import static org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE;
+
+import org.apache.james.CassandraExtension;
+import org.apache.james.EmbeddedElasticSearchExtension;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.JamesServerExtensionBuilder;
 import org.apache.james.jmap.methods.integration.SpamAssassinContract;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.apache.james.jmap.methods.integration.SpamAssassinModuleExtension;
+import org.apache.james.mailbox.extractor.TextExtractor;
+import org.apache.james.mailbox.store.search.PDFTextExtractor;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.spamassassin.SpamAssassinExtension;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class CassandraSpamAssassinContractTest implements SpamAssassinContract {
+
+    private static final int LIMIT_TO_20_MESSAGES = 20;
+    private static final SpamAssassinModuleExtension spamAssassinExtension = new SpamAssassinModuleExtension();
 
-@ExtendWith(CassandraJmapExtension.class)
-public class CassandraSpamAssassinContractTest implements SpamAssassinContract {
+    @RegisterExtension
+    static JamesServerExtension testExtension = new JamesServerExtensionBuilder()
+        .extension(new EmbeddedElasticSearchExtension())
+        .extension(new CassandraExtension())
+        .extension(spamAssassinExtension)
+        .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+            .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
+            .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
+            .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES)))
+        .build();
 
+    @Override
+    public SpamAssassinExtension.SpamAssassin spamAssassin() {
+        return spamAssassinExtension.spamAssassinExtension().getSpamAssassin();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
deleted file mode 100644
index 6a10a29..0000000
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/JamesWithSpamAssassin.java
+++ /dev/null
@@ -1,41 +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.jmap.methods.integration;
-
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.spamassassin.SpamAssassinExtension;
-
-public class JamesWithSpamAssassin {
-
-    private final GuiceJamesServer jmapServer;
-    private final SpamAssassinExtension spamAssassinExtension;
-
-    public JamesWithSpamAssassin(GuiceJamesServer jmapServer, SpamAssassinExtension spamAssassinExtension) {
-        this.jmapServer = jmapServer;
-        this.spamAssassinExtension = spamAssassinExtension;
-    }
-
-    public GuiceJamesServer getJmapServer() {
-        return jmapServer;
-    }
-
-    public SpamAssassinExtension getSpamAssassinExtension() {
-        return spamAssassinExtension;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
index 321b1dc..cb8cd57 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
@@ -40,6 +40,7 @@ import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.Role;
 import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.spamassassin.SpamAssassinExtension;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.IMAPMessageReader;
 import org.apache.james.utils.JmapGuiceProbe;
@@ -65,16 +66,16 @@ public interface SpamAssassinContract {
     String PAUL_PASSWORD = "paulPassword";
 
     @BeforeEach
-    default void setup(JamesWithSpamAssassin james) throws Throwable {
+    default void setup(GuiceJamesServer jamesServer) throws Throwable {
         RestAssured.requestSpecification = new RequestSpecBuilder()
                 .setContentType(ContentType.JSON)
                 .setAccept(ContentType.JSON)
                 .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
-                .setPort(james.getJmapServer().getProbe(JmapGuiceProbe.class).getJmapPort())
+                .setPort(jamesServer.getProbe(JmapGuiceProbe.class).getJmapPort())
                 .build();
         RestAssured.defaultParser = Parser.JSON;
 
-        james.getJmapServer().getProbe(DataProbeImpl.class)
+        jamesServer.getProbe(DataProbeImpl.class)
             .fluent()
             .addDomain(BOBS_DOMAIN)
             .addDomain(RECIPIENTS_DOMAIN)
@@ -84,19 +85,23 @@ public interface SpamAssassinContract {
     }
 
     @AfterEach
-    default void tearDown(SpamAssassinExtension.SpamAssassin spamAssassin) throws Exception {
-        spamAssassin.clear(ALICE);
+    default void tearDown() throws Exception {
+        spamAssassin().clear(ALICE);
     }
 
+    SpamAssassinExtension.SpamAssassin spamAssassin();
+
     default AccessToken accessTokenFor(GuiceJamesServer james, String user, String password) {
         return authenticateJamesUser(baseUri(james), user, password);
     }
 
     @Test
-    default void spamShouldBeDeliveredInSpamMailboxWhenSameMessageHasAlreadyBeenMovedToSpam(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void spamShouldBeDeliveredInSpamMailboxWhenSameMessageHasAlreadyBeenMovedToSpam(
+        GuiceJamesServer jamesServer) throws Exception {
+
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -143,10 +148,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void imapCopiesToSpamMailboxShouldBeConsideredAsSpam(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void imapCopiesToSpamMailboxShouldBeConsideredAsSpam(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -170,7 +175,7 @@ public interface SpamAssassinContract {
             .path(ARGUMENTS + ".messageIds");
 
         try (IMAPMessageReader imapMessageReader = new IMAPMessageReader()) {
-            imapMessageReader.connect(LOCALHOST_IP, james.getJmapServer().getProbe(ImapGuiceProbe.class).getImapPort())
+            imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
                 .login(ALICE, ALICE_PASSWORD)
                 .select(IMAPMessageReader.INBOX);
 
@@ -190,10 +195,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void imapMovesToSpamMailboxShouldBeConsideredAsSpam(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void imapMovesToSpamMailboxShouldBeConsideredAsSpam(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -217,7 +222,7 @@ public interface SpamAssassinContract {
             .path(ARGUMENTS + ".messageIds");
 
         try (IMAPMessageReader imapMessageReader = new IMAPMessageReader()) {
-            imapMessageReader.connect(LOCALHOST_IP, james.getJmapServer().getProbe(ImapGuiceProbe.class).getImapPort())
+            imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
                 .login(ALICE, ALICE_PASSWORD)
                 .select(IMAPMessageReader.INBOX);
 
@@ -237,10 +242,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void spamAssassinShouldForgetMessagesMovedOutOfSpamFolderUsingJMAP(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void spamAssassinShouldForgetMessagesMovedOutOfSpamFolderUsingJMAP(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -300,10 +305,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void movingAMailToTrashShouldNotImpactSpamassassinLearning(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void movingAMailToTrashShouldNotImpactSpamassassinLearning(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -363,10 +368,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void spamAssassinShouldForgetMessagesMovedOutOfSpamFolderUsingIMAP(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void spamAssassinShouldForgetMessagesMovedOutOfSpamFolderUsingIMAP(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -403,7 +408,7 @@ public interface SpamAssassinContract {
 
         // Alice is moving this message out of Spam -> forgetting in SpamAssassin
         try (IMAPMessageReader imapMessageReader = new IMAPMessageReader()) {
-            imapMessageReader.connect(LOCALHOST_IP, james.getJmapServer().getProbe(ImapGuiceProbe.class).getImapPort())
+            imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
                 .login(ALICE, ALICE_PASSWORD)
                 .select("Spam");
 
@@ -423,10 +428,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void expungingSpamMessageShouldNotImpactSpamAssassinState(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void expungingSpamMessageShouldNotImpactSpamAssassinState(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -463,7 +468,7 @@ public interface SpamAssassinContract {
 
         // Alice is deleting this message
         try (IMAPMessageReader imapMessageReader = new IMAPMessageReader()) {
-            imapMessageReader.connect(LOCALHOST_IP, james.getJmapServer().getProbe(ImapGuiceProbe.class).getImapPort())
+            imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
                 .login(ALICE, ALICE_PASSWORD)
                 .select("Spam");
 
@@ -484,10 +489,10 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void deletingSpamMessageShouldNotImpactSpamAssassinState(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
+    default void deletingSpamMessageShouldNotImpactSpamAssassinState(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
 
         // Bob is sending a message to Alice
         given()
@@ -565,11 +570,11 @@ public interface SpamAssassinContract {
     }
 
     @Test
-    default void spamShouldBeDeliveredInSpamMailboxOrInboxWhenMultipleRecipientsConfigurations(JamesWithSpamAssassin james) throws Exception {
-        james.getSpamAssassinExtension().getSpamAssassin().train(ALICE);
-        AccessToken aliceAccessToken = accessTokenFor(james.getJmapServer(), ALICE, ALICE_PASSWORD);
-        AccessToken bobAccessToken = accessTokenFor(james.getJmapServer(), BOB, BOB_PASSWORD);
-        AccessToken paulAccessToken = accessTokenFor(james.getJmapServer(), PAUL, PAUL_PASSWORD);
+    default void spamShouldBeDeliveredInSpamMailboxOrInboxWhenMultipleRecipientsConfigurations(GuiceJamesServer jamesServer) throws Exception {
+        spamAssassin().train(ALICE);
+        AccessToken aliceAccessToken = accessTokenFor(jamesServer, ALICE, ALICE_PASSWORD);
+        AccessToken bobAccessToken = accessTokenFor(jamesServer, BOB, BOB_PASSWORD);
+        AccessToken paulAccessToken = accessTokenFor(jamesServer, PAUL, PAUL_PASSWORD);
 
         // Bob is sending a message to Alice & Paul
         given()

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModuleExtension.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModuleExtension.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModuleExtension.java
new file mode 100644
index 0000000..a4e6e2d
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModuleExtension.java
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import org.apache.james.GuiceModuleTestExtension;
+import org.apache.james.spamassassin.SpamAssassinExtension;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+import com.google.inject.Module;
+
+public class SpamAssassinModuleExtension implements GuiceModuleTestExtension {
+
+    private final SpamAssassinExtension spamAssassin;
+
+    public SpamAssassinModuleExtension() {
+        this.spamAssassin = new org.apache.james.spamassassin.SpamAssassinExtension();
+    }
+
+    @Override
+    public void beforeAll(ExtensionContext extensionContext) {
+        spamAssassin.beforeAll(extensionContext);
+    }
+
+    @Override
+    public void afterAll(ExtensionContext extensionContext) {
+        spamAssassin.afterAll(extensionContext);
+    }
+
+    @Override
+    public Module getModule() {
+        return new SpamAssassinModule(spamAssassin);
+    }
+
+    public SpamAssassinExtension spamAssassinExtension() {
+        return spamAssassin;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
deleted file mode 100644
index f2f8462..0000000
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
+++ /dev/null
@@ -1,99 +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.jmap.memory;
-
-import java.io.IOException;
-
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJamesServerMain;
-import org.apache.james.jmap.methods.integration.JamesWithSpamAssassin;
-import org.apache.james.jmap.methods.integration.SpamAssassinModule;
-import org.apache.james.mailbox.extractor.TextExtractor;
-import org.apache.james.mailbox.store.search.MessageSearchIndex;
-import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.server.core.configuration.Configuration;
-import org.apache.james.spamassassin.SpamAssassinExtension;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-import org.junit.rules.TemporaryFolder;
-
-public class MemoryJmapExtension implements BeforeEachCallback, AfterEachCallback, ParameterResolver {
-
-    private static final int LIMIT_TO_20_MESSAGES = 20;
-
-    private final TemporaryFolder temporaryFolder;
-    private final SpamAssassinExtension spamAssassinExtension;
-    private final JamesWithSpamAssassin james;
-
-    public MemoryJmapExtension() throws IOException {
-        this.temporaryFolder = new TemporaryFolder();
-        this.spamAssassinExtension = new SpamAssassinExtension();
-        this.james = james();
-    }
-
-    private JamesWithSpamAssassin james() throws IOException {
-        temporaryFolder.create();
-        Configuration configuration = Configuration.builder()
-            .workingDirectory(temporaryFolder.newFolder())
-            .configurationFromClasspath()
-            .build();
-
-        return new JamesWithSpamAssassin(
-            GuiceJamesServer.forConfiguration(configuration)
-                .combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
-                .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
-                .overrideWith(binder -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
-                .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
-                .overrideWith(binder -> binder.bind(MessageSearchIndex.class).to(SimpleMessageSearchIndex.class))
-                .overrideWith(new SpamAssassinModule(spamAssassinExtension)),
-            spamAssassinExtension);
-    }
-
-    @Override
-    public void beforeEach(ExtensionContext context) throws Exception {
-        spamAssassinExtension.start();
-        temporaryFolder.create();
-        james.getJmapServer().start();
-    }
-
-    @Override
-    public void afterEach(ExtensionContext context) {
-        james.getJmapServer().stop();
-        temporaryFolder.delete();
-        spamAssassinExtension.stop();
-    }
-
-    @Override
-    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return parameterContext.getParameter().getType() == JamesWithSpamAssassin.class;
-    }
-
-    @Override
-    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return james;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContractTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContractTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContractTest.java
index dfee6de..29c501c 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContractTest.java
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySpamAssassinContractTest.java
@@ -18,10 +18,40 @@
  ****************************************************************/
 package org.apache.james.jmap.memory;
 
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.JamesServerExtensionBuilder;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.jmap.methods.integration.SpamAssassinContract;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.apache.james.jmap.methods.integration.SpamAssassinModuleExtension;
+import org.apache.james.mailbox.extractor.TextExtractor;
+import org.apache.james.mailbox.store.search.MessageSearchIndex;
+import org.apache.james.mailbox.store.search.PDFTextExtractor;
+import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.spamassassin.SpamAssassinExtension;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-@ExtendWith(MemoryJmapExtension.class)
-public class MemorySpamAssassinContractTest implements SpamAssassinContract {
+class MemorySpamAssassinContractTest implements SpamAssassinContract {
 
+    private static final int LIMIT_TO_20_MESSAGES = 20;
+
+    private static final SpamAssassinModuleExtension spamAssassinExtension = new SpamAssassinModuleExtension();
+    @RegisterExtension
+    static JamesServerExtension testExtension = new JamesServerExtensionBuilder()
+        .extension(spamAssassinExtension)
+        .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+            .combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
+            .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
+            .overrideWith(binder -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
+            .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
+            .overrideWith(binder -> binder.bind(MessageSearchIndex.class).to(SimpleMessageSearchIndex.class)))
+        .build();
+
+    @Override
+    public SpamAssassinExtension.SpamAssassin spamAssassin() {
+        return spamAssassinExtension.spamAssassinExtension().getSpamAssassin();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQJmapExtension.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQJmapExtension.java b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQJmapExtension.java
deleted file mode 100644
index 9aa6a5f..0000000
--- a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQJmapExtension.java
+++ /dev/null
@@ -1,130 +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.jmap.rabbitmq;
-
-import java.io.IOException;
-
-import org.apache.james.CassandraRabbitMQJamesServerMain;
-import org.apache.james.DockerCassandraRule;
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.backend.rabbitmq.DockerRabbitMQSingleton;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.jmap.methods.integration.JamesWithSpamAssassin;
-import org.apache.james.jmap.methods.integration.SpamAssassinModule;
-import org.apache.james.mailbox.extractor.TextExtractor;
-import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.modules.TestESMetricReporterModule;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.modules.TestRabbitMQModule;
-import org.apache.james.modules.TestSwiftBlobStoreModule;
-import org.apache.james.modules.blobstore.BlobStoreChoosingConfiguration;
-import org.apache.james.server.core.configuration.Configuration;
-import org.apache.james.spamassassin.SpamAssassinExtension;
-import org.apache.james.util.Runnables;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-import org.junit.rules.TemporaryFolder;
-
-public class RabbitMQJmapExtension implements BeforeAllCallback, AfterAllCallback,
-    BeforeEachCallback, AfterEachCallback, ParameterResolver {
-
-    private static final int LIMIT_TO_20_MESSAGES = 20;
-
-    private final TemporaryFolder temporaryFolder;
-    private final DockerCassandraRule cassandra;
-    private final EmbeddedElasticSearch elasticSearch;
-    private final SpamAssassinExtension spamAssassinExtension;
-    private JamesWithSpamAssassin james;
-
-    public RabbitMQJmapExtension() {
-        this.temporaryFolder = new TemporaryFolder();
-        this.cassandra = new DockerCassandraRule();
-        this.elasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-        this.spamAssassinExtension = new SpamAssassinExtension();
-    }
-
-    private JamesWithSpamAssassin james() throws IOException {
-        Configuration configuration = Configuration.builder()
-            .workingDirectory(temporaryFolder.newFolder())
-            .configurationFromClasspath()
-            .build();
-        return new JamesWithSpamAssassin(
-            GuiceJamesServer.forConfiguration(configuration)
-                    .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
-                    .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
-                    .overrideWith(new TestRabbitMQModule(DockerRabbitMQSingleton.SINGLETON))
-                    .overrideWith(new TestSwiftBlobStoreModule())
-                    .overrideWith(binder -> binder.bind(BlobStoreChoosingConfiguration.class)
-                        .toInstance(BlobStoreChoosingConfiguration.objectStorage()))
-                    .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
-                    .overrideWith(new TestESMetricReporterModule())
-                    .overrideWith(cassandra.getModule())
-                    .overrideWith(new TestElasticSearchModule(elasticSearch))
-                    .overrideWith(new SpamAssassinModule(spamAssassinExtension)),
-            spamAssassinExtension);
-    }
-
-    @Override
-    public void beforeAll(ExtensionContext context) throws Exception {
-        temporaryFolder.create();
-
-        Runnables.runParallel(
-            cassandra::start,
-            elasticSearch::before);
-    }
-
-    @Override
-    public void afterAll(ExtensionContext context) {
-        elasticSearch.after();
-
-        Runnables.runParallel(
-            cassandra::stop,
-            elasticSearch::after);
-    }
-
-    @Override
-    public void beforeEach(ExtensionContext context) throws Exception {
-        spamAssassinExtension.start();
-        james = james();
-        james.getJmapServer().start();
-    }
-
-    @Override
-    public void afterEach(ExtensionContext context) {
-        james.getJmapServer().stop();
-        spamAssassinExtension.stop();
-    }
-
-    @Override
-    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return parameterContext.getParameter().getType() == JamesWithSpamAssassin.class;
-    }
-
-    @Override
-    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return james;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQSpamAssassinContractTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQSpamAssassinContractTest.java b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQSpamAssassinContractTest.java
index cc16910..ac332a1 100644
--- a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQSpamAssassinContractTest.java
+++ b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQSpamAssassinContractTest.java
@@ -18,11 +18,45 @@
  ****************************************************************/
 package org.apache.james.jmap.rabbitmq;
 
+import org.apache.james.CassandraExtension;
+import org.apache.james.CassandraRabbitMQJamesServerMain;
+import org.apache.james.EmbeddedElasticSearchExtension;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.JamesServerExtensionBuilder;
 import org.apache.james.jmap.methods.integration.SpamAssassinContract;
+import org.apache.james.jmap.methods.integration.SpamAssassinModuleExtension;
+import org.apache.james.mailbox.extractor.TextExtractor;
+import org.apache.james.mailbox.store.search.PDFTextExtractor;
+import org.apache.james.modules.RabbitMQExtension;
+import org.apache.james.modules.SwiftBlobStoreExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.blobstore.BlobStoreChoosingConfiguration;
+import org.apache.james.spamassassin.SpamAssassinExtension;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
 class RabbitMQSpamAssassinContractTest implements SpamAssassinContract {
 
+    private static final int LIMIT_TO_20_MESSAGES = 20;
+
+    private static final SpamAssassinModuleExtension spamAssassinExtension = new SpamAssassinModuleExtension();
     @RegisterExtension
-    static RabbitMQJmapExtension jmapExtension = new RabbitMQJmapExtension();
+    static JamesServerExtension testExtension = new JamesServerExtensionBuilder()
+        .extension(new EmbeddedElasticSearchExtension())
+        .extension(new CassandraExtension())
+        .extension(new RabbitMQExtension())
+        .extension(new SwiftBlobStoreExtension())
+        .extension(spamAssassinExtension)
+        .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+            .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
+            .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
+            .overrideWith(binder -> binder.bind(BlobStoreChoosingConfiguration.class)
+                .toInstance(BlobStoreChoosingConfiguration.objectStorage()))
+            .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES)))
+        .build();
+
+    @Override
+    public SpamAssassinExtension.SpamAssassin spamAssassin() {
+        return spamAssassinExtension.spamAssassinExtension().getSpamAssassin();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/9dd5640f/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
----------------------------------------------------------------------
diff --git a/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java b/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
index e357228..6a3d876 100644
--- a/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
+++ b/third-party/spamassassin/src/test/java/org/apache/james/spamassassin/SpamAssassinExtension.java
@@ -26,6 +26,7 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.Duration;
 import java.util.Locale;
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import org.junit.jupiter.api.extension.AfterAllCallback;
@@ -54,7 +55,8 @@ public class SpamAssassinExtension implements BeforeAllCallback, AfterEachCallba
                 .withFileFromClasspath("run.sh", "docker/spamassassin/run.sh")
                 .withFileFromClasspath("spamd.sh", "docker/spamassassin/spamd.sh")
                 .withFileFromClasspath("rule-update.sh", "docker/spamassassin/rule-update.sh")
-                .withFileFromClasspath("bayes_pg.sql", "docker/spamassassin/bayes_pg.sql"));
+                .withFileFromClasspath("bayes_pg.sql", "docker/spamassassin/bayes_pg.sql"))
+            .withCreateContainerCmdModifier(cmd -> cmd.withName(containerName()));
         spamAssassinContainer.withStartupTimeout(STARTUP_TIMEOUT);
         spamAssassinContainer.waitingFor(new SpamAssassinWaitStrategy(spamAssassinContainer, STARTUP_TIMEOUT));
     }
@@ -97,6 +99,10 @@ public class SpamAssassinExtension implements BeforeAllCallback, AfterEachCallba
         return spamAssassin;
     }
 
+    private String containerName() {
+        return "spam-assassin-" + UUID.randomUUID().toString();
+    }
+
     public static class SpamAssassin {
         
         private static final int SPAMASSASSIN_PORT = 783;


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message