http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
----------------------------------------------------------------------
diff --git 
a/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
 
b/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
deleted file mode 100644
index bd7d053..0000000
--- 
a/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
+++ /dev/null
@@ -1,145 +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.imap.encode;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.james.imap.api.ImapSessionState;
-import org.apache.james.imap.api.process.ImapLineHandler;
-import org.apache.james.imap.api.process.ImapSession;
-import org.apache.james.imap.api.process.SelectedMailbox;
-
-public class FakeImapSession implements ImapSession {
-
-    private ImapSessionState state = ImapSessionState.NON_AUTHENTICATED;
-
-    private SelectedMailbox selectedMailbox = null;
-
-    private final Map<String, Object> attributesByKey;
-
-    public FakeImapSession() {
-        this.attributesByKey = new ConcurrentHashMap<>();
-    }
-
-    @Override
-    public void logout() {
-        closeMailbox();
-        state = ImapSessionState.LOGOUT;
-    }
-
-    @Override
-    public void authenticated() {
-        this.state = ImapSessionState.AUTHENTICATED;
-    }
-
-    @Override
-    public void deselect() {
-        this.state = ImapSessionState.AUTHENTICATED;
-        closeMailbox();
-    }
-
-    @Override
-    public void selected(SelectedMailbox mailbox) {
-        this.state = ImapSessionState.SELECTED;
-        closeMailbox();
-        this.selectedMailbox = mailbox;
-    }
-
-    @Override
-    public SelectedMailbox getSelected() {
-        return this.selectedMailbox;
-    }
-
-    @Override
-    public ImapSessionState getState() {
-        return this.state;
-    }
-
-    public void closeMailbox() {
-        if (selectedMailbox != null) {
-            selectedMailbox.deselect();
-            selectedMailbox = null;
-        }
-    }
-
-    @Override
-    public Object getAttribute(String key) {
-        return attributesByKey.get(key);
-    }
-
-    @Override
-    public void setAttribute(String key, Object value) {
-        if (value == null) {
-            attributesByKey.remove(key);
-        } else {
-            attributesByKey.put(key, value);
-        }
-    }
-    
-    @Override
-    public boolean startTLS() {
-        return false;
-    }
-
-    @Override
-    public boolean supportStartTLS() {
-        return false;
-    }
-
-    @Override
-    public boolean isCompressionSupported() {
-        return false;
-    }
-
-    @Override
-    public boolean startCompression() {
-        return false;
-    }
-
-    @Override
-    public void pushLineHandler(ImapLineHandler lineHandler) {
-    }
-
-    @Override
-    public void popLineHandler() {
-        
-    }
-
-    @Override
-    public boolean isPlainAuthDisallowed() {
-        return false;
-    }
-
-    @Override
-    public boolean isTLSActive() {
-        return false;
-    }
-
-    @Override
-    public boolean supportMultipleNamespaces() {
-        return false;
-    }
-
-    @Override
-    public boolean isCompressionActive() {
-        return false;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/container/core/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/core/pom.xml b/server/container/core/pom.xml
index 6f64917..ef1d3d3 100644
--- a/server/container/core/pom.xml
+++ b/server/container/core/pom.xml
@@ -49,8 +49,7 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <classifier>tests</classifier>
+            <artifactId>apache-mailet-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/container/metrics/metrics-es-reporter/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/pom.xml 
b/server/container/metrics/metrics-es-reporter/pom.xml
index dc3d11d..89b5e4a 100644
--- a/server/container/metrics/metrics-es-reporter/pom.xml
+++ b/server/container/metrics/metrics-es-reporter/pom.xml
@@ -40,8 +40,7 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-util-java8</artifactId>
-            <type>test-jar</type>
+            <artifactId>james-server-testing</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/container/util-java8/src/test/java/org/apache/james/util/docker/Images.java
----------------------------------------------------------------------
diff --git 
a/server/container/util-java8/src/test/java/org/apache/james/util/docker/Images.java
 
b/server/container/util-java8/src/test/java/org/apache/james/util/docker/Images.java
deleted file mode 100644
index c252f1a..0000000
--- 
a/server/container/util-java8/src/test/java/org/apache/james/util/docker/Images.java
+++ /dev/null
@@ -1,29 +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.util.docker;
-
-public interface Images {
-    String FAKE_SMTP = "weave/rest-smtp-sink:latest";
-    String RABBITMQ = "rabbitmq:3.7.7";
-    String ELASTICSEARCH = "elasticsearch:2.4.6";
-    String NGINX = "nginx:1.15.1";
-    String TIKA = "linagora/docker-tikaserver:1.18-SNAPSHOT-plus-TIKA-2520";
-    String SPAMASSASSIN = "dinkel/spamassassin:3.4.0";
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/container/util-java8/src/test/java/org/apache/james/util/docker/SwarmGenericContainer.java
----------------------------------------------------------------------
diff --git 
a/server/container/util-java8/src/test/java/org/apache/james/util/docker/SwarmGenericContainer.java
 
b/server/container/util-java8/src/test/java/org/apache/james/util/docker/SwarmGenericContainer.java
deleted file mode 100644
index 59488c0..0000000
--- 
a/server/container/util-java8/src/test/java/org/apache/james/util/docker/SwarmGenericContainer.java
+++ /dev/null
@@ -1,164 +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.util.docker;
-
-import java.net.Socket;
-import java.time.Duration;
-import java.util.List;
-
-import javax.net.SocketFactory;
-
-import org.junit.Assume;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.WaitStrategy;
-import org.testcontainers.images.builder.ImageFromDockerfile;
-import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import com.google.common.base.Strings;
-
-public class SwarmGenericContainer implements TestRule {
-    private static final Logger LOGGER = 
LoggerFactory.getLogger(SwarmGenericContainer.class);
-    private static final String DOCKER_CONTAINER = "DOCKER_CONTAINER";
-    private static final String NO_DOCKER_ENVIRONMENT = "Could not find a 
valid Docker environment.";
-    private static final String SKIPPING_TEST_CAUTION = "Skipping all docker 
tests as no Docker environment was found";
-
-    private GenericContainer<?> container;
-
-    public SwarmGenericContainer(String dockerImageName) {
-        try {
-            this.container = new GenericContainer<>(dockerImageName);
-        } catch (IllegalStateException e) {
-            logAndCheckSkipTest(e);
-        }
-    }
-
-    public SwarmGenericContainer(ImageFromDockerfile imageFromDockerfile) {
-        try {
-            this.container = new GenericContainer<>(imageFromDockerfile);
-        } catch (IllegalStateException e) {
-            logAndCheckSkipTest(e);
-        }
-    }
-    
-    private void logAndCheckSkipTest(IllegalStateException e) {
-        LOGGER.error("Cannot initial a docker container", e);
-        if (e.getMessage().startsWith(NO_DOCKER_ENVIRONMENT)) {
-            Assume.assumeTrue(SKIPPING_TEST_CAUTION, false);
-        }
-    }
-
-    public SwarmGenericContainer withAffinityToContainer() {
-        String containerEnv = System.getenv(DOCKER_CONTAINER);
-        if (Strings.isNullOrEmpty(containerEnv)) {
-            LOGGER.warn("'DOCKER_CONTAINER' environment variable not found, 
dockering without affinity");
-            return this;
-        }
-        List<String> envVariables = container.getEnv();
-        envVariables.add("affinity:container==" + container);
-        container.setEnv(envVariables);
-        return this;
-    }
-
-    public SwarmGenericContainer withEnv(String key, String value) {
-        container.addEnv(key, value);
-        return this;
-    }
-
-    public SwarmGenericContainer withExposedPorts(Integer... ports) {
-        container.withExposedPorts(ports);
-        return this;
-    }
-
-    public SwarmGenericContainer portBinding(int hostPort, int dockerPort) {
-        container.setPortBindings(ImmutableList.of("0.0.0.0:" + hostPort + ":" 
+ dockerPort));
-        return this;
-    }
-
-    public SwarmGenericContainer waitingFor(WaitStrategy waitStrategy) {
-        container.waitingFor(waitStrategy);
-        return this;
-    }
-
-    public SwarmGenericContainer withStartupTimeout(Duration startupTimeout) {
-        container.withStartupTimeout(startupTimeout);
-        return this;
-    }
-
-    public SwarmGenericContainer withCommands(String... commands) {
-        container.withCommand(commands);
-        return this;
-    }
-
-    public void start() {
-        container.start();
-    }
-
-    public void stop() {
-        container.stop();
-    }
-
-    public void pause() {
-        
DockerClientFactory.instance().client().pauseContainerCmd(container.getContainerInfo().getId());
-    }
-
-    public void unpause() {
-        
DockerClientFactory.instance().client().unpauseContainerCmd(container.getContainerInfo().getId());
-    }
-
-    public Integer getMappedPort(int originalPort) {
-        return container.getMappedPort(originalPort);
-    }
-
-    @SuppressWarnings("deprecation")
-    public String getContainerIp() {
-        return 
container.getContainerInfo().getNetworkSettings().getIpAddress();
-    }
-    
-    public String getHostIp() {
-        return container.getContainerIpAddress();
-    }
-
-    public InspectContainerResponse getContainerInfo() {
-        return container.getContainerInfo();
-    }
-
-    public boolean tryConnect(int port) {
-        try {
-            Socket socket = 
SocketFactory.getDefault().createSocket(getContainerIp(), port);
-            socket.close();
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-    @Override
-    public Statement apply(Statement statement, Description description) {
-        return container.apply(statement, description);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/container/util/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/util/pom.xml b/server/container/util/pom.xml
index fadfca7..a7af883 100644
--- a/server/container/util/pom.xml
+++ b/server/container/util/pom.xml
@@ -38,6 +38,10 @@
             <artifactId>guava</artifactId>
         </dependency>
         <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+        </dependency>
+        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
@@ -46,6 +50,11 @@
             <artifactId>commons-lang3</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
             <scope>test</scope>
@@ -61,11 +70,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.assertj</groupId>
-            <artifactId>assertj-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/container/util/src/main/java/org/apache/james/util/MimeMessageUtil.java
----------------------------------------------------------------------
diff --git 
a/server/container/util/src/main/java/org/apache/james/util/MimeMessageUtil.java
 
b/server/container/util/src/main/java/org/apache/james/util/MimeMessageUtil.java
new file mode 100644
index 0000000..93715f8
--- /dev/null
+++ 
b/server/container/util/src/main/java/org/apache/james/util/MimeMessageUtil.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+public class MimeMessageUtil {
+
+    public static String asString(MimeMessage mimeMessage) throws Exception {
+        ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();
+        mimeMessage.writeTo(byteArrayOutputStream);
+        return new String(byteArrayOutputStream.toByteArray(), 
StandardCharsets.UTF_8);
+    }
+
+    public static MimeMessage defaultMimeMessage() {
+        return new MimeMessage(Session.getDefaultInstance(new Properties()));
+    }
+
+    public static MimeMessage mimeMessageFromStream(InputStream inputStream) 
throws MessagingException {
+        return new MimeMessage(Session.getDefaultInstance(new Properties()), 
inputStream);
+    }
+
+    public static MimeMessage mimeMessageFromBytes(byte[] bytes) throws 
MessagingException {
+        return mimeMessageFromStream(new ByteArrayInputStream(bytes));
+    }
+
+    public static MimeMessage mimeMessageFromString(String string) throws 
MessagingException {
+        return mimeMessageFromBytes(string.getBytes(StandardCharsets.UTF_8));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/data/data-ldap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/pom.xml 
b/server/data/data-ldap-integration-testing/pom.xml
index 63617e3..4b5919c 100644
--- a/server/data/data-ldap-integration-testing/pom.xml
+++ b/server/data/data-ldap-integration-testing/pom.xml
@@ -45,8 +45,7 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-util-java8</artifactId>
-            <type>test-jar</type>
+            <artifactId>james-server-testing</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/mailet/integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/pom.xml 
b/server/mailet/integration-testing/pom.xml
index 3670525..0af81e4 100644
--- a/server/mailet/integration-testing/pom.xml
+++ b/server/mailet/integration-testing/pom.xml
@@ -35,8 +35,7 @@
     <dependencies>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <type>test-jar</type>
+            <artifactId>apache-mailet-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index b1b61e3..21c6e8a 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -53,7 +53,6 @@
         <module>container/metrics/metrics-es-reporter</module>
         <module>container/spring</module>
         <module>container/util</module>
-        <module>container/util-java8</module>
 
         <module>data/data-api</module>
         <module>data/data-cassandra</module>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/protocols/jmap/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/pom.xml b/server/protocols/jmap/pom.xml
index 31e1ec8..f8eebce 100644
--- a/server/protocols/jmap/pom.xml
+++ b/server/protocols/jmap/pom.xml
@@ -65,8 +65,7 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <type>test-jar</type>
+            <artifactId>apache-mailet-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/protocols/webadmin/webadmin-mailqueue/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailqueue/pom.xml 
b/server/protocols/webadmin/webadmin-mailqueue/pom.xml
index 032fba8..5964a75 100644
--- a/server/protocols/webadmin/webadmin-mailqueue/pom.xml
+++ b/server/protocols/webadmin/webadmin-mailqueue/pom.xml
@@ -35,8 +35,7 @@
     <dependencies>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <type>test-jar</type>
+            <artifactId>apache-mailet-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/protocols/webadmin/webadmin-mailrepository/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailrepository/pom.xml 
b/server/protocols/webadmin/webadmin-mailrepository/pom.xml
index 2e27115..abc9d2f 100644
--- a/server/protocols/webadmin/webadmin-mailrepository/pom.xml
+++ b/server/protocols/webadmin/webadmin-mailrepository/pom.xml
@@ -35,8 +35,7 @@
     <dependencies>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <type>test-jar</type>
+            <artifactId>apache-mailet-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/queue/queue-rabbitmq/pom.xml
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/pom.xml 
b/server/queue/queue-rabbitmq/pom.xml
index 3f7e708..7244a13 100644
--- a/server/queue/queue-rabbitmq/pom.xml
+++ b/server/queue/queue-rabbitmq/pom.xml
@@ -40,8 +40,7 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-util-java8</artifactId>
-            <type>test-jar</type>
+            <artifactId>james-server-testing</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/testing/pom.xml b/server/testing/pom.xml
index 50623d2..c689d7b 100644
--- a/server/testing/pom.xml
+++ b/server/testing/pom.xml
@@ -37,8 +37,7 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <type>test-jar</type>
+            <artifactId>apache-mailet-test</artifactId>
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/testing/src/main/java/org/apache/james/util/docker/Images.java
----------------------------------------------------------------------
diff --git 
a/server/testing/src/main/java/org/apache/james/util/docker/Images.java 
b/server/testing/src/main/java/org/apache/james/util/docker/Images.java
new file mode 100644
index 0000000..c252f1a
--- /dev/null
+++ b/server/testing/src/main/java/org/apache/james/util/docker/Images.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.util.docker;
+
+public interface Images {
+    String FAKE_SMTP = "weave/rest-smtp-sink:latest";
+    String RABBITMQ = "rabbitmq:3.7.7";
+    String ELASTICSEARCH = "elasticsearch:2.4.6";
+    String NGINX = "nginx:1.15.1";
+    String TIKA = "linagora/docker-tikaserver:1.18-SNAPSHOT-plus-TIKA-2520";
+    String SPAMASSASSIN = "dinkel/spamassassin:3.4.0";
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/server/testing/src/main/java/org/apache/james/util/docker/SwarmGenericContainer.java
----------------------------------------------------------------------
diff --git 
a/server/testing/src/main/java/org/apache/james/util/docker/SwarmGenericContainer.java
 
b/server/testing/src/main/java/org/apache/james/util/docker/SwarmGenericContainer.java
new file mode 100644
index 0000000..59488c0
--- /dev/null
+++ 
b/server/testing/src/main/java/org/apache/james/util/docker/SwarmGenericContainer.java
@@ -0,0 +1,164 @@
+/****************************************************************
+ * 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.util.docker;
+
+import java.net.Socket;
+import java.time.Duration;
+import java.util.List;
+
+import javax.net.SocketFactory;
+
+import org.junit.Assume;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.WaitStrategy;
+import org.testcontainers.images.builder.ImageFromDockerfile;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
+
+import com.github.dockerjava.api.command.InspectContainerResponse;
+import com.google.common.base.Strings;
+
+public class SwarmGenericContainer implements TestRule {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(SwarmGenericContainer.class);
+    private static final String DOCKER_CONTAINER = "DOCKER_CONTAINER";
+    private static final String NO_DOCKER_ENVIRONMENT = "Could not find a 
valid Docker environment.";
+    private static final String SKIPPING_TEST_CAUTION = "Skipping all docker 
tests as no Docker environment was found";
+
+    private GenericContainer<?> container;
+
+    public SwarmGenericContainer(String dockerImageName) {
+        try {
+            this.container = new GenericContainer<>(dockerImageName);
+        } catch (IllegalStateException e) {
+            logAndCheckSkipTest(e);
+        }
+    }
+
+    public SwarmGenericContainer(ImageFromDockerfile imageFromDockerfile) {
+        try {
+            this.container = new GenericContainer<>(imageFromDockerfile);
+        } catch (IllegalStateException e) {
+            logAndCheckSkipTest(e);
+        }
+    }
+    
+    private void logAndCheckSkipTest(IllegalStateException e) {
+        LOGGER.error("Cannot initial a docker container", e);
+        if (e.getMessage().startsWith(NO_DOCKER_ENVIRONMENT)) {
+            Assume.assumeTrue(SKIPPING_TEST_CAUTION, false);
+        }
+    }
+
+    public SwarmGenericContainer withAffinityToContainer() {
+        String containerEnv = System.getenv(DOCKER_CONTAINER);
+        if (Strings.isNullOrEmpty(containerEnv)) {
+            LOGGER.warn("'DOCKER_CONTAINER' environment variable not found, 
dockering without affinity");
+            return this;
+        }
+        List<String> envVariables = container.getEnv();
+        envVariables.add("affinity:container==" + container);
+        container.setEnv(envVariables);
+        return this;
+    }
+
+    public SwarmGenericContainer withEnv(String key, String value) {
+        container.addEnv(key, value);
+        return this;
+    }
+
+    public SwarmGenericContainer withExposedPorts(Integer... ports) {
+        container.withExposedPorts(ports);
+        return this;
+    }
+
+    public SwarmGenericContainer portBinding(int hostPort, int dockerPort) {
+        container.setPortBindings(ImmutableList.of("0.0.0.0:" + hostPort + ":" 
+ dockerPort));
+        return this;
+    }
+
+    public SwarmGenericContainer waitingFor(WaitStrategy waitStrategy) {
+        container.waitingFor(waitStrategy);
+        return this;
+    }
+
+    public SwarmGenericContainer withStartupTimeout(Duration startupTimeout) {
+        container.withStartupTimeout(startupTimeout);
+        return this;
+    }
+
+    public SwarmGenericContainer withCommands(String... commands) {
+        container.withCommand(commands);
+        return this;
+    }
+
+    public void start() {
+        container.start();
+    }
+
+    public void stop() {
+        container.stop();
+    }
+
+    public void pause() {
+        
DockerClientFactory.instance().client().pauseContainerCmd(container.getContainerInfo().getId());
+    }
+
+    public void unpause() {
+        
DockerClientFactory.instance().client().unpauseContainerCmd(container.getContainerInfo().getId());
+    }
+
+    public Integer getMappedPort(int originalPort) {
+        return container.getMappedPort(originalPort);
+    }
+
+    @SuppressWarnings("deprecation")
+    public String getContainerIp() {
+        return 
container.getContainerInfo().getNetworkSettings().getIpAddress();
+    }
+    
+    public String getHostIp() {
+        return container.getContainerIpAddress();
+    }
+
+    public InspectContainerResponse getContainerInfo() {
+        return container.getContainerInfo();
+    }
+
+    public boolean tryConnect(int port) {
+        try {
+            Socket socket = 
SocketFactory.getDefault().createSocket(getContainerIp(), port);
+            socket.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    @Override
+    public Statement apply(Statement statement, Description description) {
+        return container.apply(statement, description);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/3dddd7c5/third-party/spamassassin/pom.xml
----------------------------------------------------------------------
diff --git a/third-party/spamassassin/pom.xml b/third-party/spamassassin/pom.xml
index 4b1da22..9b1c7a6 100644
--- a/third-party/spamassassin/pom.xml
+++ b/third-party/spamassassin/pom.xml
@@ -31,6 +31,11 @@
     <dependencies>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>javax-mail-extension</artifactId>
             <type>test-jar</type>
             <scope>test</scope>


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

Reply via email to