You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/22 02:51:52 UTC

[james-project] branch master updated: JAMES-2754 Migrate deployment tests to JUNIT 5

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 424c4e7  JAMES-2754 Migrate deployment tests to JUNIT 5
424c4e7 is described below

commit 424c4e76b4a43df5d2426c11650e4045b5e7aadf
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Jan 21 12:56:16 2021 +0700

    JAMES-2754 Migrate deployment tests to JUNIT 5
---
 .../external/james/DeploymentValidation.java       |  6 ++---
 .../DockerDeploymentValidationGuiceJPATest.java    | 24 +++++++++---------
 .../DockerDeploymentValidationSpringJPATest.java   | 29 +++++++++-------------
 .../external/james/DockerJamesRule.java            | 15 ++++++++++-
 .../james/JamesDeploymentValidationTest.java       | 10 ++++----
 5 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DeploymentValidation.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DeploymentValidation.java
index b42edcf..bb6adcb 100644
--- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DeploymentValidation.java
+++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DeploymentValidation.java
@@ -34,8 +34,8 @@ import org.apache.james.utils.SMTPMessageSender;
 import org.awaitility.Awaitility;
 import org.awaitility.Duration;
 import org.awaitility.core.ConditionFactory;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
 
 public abstract class DeploymentValidation {
 
@@ -66,7 +66,7 @@ public abstract class DeploymentValidation {
         .await();
     protected static final ConditionFactory awaitAtMostTenSeconds = calmlyAwait.atMost(TEN_SECONDS);
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         system = createImapHostSystem();
         smtpSystem = createSmtpHostSystem();
diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationGuiceJPATest.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationGuiceJPATest.java
index 268f8db..0e1a145 100644
--- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationGuiceJPATest.java
+++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationGuiceJPATest.java
@@ -24,26 +24,26 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.external.james.host.ProvisioningAPI;
 import org.apache.james.mpt.imapmailbox.external.james.host.SmtpHostSystem;
 import org.apache.james.mpt.imapmailbox.external.james.host.external.ExternalJamesConfiguration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-@Ignore("Not to be run on CI, as it will not use the current build")
-public class DockerDeploymentValidationGuiceJPATest extends DeploymentValidation {
+@Disabled("Not to be run on CI, as it will not use the current build")
+class DockerDeploymentValidationGuiceJPATest extends DeploymentValidation {
 
     private ImapHostSystem system;
     private SmtpHostSystem smtpHostSystem;
 
-    @Rule
+    @RegisterExtension
     public DockerJamesRule dockerJamesRule = new DockerJamesRule("linagora/james-jpa-guice");
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
         dockerJamesRule.start();
@@ -60,13 +60,13 @@ public class DockerDeploymentValidationGuiceJPATest extends DeploymentValidation
     }
 
     @Test
-    @Ignore("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
+    @Disabled("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
     @Override
     public void validateDeployment() throws Exception {
     }
 
     @Test
-    @Ignore("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
+    @Disabled("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
     @Override
     public void validateDeploymentWithMailsFromSmtp() throws Exception {
     }
@@ -86,7 +86,7 @@ public class DockerDeploymentValidationGuiceJPATest extends DeploymentValidation
         return dockerJamesRule.getConfiguration();
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         system.afterTest();
         dockerJamesRule.stop();
diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationSpringJPATest.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationSpringJPATest.java
index a40e763..3155d8a 100644
--- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationSpringJPATest.java
+++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerDeploymentValidationSpringJPATest.java
@@ -24,30 +24,27 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.external.james.host.ProvisioningAPI;
 import org.apache.james.mpt.imapmailbox.external.james.host.SmtpHostSystem;
 import org.apache.james.mpt.imapmailbox.external.james.host.external.ExternalJamesConfiguration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-@Ignore("Not to be run on CI, as it will not use the current build")
-public class DockerDeploymentValidationSpringJPATest extends DeploymentValidation {
+@Disabled("Not to be run on CI, as it will not use the current build")
+class DockerDeploymentValidationSpringJPATest extends DeploymentValidation {
 
     private ImapHostSystem system;
     private SmtpHostSystem smtpHostSystem;
 
-    @Rule
+    @RegisterExtension
     public DockerJamesRule dockerJamesRule = new DockerJamesRule("linagora/james-jpa-spring");
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
-
-        dockerJamesRule.start();
-
         ProvisioningAPI provisioningAPI = dockerJamesRule.cliShellDomainsAndUsersAdder();
         Injector injector = Guice.createInjector(new ExternalJamesModule(getConfiguration(), provisioningAPI));
         system = injector.getInstance(ImapHostSystem.class);
@@ -60,13 +57,13 @@ public class DockerDeploymentValidationSpringJPATest extends DeploymentValidatio
     }
 
     @Test
-    @Ignore("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
+    @Disabled("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
     @Override
     public void validateDeployment() throws Exception {
     }
 
     @Test
-    @Ignore("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
+    @Disabled("Not to be run on CI, as it will not use the current build. Uncomment to test on local dev environment")
     @Override
     public void validateDeploymentWithMailsFromSmtp() throws Exception {
     }
@@ -86,10 +83,8 @@ public class DockerDeploymentValidationSpringJPATest extends DeploymentValidatio
         return dockerJamesRule.getConfiguration();
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         system.afterTest();
-        dockerJamesRule.stop();
     }
-
 }
diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerJamesRule.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerJamesRule.java
index fc23bfb..8dc25f5 100644
--- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerJamesRule.java
+++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/DockerJamesRule.java
@@ -26,6 +26,9 @@ import org.apache.james.mpt.imapmailbox.external.james.host.docker.CliProvisioni
 import org.apache.james.mpt.imapmailbox.external.james.host.external.ExternalJamesConfiguration;
 import org.apache.james.util.Port;
 import org.apache.james.util.docker.DockerContainer;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
@@ -33,7 +36,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
-public class DockerJamesRule implements TestRule {
+public class DockerJamesRule implements TestRule, BeforeEachCallback, AfterEachCallback {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DockerJamesRule.class);
 
@@ -101,4 +104,14 @@ public class DockerJamesRule implements TestRule {
     public Statement apply(Statement statement, Description description) {
         return statement;
     }
+
+    @Override
+    public void afterEach(ExtensionContext extensionContext) throws Exception {
+        stop();
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext extensionContext) throws Exception {
+        start();
+    }
 }
diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/JamesDeploymentValidationTest.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/JamesDeploymentValidationTest.java
index af766be..47d6d00 100644
--- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/JamesDeploymentValidationTest.java
+++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/JamesDeploymentValidationTest.java
@@ -26,18 +26,19 @@ import org.apache.james.mpt.imapmailbox.external.james.host.external.ExternalJam
 import org.apache.james.mpt.imapmailbox.external.james.host.external.NoopDomainsAndUserAdder;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-public class JamesDeploymentValidationTest extends DeploymentValidation {
-
+class JamesDeploymentValidationTest extends DeploymentValidation {
     private ImapHostSystem system;
     private SmtpHostSystem smtpHostSystem;
     private final ExternalJamesConfiguration configuration = new ExternalJamesConfigurationEnvironnementVariables();
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         Injector injector = Guice.createInjector(new ExternalJamesModule(configuration, new NoopDomainsAndUserAdder()));
         system = injector.getInstance(ImapHostSystem.class);
@@ -61,9 +62,8 @@ public class JamesDeploymentValidationTest extends DeploymentValidation {
         return configuration;
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         system.afterTest();
     }
-
 }


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