james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [15/24] james-project git commit: JAMES-2366 Factorize WebAdmin Test configuration
Date Fri, 06 Apr 2018 13:20:34 GMT
JAMES-2366 Factorize WebAdmin Test configuration


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

Branch: refs/heads/master
Commit: 77bb6b550d54c1832311242f471b088c1f0f2878
Parents: aca51fc
Author: benwa <btellier@linagora.com>
Authored: Thu Apr 5 16:23:53 2018 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Fri Apr 6 15:04:49 2018 +0200

----------------------------------------------------------------------
 .../test/java/org/apache/james/FixingGhostMailboxTest.java  | 6 +-----
 .../java/org/apache/james/mailets/TemporaryJamesServer.java | 3 +--
 .../jmap/cassandra/CassandraForwardIntegrationTest.java     | 8 +-------
 .../james/jmap/memory/MemoryForwardIntegrationTest.java     | 8 +-------
 .../webadmin/integration/WebAdminConfigurationModule.java   | 3 +--
 .../org/apache/james/webadmin/WebAdminConfiguration.java    | 7 +++++++
 .../test/java/org/apache/james/webadmin/WebAdminUtils.java  | 9 +--------
 7 files changed, 13 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
index 036ee10..5de81da 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
@@ -67,7 +67,6 @@ import org.apache.james.task.TaskManager;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.JmapGuiceProbe;
 import org.apache.james.utils.WebAdminGuiceProbe;
-import org.apache.james.webadmin.RandomPortSupplier;
 import org.apache.james.webadmin.WebAdminConfiguration;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.routes.CassandraMailboxMergingRoutes;
@@ -127,10 +126,7 @@ public class FixingGhostMailboxTest {
     public void setup() throws Throwable {
         jmapServer = rule.jmapServer(cassandra.getModule(),
             binder -> binder.bind(WebAdminConfiguration.class)
-            .toInstance(WebAdminConfiguration.builder()
-                .port(new RandomPortSupplier())
-                .enabled()
-                .build()));
+            .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
         jmapServer.start();
         webAdminProbe = jmapServer.getProbe(WebAdminGuiceProbe.class);
         mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class);

http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
index a621caa..2a6e737 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
@@ -41,7 +41,6 @@ import org.apache.james.mailets.configuration.SmtpConfiguration;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.utils.GuiceProbe;
 import org.apache.james.webadmin.WebAdminConfiguration;
-import org.apache.james.webadmin.WebAdminUtils;
 import org.junit.rules.TemporaryFolder;
 
 import com.google.common.collect.ImmutableList;
@@ -141,7 +140,7 @@ public class TemporaryJamesServer {
             .overrideWith(additionalModules)
             .overrideWith(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES))
             .overrideWith(new TemporaryFilesystemModule(temporaryFolder))
-            .overrideWith((binder) -> binder.bind(WebAdminConfiguration.class).toProvider(WebAdminUtils::webAdminConfigurationForTesting));
+            .overrideWith((binder) -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
 
         jamesServer.start();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java
index 2630250..c0e1517 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java
@@ -24,7 +24,6 @@ import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration;
 import org.apache.james.jmap.methods.integration.ForwardIntegrationTest;
-import org.apache.james.webadmin.RandomPortSupplier;
 import org.apache.james.webadmin.WebAdminConfiguration;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -47,12 +46,7 @@ public class CassandraForwardIntegrationTest extends ForwardIntegrationTest
{
     protected GuiceJamesServer createJmapServer() {
         return rule.jmapServer(cassandra.getModule(),
             binder -> binder.bind(WebAdminConfiguration.class)
-                .toInstance(WebAdminConfiguration.builder()
-                    .enabled()
-                    .corsDisabled()
-                    .host("127.0.0.1")
-                    .port(new RandomPortSupplier())
-                    .build()));
+                .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
     }
     
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryForwardIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryForwardIntegrationTest.java
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryForwardIntegrationTest.java
index 458e1e3..b1d64ee 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryForwardIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryForwardIntegrationTest.java
@@ -22,7 +22,6 @@ package org.apache.james.jmap.memory;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.MemoryJmapTestRule;
 import org.apache.james.jmap.methods.integration.ForwardIntegrationTest;
-import org.apache.james.webadmin.RandomPortSupplier;
 import org.apache.james.webadmin.WebAdminConfiguration;
 import org.junit.Rule;
 
@@ -35,12 +34,7 @@ public class MemoryForwardIntegrationTest extends ForwardIntegrationTest
{
     protected GuiceJamesServer createJmapServer() {
         return memoryJmap
             .jmapServer(binder -> binder.bind(WebAdminConfiguration.class)
-                .toInstance(WebAdminConfiguration.builder()
-                    .enabled()
-                    .corsDisabled()
-                    .host("127.0.0.1")
-                    .port(new RandomPortSupplier())
-                    .build()));
+                .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
     }
     
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminConfigurationModule.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminConfigurationModule.java
b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminConfigurationModule.java
index 8bcf260..f84810b 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminConfigurationModule.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminConfigurationModule.java
@@ -20,7 +20,6 @@
 package org.apache.james.webadmin.integration;
 
 import org.apache.james.webadmin.WebAdminConfiguration;
-import org.apache.james.webadmin.WebAdminUtils;
 
 import com.google.inject.AbstractModule;
 
@@ -28,7 +27,7 @@ public class WebAdminConfigurationModule extends AbstractModule {
 
     @Override
     protected void configure() {
-        bind(WebAdminConfiguration.class).toProvider(WebAdminUtils::webAdminConfigurationForTesting);
+        bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminConfiguration.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminConfiguration.java
b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminConfiguration.java
index 8712a4c..e4a90e9 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminConfiguration.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminConfiguration.java
@@ -36,6 +36,13 @@ public class WebAdminConfiguration {
         .disabled()
         .build();
 
+    public static final WebAdminConfiguration TEST_CONFIGURATION = WebAdminConfiguration.builder()
+        .enabled()
+        .corsDisabled()
+        .host("127.0.0.1")
+        .port(new RandomPortSupplier())
+        .build();
+
     public static Builder builder() {
         return new Builder();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/77bb6b55/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminUtils.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminUtils.java
b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminUtils.java
index 5b4e147..76862b4 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminUtils.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminUtils.java
@@ -34,15 +34,8 @@ import com.jayway.restassured.http.ContentType;
 
 public class WebAdminUtils {
 
-    public static WebAdminConfiguration webAdminConfigurationForTesting() {
-        return WebAdminConfiguration.builder()
-            .enabled()
-            .port(new RandomPortSupplier())
-            .build();
-    }
-
     public static WebAdminServer createWebAdminServer(MetricFactory metricFactory, Routes...
routes) throws IOException {
-        return new WebAdminServer(webAdminConfigurationForTesting(),
+        return new WebAdminServer(WebAdminConfiguration.TEST_CONFIGURATION,
             ImmutableSet.copyOf(routes),
             new NoAuthenticationFilter(),
             metricFactory);


---------------------------------------------------------------------
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