You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2020/12/07 03:57:31 UTC

[james-project] 01/13: JAMES-2543 updgrades MPT impl smtp to junit 5

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b44a5ed3fe28e8a4e7f1fae7835c394ce1a98a40
Author: Jean Helou <jh...@codamens.fr>
AuthorDate: Mon Nov 30 21:59:40 2020 +0100

    JAMES-2543 updgrades MPT impl smtp to junit 5
---
 .../mpt/smtp/AwsS3RabbitMQForwardSmtpTest.java     |  32 ++--
 .../smtp/AwsS3RabbitMQSmtpStarttlsCommandTest.java |  29 ++--
 .../CassandraRabbitMQAwsS3SmtpTestRuleFactory.java |  21 ++-
 .../james/mpt/smtp/CassandraForwardSmtpTest.java   |  26 +++-
 .../mpt/smtp/CassandraSmtpStarttlsCommandTest.java |  18 +--
 .../mpt/smtp/CassandraSmtpTestRuleFactory.java     |  15 +-
 .../org/apache/james/mpt/smtp/ForwardSmtpTest.java |  50 +++---
 .../apache/james/mpt/smtp/SmtpAuthCommandTest.java |   5 -
 .../james/mpt/smtp/SmtpStarttlsCommandTest.java    |  29 ++--
 .../apache/james/mpt/smtp/SmtpTestExtension.java   | 159 +++++++++++++++++++
 .../org/apache/james/mpt/smtp/SmtpTestRule.java    | 137 -----------------
 server/testing/pom.xml                             |   4 +
 .../org/apache/james/utils/FakeSmtpExtension.java  | 168 +++++++++++++++++++++
 13 files changed, 443 insertions(+), 250 deletions(-)

diff --git a/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQForwardSmtpTest.java b/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQForwardSmtpTest.java
index 85b659d..f6621a9 100644
--- a/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQForwardSmtpTest.java
+++ b/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQForwardSmtpTest.java
@@ -21,27 +21,41 @@ package org.apache.james.mpt.smtp;
 
 import static org.apache.james.modules.protocols.SmtpGuiceProbe.SmtpServerConnectedType.SMTP_GLOBAL_SERVER;
 
+import org.apache.james.backends.cassandra.DockerCassandraExtension;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.blob.objectstorage.aws.DockerAwsS3Container;
+import org.apache.james.blob.objectstorage.aws.DockerAwsS3Extension;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
 import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
 import org.junit.Rule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
 
