james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [05/18] james-project git commit: JAMES-2553 Enable to not automatically start James server via the extension
Date Thu, 04 Oct 2018 10:49:25 GMT
JAMES-2553 Enable to not automatically start James server via the extension


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

Branch: refs/heads/master
Commit: 0cc7b27c7544f39ace88ece43f6e9cd512911bb8
Parents: 17692d9
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Oct 2 11:37:26 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Oct 4 17:48:42 2018 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/JamesServerExtension.java    |  8 ++++++--
 .../org/apache/james/JamesServerExtensionBuilder.java  | 13 +++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0cc7b27c/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
index 6ba6b0a..829e741 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
@@ -41,12 +41,14 @@ public class JamesServerExtension implements BeforeAllCallback, BeforeEachCallba
     private final TemporaryFolderRegistrableExtension folderRegistrableExtension;
     private final ThrowingFunction<File, GuiceJamesServer> serverSupplier;
     private final RegistrableExtension registrableExtension;
+    private final boolean autoStart;
     private GuiceJamesServer guiceJamesServer;
 
-    JamesServerExtension(RegistrableExtension registrableExtension, ThrowingFunction<File,
GuiceJamesServer> serverSupplier) {
+    JamesServerExtension(RegistrableExtension registrableExtension, ThrowingFunction<File,
GuiceJamesServer> serverSupplier, boolean autoStart) {
         this.registrableExtension = registrableExtension;
         this.serverSupplier = serverSupplier;
         this.folderRegistrableExtension = new TemporaryFolderRegistrableExtension();
+        this.autoStart = autoStart;
     }
 
     @Override
@@ -59,7 +61,9 @@ public class JamesServerExtension implements BeforeAllCallback, BeforeEachCallba
         folderRegistrableExtension.beforeEach(extensionContext);
         registrableExtension.beforeEach(extensionContext);
         guiceJamesServer = serverSupplier.apply(createTmpDir());
-        guiceJamesServer.start();
+        if (autoStart) {
+            guiceJamesServer.start();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/0cc7b27c/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
index 1831f72..9981ce1 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtensionBuilder.java
@@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.inject.Module;
 
 public class JamesServerExtensionBuilder {
+    private static final boolean DEFAULT_AUTO_START = true;
 
     @FunctionalInterface
     interface ConfigurationProvider {
@@ -46,11 +47,13 @@ public class JamesServerExtensionBuilder {
     private final TemporaryFolderRegistrableExtension folderRegistrableExtension;
     private ServerProvider server;
     private Optional<ConfigurationProvider> configuration;
+    private Optional<Boolean> autoStart;
 
     JamesServerExtensionBuilder() {
         configuration = Optional.empty();
         extensions = ImmutableList.builder();
         folderRegistrableExtension = new TemporaryFolderRegistrableExtension();
+        autoStart = Optional.empty();
     }
 
     public JamesServerExtensionBuilder extensions(GuiceModuleTestExtension... extensions)
{
@@ -72,11 +75,17 @@ public class JamesServerExtensionBuilder {
         return this;
     }
 
+    public JamesServerExtensionBuilder disableAutoStart() {
+        this.autoStart = Optional.of(false);
+        return this;
+    }
+
     public JamesServerExtension build() {
         Preconditions.checkNotNull(server);
         ConfigurationProvider configuration = this.configuration.orElse(defaultConfigurationProvider());
-        return new JamesServerExtension(buildAggregateJunitExtension(),
-            file -> overrideServerWithExtensionsModules(file, configuration));
+
+        return new JamesServerExtension(buildAggregateJunitExtension(), file -> overrideServerWithExtensionsModules(file,
configuration),
+            autoStart.orElse(DEFAULT_AUTO_START));
     }
 
     private ConfigurationProvider defaultConfigurationProvider() {


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


Mime
View raw message