-public class AwsS3RabbitMQForwardSmtpTest extends ForwardSmtpTest {
+public class AwsS3RabbitMQForwardSmtpTest implements ForwardSmtpTest {
 
-    @Rule public DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    @RegisterExtension
+    public static DockerCassandraExtension cassandraServer = new DockerCassandraExtension();
 
-    private DockerAwsS3TestRule dockerAwsS3TestRule = new DockerAwsS3TestRule();
+    @RegisterExtension
+    public AwsS3BlobStoreExtension dockerAwsS3TestRule = new AwsS3BlobStoreExtension();
 
-    private SmtpTestRule cassandraRabbitMQAwsS3SmtpTestRule =
-        CassandraRabbitMQAwsS3SmtpTestRuleFactory.create(SMTP_GLOBAL_SERVER, cassandraServer.getHost(), dockerAwsS3TestRule);
+    @RegisterExtension
+    public SmtpTestExtension cassandraRabbitMQAwsS3SmtpTestRule =
+            CassandraRabbitMQAwsS3SmtpTestRuleFactory.createExtension(SMTP_GLOBAL_SERVER, () -> cassandraServer.getDockerCassandra().getHost(), dockerAwsS3TestRule);
+
+    private SmtpHostSystem hostSystem;
+
+    @BeforeEach
+    void setup(SmtpHostSystem hostSystem) {
+        this.hostSystem = hostSystem;
+    }
 
-    @Rule
-    public TestRule composedRule = RuleChain.outerRule(dockerAwsS3TestRule).around(cassandraRabbitMQAwsS3SmtpTestRule);
 
     @Override
-    protected SmtpHostSystem createSmtpHostSystem() {
-        return cassandraRabbitMQAwsS3SmtpTestRule;
+    public SmtpHostSystem hostSystem() {
+        return hostSystem;
     }
 
 }
diff --git a/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQSmtpStarttlsCommandTest.java b/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQSmtpStarttlsCommandTest.java
index f3e31ab..d06d958 100644
--- a/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQSmtpStarttlsCommandTest.java
+++ b/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/AwsS3RabbitMQSmtpStarttlsCommandTest.java
@@ -21,28 +21,19 @@ package org.apache.james.mpt.smtp;
 
 import static org.apache.james.modules.protocols.SmtpGuiceProbe.SmtpServerConnectedType.SMTP_START_TLS_SERVER;
 
-import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
-import org.junit.Rule;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestRule;
+import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 public class AwsS3RabbitMQSmtpStarttlsCommandTest extends SmtpStarttlsCommandTest {
 
-    @Rule public DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    @RegisterExtension
+    public static DockerCassandraExtension cassandraServer = new DockerCassandraExtension();
 
+    @RegisterExtension
+    public AwsS3BlobStoreExtension dockerAwsS3TestRule = new AwsS3BlobStoreExtension();
 
-    private DockerAwsS3TestRule dockerAwsS3TestRule = new DockerAwsS3TestRule();
-
-    private SmtpTestRule cassandraRabbitMQAwsS3SmtpTestRule =
-        CassandraRabbitMQAwsS3SmtpTestRuleFactory.create(SMTP_START_TLS_SERVER, cassandraServer.getHost(), dockerAwsS3TestRule);
-
-    @Rule
-    public TestRule composedRule = RuleChain.outerRule(dockerAwsS3TestRule).around(cassandraRabbitMQAwsS3SmtpTestRule);
-
-    @Override
-    protected SmtpHostSystem createSmtpHostSystem() {
-        return cassandraRabbitMQAwsS3SmtpTestRule;
-    }
-
+    @RegisterExtension
+    public SmtpTestExtension cassandraRabbitMQAwsS3SmtpTestRule =
+            CassandraRabbitMQAwsS3SmtpTestRuleFactory.createExtension(SMTP_START_TLS_SERVER, () -> cassandraServer.getDockerCassandra().getHost(), dockerAwsS3TestRule);
 }
diff --git a/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/CassandraRabbitMQAwsS3SmtpTestRuleFactory.java b/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/CassandraRabbitMQAwsS3SmtpTestRuleFactory.java
index bb0bf7c..bd625dd 100644
--- a/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/CassandraRabbitMQAwsS3SmtpTestRuleFactory.java
+++ b/mpt/impl/smtp/cassandra-rabbitmq-object-storage/src/test/java/org/apache/james/mpt/smtp/CassandraRabbitMQAwsS3SmtpTestRuleFactory.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.mpt.smtp;
 
+import java.util.function.Supplier;
+
 import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
 import org.apache.james.CassandraJamesServerMain;
 import org.apache.james.CleanupTasksPerformer;
@@ -30,10 +32,10 @@ import org.apache.james.blob.api.BlobStoreDAO;
 import org.apache.james.blob.api.MetricableBlobStore;
 import org.apache.james.blob.objectstorage.aws.S3BlobStoreDAO;
 import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
 import org.apache.james.modules.TestRabbitMQModule;
 import org.apache.james.modules.mailbox.KeyspacesConfiguration;
 import org.apache.james.modules.objectstorage.DefaultBucketModule;
-import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
 import org.apache.james.modules.protocols.SmtpGuiceProbe.SmtpServerConnectedType;
 import org.apache.james.modules.queue.rabbitmq.RabbitMQModule;
 import org.apache.james.modules.server.CamelMailetContainerModule;
@@ -49,12 +51,13 @@ import com.google.inject.Module;
 import com.google.inject.name.Names;
 
 public final class CassandraRabbitMQAwsS3SmtpTestRuleFactory {
-    public static SmtpTestRule create(SmtpServerConnectedType smtpServerConnectedType, Host cassandraHost, DockerAwsS3TestRule awsS3TestRule) {
-        SmtpTestRule.ServerBuilder createJamesServer = (folder, dnsService) -> createJamesServer(cassandraHost, awsS3TestRule, folder, dnsService);
+    public static SmtpTestExtension createExtension(SmtpServerConnectedType smtpGlobalServer, Supplier<Host> host, AwsS3BlobStoreExtension dockerAwsS3TestRule) {
+        SmtpTestExtension.ServerBuilder createJamesServer = (folder, dnsService) -> createJamesServer(host, dockerAwsS3TestRule.getModule(), folder, dnsService);
 
-        return new SmtpTestRule(smtpServerConnectedType, createJamesServer);
+        return new SmtpTestExtension(smtpGlobalServer, createJamesServer);
     }
 
+
     private static Module BLOB_STORE_MODULE = new AbstractModule() {
         @Override
         protected void configure() {
@@ -65,23 +68,24 @@ public final class CassandraRabbitMQAwsS3SmtpTestRuleFactory {
         }
     };
 
-    private static GuiceJamesServer createJamesServer(Host cassandraHost, DockerAwsS3TestRule awsS3TestRule, TemporaryFolder folder, DNSService dnsService) throws Exception {
+    private static GuiceJamesServer createJamesServer(Supplier<Host> cassandraHost, Module awsS3Module , TemporaryFolder folder, DNSService dnsService) throws Exception {
         Configuration configuration = Configuration.builder()
             .workingDirectory(folder.newFolder())
             .configurationFromClasspath()
             .build();
 
+
         return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(CassandraJamesServerMain.CASSANDRA_SERVER_CORE_MODULE,
                 new DefaultBucketModule(),
-                SmtpTestRule.SMTP_PROTOCOL_MODULE,
+                SmtpTestExtension.SMTP_PROTOCOL_MODULE,
                 binder -> binder.bind(MailQueueItemDecoratorFactory.class).to(RawMailQueueItemDecoratorFactory.class),
                 binder -> binder.bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
                     .toInstance(BaseHierarchicalConfiguration::new))
             .overrideWith(new RabbitMQModule(), BLOB_STORE_MODULE)
             .overrideWith(
                 new TestRabbitMQModule(DockerRabbitMQSingleton.SINGLETON),
-                awsS3TestRule.getModule(),
+                    awsS3Module,
                 binder -> binder.bind(KeyspacesConfiguration.class)
                     .toInstance(KeyspacesConfiguration.builder()
                         .keyspace(DockerCassandra.KEYSPACE)
@@ -90,10 +94,11 @@ public final class CassandraRabbitMQAwsS3SmtpTestRuleFactory {
                         .disableDurableWrites()
                         .build()),
                 binder -> binder.bind(ClusterConfiguration.class).toInstance(
-                    DockerCassandra.configurationBuilder(cassandraHost)
+                    DockerCassandra.configurationBuilder(cassandraHost.get())
                         .build()),
                 binder -> binder.bind(DNSService.class).toInstance(dnsService),
                 binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton());
     }
+
 }
 
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
index 21c8992..e2c8cdb 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
@@ -21,19 +21,29 @@ package org.apache.james.mpt.smtp;
 
 import static org.apache.james.modules.protocols.SmtpGuiceProbe.SmtpServerConnectedType.SMTP_GLOBAL_SERVER;
 
-import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.junit.Rule;
+import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class CassandraForwardSmtpTest extends ForwardSmtpTest {
+public class CassandraForwardSmtpTest implements ForwardSmtpTest {
 
-    @Rule public DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    @RegisterExtension
+    public static DockerCassandraExtension cassandraServer = new DockerCassandraExtension();
 
-    @Rule
-    public SmtpTestRule cassandraSmtpTestRule = CassandraSmtpTestRuleFactory.create(SMTP_GLOBAL_SERVER, cassandraServer.getHost());
+    @RegisterExtension
+    public SmtpTestExtension smtpTestExtension =
+            CassandraSmtpTestRuleFactory.createExtension(SMTP_GLOBAL_SERVER, () -> cassandraServer.getDockerCassandra().getHost());
+
+    private SmtpHostSystem hostSystem;
+
+    @BeforeEach
+    void setup(SmtpHostSystem hostSystem) {
+        this.hostSystem = hostSystem;
+    }
 
     @Override
-    protected SmtpHostSystem createSmtpHostSystem() {
-        return cassandraSmtpTestRule;
+    public SmtpHostSystem hostSystem() {
+        return hostSystem;
     }
 
 }
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
index d7d1209..511a2ba 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
@@ -21,20 +21,16 @@ package org.apache.james.mpt.smtp;
 
 import static org.apache.james.modules.protocols.SmtpGuiceProbe.SmtpServerConnectedType.SMTP_START_TLS_SERVER;
 
-import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.junit.Rule;
+import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 public class CassandraSmtpStarttlsCommandTest extends SmtpStarttlsCommandTest {
 
-    @Rule public DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    @Rule
-    public SmtpTestRule cassandraSmtpTestRule = CassandraSmtpTestRuleFactory.create(SMTP_START_TLS_SERVER, cassandraServer.getHost());
-
-    @Override
-    protected SmtpHostSystem createSmtpHostSystem() {
-        return cassandraSmtpTestRule;
-    }
+    @RegisterExtension
+    public static DockerCassandraExtension cassandraServer = new DockerCassandraExtension();
 
+    @RegisterExtension
+    public SmtpTestExtension smtpTestExtension =
+            CassandraSmtpTestRuleFactory.createExtension(SMTP_START_TLS_SERVER, () -> cassandraServer.getDockerCassandra().getHost());
 
 }
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpTestRuleFactory.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpTestRuleFactory.java
index cddc8dd..a5a5954 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpTestRuleFactory.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpTestRuleFactory.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.mpt.smtp;
 
+import java.util.function.Supplier;
+
 import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
 import org.apache.james.CassandraJamesServerMain;
 import org.apache.james.GuiceJamesServer;
@@ -36,13 +38,14 @@ import org.apache.james.util.Host;
 import org.junit.rules.TemporaryFolder;
 
 public final class CassandraSmtpTestRuleFactory {
-    public static SmtpTestRule create(SmtpServerConnectedType smtpServerConnectedType, Host cassandraHost) {
-        SmtpTestRule.ServerBuilder createJamesServer = (folder, dnsService) -> createJamesServer(cassandraHost, folder, dnsService);
 
-        return new SmtpTestRule(smtpServerConnectedType, createJamesServer);
+    public static SmtpTestExtension createExtension(SmtpServerConnectedType smtpServerConnectedType, Supplier<Host> cassandraHost) {
+        SmtpTestExtension.ServerBuilder createJamesServer = (folder, dnsService) -> createJamesServer(cassandraHost, folder, dnsService);
+
+        return new SmtpTestExtension(smtpServerConnectedType, createJamesServer);
     }
 
-    private static GuiceJamesServer createJamesServer(Host cassandraHost, TemporaryFolder folder, DNSService dnsService) throws Exception {
+    private static GuiceJamesServer createJamesServer(Supplier<Host> cassandraHost, TemporaryFolder folder, DNSService dnsService) throws Exception {
         Configuration configuration = Configuration.builder()
             .workingDirectory(folder.newFolder())
             .configurationFromClasspath()
@@ -52,13 +55,13 @@ public final class CassandraSmtpTestRuleFactory {
             .combineWith(CassandraJamesServerMain.CASSANDRA_SERVER_CORE_MODULE,
                 new CassandraBlobStoreModule(),
                 new CassandraBucketModule(),
-                SmtpTestRule.SMTP_PROTOCOL_MODULE,
+                SmtpTestExtension.SMTP_PROTOCOL_MODULE,
                 binder -> binder.bind(MailQueueItemDecoratorFactory.class).to(RawMailQueueItemDecoratorFactory.class),
                 binder -> binder.bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
                     .toInstance(BaseHierarchicalConfiguration::new))
             .overrideWith(
                 binder -> binder.bind(ClusterConfiguration.class).toInstance(
-                    DockerCassandra.configurationBuilder(cassandraHost)
+                    DockerCassandra.configurationBuilder(cassandraHost.get())
                         .build()),
                 binder -> binder.bind(KeyspacesConfiguration.class)
                     .toInstance(KeyspacesConfiguration.builder()
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
index b885f7a..8092e07 100644
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
@@ -25,48 +25,40 @@ import static org.hamcrest.Matchers.equalTo;
 import java.util.Locale;
 
 import org.apache.james.mpt.script.SimpleScriptedTestProtocol;
-import org.apache.james.utils.FakeSmtp;
+import org.apache.james.utils.FakeSmtpExtension;
 import org.awaitility.Awaitility;
 import org.awaitility.Duration;
 import org.awaitility.core.ConditionFactory;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public abstract class ForwardSmtpTest {
 
-    public static final String USER = "bob";
-    public static final String DOMAIN = "mydomain.tld";
-    public static final String USER_AT_DOMAIN = USER + "@" + DOMAIN;
-    public static final String PASSWORD = "secret";
-    public static final Duration slowPacedPollInterval = ONE_HUNDRED_MILLISECONDS;
-    public static final ConditionFactory calmlyAwait = Awaitility.with()
+public interface ForwardSmtpTest {
+
+    String USER = "bob";
+    String DOMAIN = "mydomain.tld";
+    String USER_AT_DOMAIN = USER + "@" + DOMAIN;
+    String PASSWORD = "secret";
+    Duration slowPacedPollInterval = ONE_HUNDRED_MILLISECONDS;
+    ConditionFactory calmlyAwait = Awaitility.with()
         .pollInterval(slowPacedPollInterval)
         .await();
 
-    @ClassRule
-    public static FakeSmtp fakeSmtp = FakeSmtp.withDefaultPort();
-
-    protected abstract SmtpHostSystem createSmtpHostSystem();
-    
-    private SmtpHostSystem hostSystem;
-    private SimpleScriptedTestProtocol scriptedTest;
+    @RegisterExtension
+    FakeSmtpExtension fakeSmtp = FakeSmtpExtension.withDefaultPort();
 
-    @Before
-    public void setUp() throws Exception {
-        hostSystem = createSmtpHostSystem();
+    SmtpHostSystem hostSystem();
 
-        scriptedTest = new SimpleScriptedTestProtocol("/org/apache/james/smtp/scripts/", hostSystem)
+    @Test
+    default void forwardingAnEmailShouldWork(FakeSmtpExtension.FakeSmtp fakeSmtp) throws Exception {
+        SimpleScriptedTestProtocol scriptedTest = new SimpleScriptedTestProtocol("/org/apache/james/smtp/scripts/", hostSystem())
                 .withLocale(Locale.US)
                 .withUser(USER_AT_DOMAIN, PASSWORD);
-        
-        hostSystem.getInMemoryDnsService()
-            .registerMxRecord("yopmail.com", fakeSmtp.getContainer().getContainerIp());
-        hostSystem.addAddressMapping(USER, DOMAIN, "ray@yopmail.com");
-    }
 
-    @Test
-    public void forwardingAnEmailShouldWork() throws Exception {
+        hostSystem().getInMemoryDnsService()
+                .registerMxRecord("yopmail.com", fakeSmtp.getContainerIp());
+        hostSystem().addAddressMapping(USER, DOMAIN, "ray@yopmail.com");
+
         scriptedTest.run("helo");
 
         calmlyAwait.atMost(TWO_MINUTES).untilAsserted(() ->
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java
index 4071696..f45a7bd 100644
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java
@@ -22,9 +22,7 @@ import java.util.Locale;
 
 import org.apache.james.mpt.script.SimpleScriptedTestProtocol;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
 
 public abstract class SmtpAuthCommandTest {
 
@@ -33,9 +31,6 @@ public abstract class SmtpAuthCommandTest {
     public static final String USER_AT_DOMAIN = USER + "@" + DOMAIN;
     public static final String PASSWORD = "secret";
 
-    @Rule
-    public final TemporaryFolder folder = new TemporaryFolder();
-
     protected abstract SmtpHostSystem createSmtpHostSystem();
     
     private SmtpHostSystem hostSystem;
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
index a0c110e..89925b6 100644
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
@@ -21,10 +21,8 @@ package org.apache.james.mpt.smtp;
 import java.util.Locale;
 
 import org.apache.james.mpt.script.SimpleScriptedTestProtocol;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public abstract class SmtpStarttlsCommandTest {
 
@@ -33,17 +31,12 @@ public abstract class SmtpStarttlsCommandTest {
     public static final String USER_AT_DOMAIN = USER + "@" + DOMAIN;
     public static final String PASSWORD = "secret";
 
-    @Rule
-    public final TemporaryFolder folder = new TemporaryFolder();
-
-    protected abstract SmtpHostSystem createSmtpHostSystem();
-    
-    private SmtpHostSystem hostSystem;
+    protected SmtpHostSystem hostSystem;
     private SimpleScriptedTestProtocol scriptedTest;
 
-    @Before
-    public void setUp() throws Exception {
-        hostSystem = createSmtpHostSystem();
+    @BeforeEach
+    public void setUp(SmtpHostSystem hostSystem) throws Exception {
+        this.hostSystem = hostSystem;
         String scriptDir = "/org/apache/james/smtp/scripts/";
         scriptedTest = new SimpleScriptedTestProtocol(scriptDir, hostSystem)
                 .withLocale(Locale.US)
@@ -51,29 +44,29 @@ public abstract class SmtpStarttlsCommandTest {
     }
 
     @Test
-    public void starttlsShouldWork() throws Exception {
+    void starttlsShouldWork() throws Exception {
         scriptedTest.run("starttls");
     }
 
     @Test
-    public void starttlsShouldBeRejectedWhenFollowedByCommand() throws Exception {
+    void starttlsShouldBeRejectedWhenFollowedByCommand() throws Exception {
         scriptedTest.run("starttls_with_injection");
     }
 
     @Test
-    public void shouldNotRejectContentWithStartTls() throws Exception {
+    void shouldNotRejectContentWithStartTls() throws Exception {
         scriptedTest.run("data_with_starttls");
     }
 
 
     @Test
-    public void shouldNotRejectRcptWithStartTls() throws Exception {
+    void shouldNotRejectRcptWithStartTls() throws Exception {
         scriptedTest.withUser("starttls@mydomain.tld", PASSWORD);
         scriptedTest.run("rcpt_with_starttls");
     }
 
     @Test
-    public void shouldNotRejectContentStartsWithStartTls() throws Exception {
+    void shouldNotRejectContentStartsWithStartTls() throws Exception {
         scriptedTest.run("data_starts_with_starttls");
     }
 }
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpTestExtension.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpTestExtension.java
new file mode 100644
index 0000000..aef6692
--- /dev/null
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpTestExtension.java
@@ -0,0 +1,159 @@
+/****************************************************************
+ * 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.smtp;
+
+import java.util.Optional;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.core.Domain;
+import org.apache.james.core.Username;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.api.InMemoryDNSService;
+import org.apache.james.modules.protocols.ProtocolHandlerModule;
+import org.apache.james.modules.protocols.SMTPServerModule;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.mpt.api.Continuation;
+import org.apache.james.mpt.api.Session;
+import org.apache.james.mpt.monitor.SystemLoggingMonitor;
+import org.apache.james.mpt.session.ExternalSessionFactory;
+import org.apache.james.util.Port;
+import org.apache.james.utils.DataProbeImpl;
+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;
+
+import com.google.common.base.Preconditions;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
+
+public class SmtpTestExtension implements
+        BeforeEachCallback,
+        AfterEachCallback,
+        ParameterResolver {
+
+    @FunctionalInterface
+    public interface ServerBuilder {
+        GuiceJamesServer build(TemporaryFolder folder, DNSService dnsService) throws Exception;
+    }
+
+    public static final Module SMTP_PROTOCOL_MODULE = Modules.combine(
+            new ProtocolHandlerModule(),
+            new SMTPServerModule());
+
+    private final SmtpGuiceProbe.SmtpServerConnectedType smtpServerConnectedType;
+    private final ServerBuilder createJamesServer;
+    private TemporaryFolder folder;
+    private InMemoryDNSService inMemoryDNSService;
+    private GuiceJamesServer jamesServer;
+    private SmtpHostSystem smtpHostSystem;
+
+    public SmtpTestExtension(SmtpGuiceProbe.SmtpServerConnectedType smtpServerConnectedType, ServerBuilder createJamesServer) {
+        this.smtpServerConnectedType = smtpServerConnectedType;
+        this.createJamesServer = createJamesServer;
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext context) throws Exception {
+        inMemoryDNSService = new InMemoryDNSService();
+        folder = new TemporaryFolder();
+        folder.create();
+        jamesServer = createJamesServer.build(folder, inMemoryDNSService);
+        jamesServer.start();
+        smtpHostSystem = new HostSystem(jamesServer, smtpServerConnectedType, inMemoryDNSService);
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context) throws Exception {
+        jamesServer.stop();
+        folder.delete();
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return (parameterContext.getParameter().getType().isAssignableFrom(SmtpHostSystem.class));
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return smtpHostSystem;
+    }
+
+
+    public static class HostSystem implements SmtpHostSystem {
+
+        private final ExternalSessionFactory sessionFactory;
+        private final SmtpGuiceProbe.SmtpServerConnectedType smtpServerConnectedType;
+        private final InMemoryDNSService inMemoryDNSService;
+        private final GuiceJamesServer jamesServer;
+
+        public HostSystem(GuiceJamesServer jamesServer, SmtpGuiceProbe.SmtpServerConnectedType smtpServerConnectedType, InMemoryDNSService inMemoryDNSService) {
+            this.jamesServer = jamesServer;
+            this.smtpServerConnectedType = smtpServerConnectedType;
+            this.inMemoryDNSService = inMemoryDNSService;
+            SmtpGuiceProbe smtpProbe = jamesServer.getProbe(SmtpGuiceProbe.class);
+            Port smtpPort = this.smtpServerConnectedType.getPortExtractor().apply(smtpProbe);
+            sessionFactory = new ExternalSessionFactory("localhost", smtpPort, new SystemLoggingMonitor(), "220 mydomain.tld smtp");
+        }
+
+        @Override
+        public boolean addUser(Username userAtDomain, String password) throws Exception {
+            Optional<Domain> domain = userAtDomain.getDomainPart();
+            Preconditions.checkArgument(domain.isPresent(), "The 'user' should contain the 'domain'");
+            createDomainIfNeeded(domain.get().asString());
+            jamesServer.getProbe(DataProbeImpl.class).addUser(userAtDomain.asString(), password);
+            return true;
+        }
+
+        @Override
+        public Session newSession(Continuation continuation) throws Exception {
+            return sessionFactory.newSession(continuation);
+        }
+
+        private void createDomainIfNeeded(String domain) throws Exception {
+            if (!jamesServer.getProbe(DataProbeImpl.class).containsDomain(domain)) {
+                jamesServer.getProbe(DataProbeImpl.class).addDomain(domain);
+            }
+        }
+
+        @Override
+        public void addAddressMapping(String user, String domain, String address) throws Exception {
+            jamesServer.getProbe(DataProbeImpl.class).addAddressMapping(user, domain, address);
+        }
+
+        @Override
+        public void beforeTest() throws Exception {
+
+        }
+
+        @Override
+        public void afterTest() throws Exception {
+
+        }
+
+        @Override
+        public InMemoryDNSService getInMemoryDnsService() {
+            return inMemoryDNSService;
+        }
+    }
+}
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpTestRule.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpTestRule.java
deleted file mode 100644
index 9162099..0000000
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpTestRule.java
+++ /dev/null
@@ -1,137 +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.smtp;
-
-import java.util.Optional;
-
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.core.Domain;
-import org.apache.james.core.Username;
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.dnsservice.api.InMemoryDNSService;
-import org.apache.james.modules.protocols.ProtocolHandlerModule;
-import org.apache.james.modules.protocols.SMTPServerModule;
-import org.apache.james.modules.protocols.SmtpGuiceProbe;
-import org.apache.james.mpt.api.Continuation;
-import org.apache.james.mpt.api.Session;
-import org.apache.james.mpt.monitor.SystemLoggingMonitor;
-import org.apache.james.mpt.session.ExternalSessionFactory;
-import org.apache.james.util.Port;
-import org.apache.james.utils.DataProbeImpl;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-
-public class SmtpTestRule implements TestRule, SmtpHostSystem {
-    @FunctionalInterface
-    public interface ServerBuilder {
-        GuiceJamesServer build(TemporaryFolder folder, DNSService dnsService) throws Exception;
-    }
-
-    public static final Module SMTP_PROTOCOL_MODULE = Modules.combine(
-        new ProtocolHandlerModule(),
-        new SMTPServerModule());
-
-    private final SmtpGuiceProbe.SmtpServerConnectedType smtpServerConnectedType;
-    private final ServerBuilder createJamesServer;
-    private TemporaryFolder folder;
-    private InMemoryDNSService inMemoryDNSService;
-    private GuiceJamesServer jamesServer;
-    private ExternalSessionFactory sessionFactory;
-
-    public SmtpTestRule(SmtpGuiceProbe.SmtpServerConnectedType smtpServerConnectedType, ServerBuilder createJamesServer) {
-        this.smtpServerConnectedType = smtpServerConnectedType;
-        this.createJamesServer = createJamesServer;
-    }
-
-    @Override
-    public Statement apply(Statement base, Description description) {
-        return new Statement() {
-            @Override
-            public void evaluate() throws Throwable {
-                beforeTest();
-                try {
-                    base.evaluate();
-                } finally {
-                    afterTest();
-                }
-            }
-        };
-    }
-
-    @Override
-    public boolean addUser(Username userAtDomain, String password) throws Exception {
-        Optional<Domain> domain = userAtDomain.getDomainPart();
-        Preconditions.checkArgument(domain.isPresent(), "The 'user' should contain the 'domain'");
-        createDomainIfNeeded(domain.get().asString());
-        jamesServer.getProbe(DataProbeImpl.class).addUser(userAtDomain.asString(), password);
-        return true;
-    }
-
-    @Override
-    public Session newSession(Continuation continuation) throws Exception {
-        return sessionFactory.newSession(continuation);
-    }
-
-    private void createDomainIfNeeded(String domain) throws Exception {
-        if (!jamesServer.getProbe(DataProbeImpl.class).containsDomain(domain)) {
-            jamesServer.getProbe(DataProbeImpl.class).addDomain(domain);
-        }
-    }
-
-    @Override
-    public void addAddressMapping(String user, String domain, String address) throws Exception {
-        jamesServer.getProbe(DataProbeImpl.class).addAddressMapping(user, domain, address);
-    }
-
-    @Override
-    public void beforeTest() throws Exception {
-        inMemoryDNSService = new InMemoryDNSService();
-        folder = new TemporaryFolder();
-        folder.create();
-        jamesServer = createJamesServer.build(folder, inMemoryDNSService);
-        jamesServer.start();
-
-        createSessionFactory();
-    }
-
-    @Override
-    public void afterTest() {
-        jamesServer.stop();
-        folder.delete();
-    }
-
-    @Override
-    public InMemoryDNSService getInMemoryDnsService() {
-        return inMemoryDNSService;
-    }
-
-    private void createSessionFactory() {
-        SmtpGuiceProbe smtpProbe = jamesServer.getProbe(SmtpGuiceProbe.class);
-        Port smtpPort = smtpServerConnectedType.getPortExtractor().apply(smtpProbe);
-
-        sessionFactory = new ExternalSessionFactory("localhost", smtpPort, new SystemLoggingMonitor(), "220 mydomain.tld smtp");
-    }
-}
diff --git a/server/testing/pom.xml b/server/testing/pom.xml
index 6c8d522..e991f0c 100644
--- a/server/testing/pom.xml
+++ b/server/testing/pom.xml
@@ -74,6 +74,10 @@
             <artifactId>awaitility</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.subethamail</groupId>
             <artifactId>subethasmtp</artifactId>
             <scope>test</scope>
diff --git a/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java b/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java
new file mode 100644
index 0000000..a2f59c3
--- /dev/null
+++ b/server/testing/src/main/java/org/apache/james/utils/FakeSmtpExtension.java
@@ -0,0 +1,168 @@
+/****************************************************************
+ * 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.utils;
+
+import static io.restassured.RestAssured.given;
+import static io.restassured.config.EncoderConfig.encoderConfig;
+import static io.restassured.config.RestAssuredConfig.newConfig;
+
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.function.Consumer;
+
+import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
+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.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
+
+import com.github.dockerjava.api.model.ContainerNetwork;
+
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.builder.ResponseSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.response.ValidatableResponse;
+import io.restassured.specification.RequestSpecification;
+import io.restassured.specification.ResponseSpecification;
+
+
+public class FakeSmtpExtension implements
+        BeforeEachCallback,
+        AfterEachCallback,
+        ParameterResolver {
+
+    private static final int SMTP_PORT = 25;
+
+    public static FakeSmtpExtension withSmtpPort(Integer smtpPort) {
+        GenericContainer<?> container = fakeSmtpContainer()
+                .withExposedPorts(smtpPort)
+                .withCommand("node", "cli", "--listen", "80", "--smtp", smtpPort.toString());
+
+        return new FakeSmtpExtension(container);
+    }
+
+    public static FakeSmtpExtension withDefaultPort() {
+        return withSmtpPort(SMTP_PORT);
+    }
+
+    private static  GenericContainer<?> fakeSmtpContainer() {
+        return new GenericContainer<>(Images.FAKE_SMTP)
+            .waitingFor(new HostPortWaitStrategy()
+                .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND)
+                .withStartupTimeout(Duration.ofMinutes(1))
+            );
+    }
+
+    private final GenericContainer<?> container;
+    private final FakeSmtp fakeSmtp;
+
+    private FakeSmtpExtension(GenericContainer<?> container) {
+        this.container = container;
+        this.fakeSmtp = new FakeSmtp(container);
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext context) throws Exception {
+        container.start();
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context) throws Exception {
+        container.stop();
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return (parameterContext.getParameter().getType().isAssignableFrom(FakeSmtp.class));
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return fakeSmtp;
+    }
+
+    public static class FakeSmtp {
+        public static final ResponseSpecification RESPONSE_SPECIFICATION = new ResponseSpecBuilder().build();
+
+        private final GenericContainer<?> container;
+
+        public FakeSmtp(GenericContainer<?> container) {
+            this.container = container;
+        }
+
+        public String getContainerIp() {
+            return container.getContainerInfo()
+                    .getNetworkSettings()
+                    .getNetworks()
+                    .values()
+                    .stream()
+                    .map(ContainerNetwork::getIpAddress)
+                    .findFirst()
+                    .orElseThrow(IllegalStateException::new);
+        }
+
+        private String getHostIp() {
+            return container.getContainerIpAddress();
+        }
+
+        public void assertEmailReceived(Consumer<ValidatableResponse> expectations) {
+            expectations.accept(
+                    given(requestSpecification(), RESPONSE_SPECIFICATION)
+                            .get("/api/email")
+                            .then()
+                            .statusCode(200));
+        }
+
+        private RequestSpecification requestSpecification() {
+            return new RequestSpecBuilder()
+                    .setContentType(ContentType.JSON)
+                    .setAccept(ContentType.JSON)
+                    .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
+                    .setPort(80)
+                    .setBaseUri("http://" + getContainerIp())
+                    .build();
+        }
+
+        public void clean() {
+            clean(requestSpecification());
+        }
+
+        private static void clean(RequestSpecification requestSpecification) {
+            given(requestSpecification, RESPONSE_SPECIFICATION)
+                    .get("/api/email")
+                    .jsonPath()
+                    .getList("id", String.class)
+                    .stream()
+                    .mapToInt(Integer::valueOf)
+                    .max()
+                    .ifPresent(id -> given(requestSpecification, RESPONSE_SPECIFICATION)
+                            .get("/api/email/purge/" + id));
+        }
+
+        public GenericContainer<?> getContainer() {
+            return container;
+        }
+    }
+}


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