james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [09/29] james-project git commit: JAMES-1842: JMAP port should be Optional
Date Fri, 18 Nov 2016 09:54:02 GMT
JAMES-1842: JMAP port should be Optional


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

Branch: refs/heads/master
Commit: 978e722ebee120f42b835911b644f5758fefe3e7
Parents: ff57437
Author: Quynh Nguyen <qnguyen@linagora.com>
Authored: Fri Oct 28 12:07:17 2016 +0700
Committer: Quynh Nguyen <qnguyen@linagora.com>
Committed: Fri Nov 18 09:25:34 2016 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/GuiceJamesServer.java     | 16 ++++++++++++----
 .../org/apache/james/AbstractJamesServerTest.java   |  6 +++++-
 .../apache/james/jmap/JMAPAuthenticationTest.java   |  3 ++-
 .../apache/james/jmap/VacationIntegrationTest.java  |  3 ++-
 .../methods/integration/GetMailboxesMethodTest.java |  3 ++-
 .../integration/GetMessageListMethodTest.java       |  3 ++-
 .../integration/GetVacationResponseTest.java        |  3 ++-
 .../methods/integration/SetMailboxesMethodTest.java |  3 ++-
 .../methods/integration/SetMessagesMethodTest.java  |  3 ++-
 .../integration/SetVacationResponseTest.java        |  3 ++-
 .../methods/integration/cucumber/MainStepdefs.java  |  3 ++-
 11 files changed, 35 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
index 39411b0..b3dc728 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
@@ -47,7 +47,7 @@ public class GuiceJamesServer {
     private final Module module;
     private Stager<PreDestroy> preDestroy;
     private GuiceServerProbe serverProbe;
-    private int jmapPort;
+    private Optional<Integer> jmapPort;
     private Optional<Port> webadminPort;
 
     public GuiceJamesServer() {
@@ -57,7 +57,7 @@ public class GuiceJamesServer {
                         new MailetProcessingModule()));
     }
 
-    private GuiceJamesServer(Module module) {
+    public GuiceJamesServer(Module module) {
         this.module = module;
     }
     
@@ -74,10 +74,18 @@ public class GuiceJamesServer {
         preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>()
{}));
         injector.getInstance(ConfigurationsPerformer.class).initModules();
         serverProbe = injector.getInstance(GuiceServerProbe.class);
-        jmapPort = injector.getInstance(JMAPServer.class).getPort();
+        jmapPort = locateJMAPPort(injector);
         webadminPort =locateWebAdminPort(injector);
     }
 
+    private Optional<Integer> locateJMAPPort(Injector injector) {
+        try {
+            return Optional.of(injector.getInstance(JMAPServer.class).getPort());
+        } catch(Exception e) {
+            return Optional.empty();
+        }
+    }
+
     private Optional<Port> locateWebAdminPort(Injector injector) {
         try {
             return Optional.of(injector.getInstance(WebAdminServer.class).getPort());
@@ -96,7 +104,7 @@ public class GuiceJamesServer {
         return serverProbe;
     }
 
-    public int getJmapPort() {
+    public Optional<Integer> getJmapPort() {
         return jmapPort;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java
b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java
index 6529ef4..11fc881 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java
@@ -31,6 +31,7 @@ import java.nio.channels.SocketChannel;
 import java.nio.charset.Charset;
 
 import org.junit.After;
+import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -46,6 +47,7 @@ public abstract class AbstractJamesServerTest {
     private static final int POP3_PORT = 1110;
     private static final int SMTP_PORT = 1025;
     private static final int LMTP_PORT = 1024;
+    private static final int JMAP_PORT = 1080;
 
     private GuiceJamesServer server;
     private SocketChannel socketChannel;
@@ -60,7 +62,8 @@ public abstract class AbstractJamesServerTest {
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(server.getJmapPort())
+        		.setPort(server.getJmapPort()
+        		        .orElse(JMAP_PORT))
         		.build();
     }
 
@@ -122,6 +125,7 @@ public abstract class AbstractJamesServerTest {
 
     @Test
     public void connectJMAPServerShouldRespondBadRequest() throws Exception {
+        Assume.assumeTrue(server.getJmapPort().isPresent());
         given()
             .body("{\"badAttributeName\": \"value\"}")
         .when()

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
index cd17481..12e6a1a 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
@@ -63,7 +63,8 @@ public abstract class JMAPAuthenticationTest {
         jmapServer.start();
         RestAssured.requestSpecification = new RequestSpecBuilder()
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(jmapServer.getJmapPort())
+        		.setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
         		.build();
         
         userCredentials = UserCredentials.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
index dff1898..653bfe0 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
@@ -87,7 +87,8 @@ public abstract class VacationIntegrationTest {
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(guiceJamesServer.getJmapPort())
+        		.setPort(guiceJamesServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
         		.build();
 
         Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
index f59850a..d77362b 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
@@ -69,7 +69,8 @@ public abstract class GetMailboxesMethodTest {
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(jmapServer.getJmapPort())
+        		.setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
         		.build();
 
         String domain = "domain.tld";

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index ee24d6b..b05fc07 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -73,7 +73,8 @@ public abstract class GetMessageListMethodTest {
                 .setContentType(ContentType.JSON)
                 .setAccept(ContentType.JSON)
                 .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-                .setPort(jmapServer.getJmapPort())
+                .setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
                 .build();
 
         this.domain = "domain.tld";

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
index c93f6d8..a6f5604 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
@@ -76,7 +76,8 @@ public abstract class GetVacationResponseTest {
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(jmapServer.getJmapPort())
+        		.setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
         		.build();
 
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
index 1fa49cc..29fffdc 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
@@ -75,7 +75,8 @@ public abstract class SetMailboxesMethodTest {
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(jmapServer.getJmapPort())
+        		.setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
         		.build();
         RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 6cf9ec7..ba864b1 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -106,7 +106,8 @@ public abstract class SetMessagesMethodTest {
                 .setContentType(ContentType.JSON)
                 .setAccept(ContentType.JSON)
                 .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-                .setPort(jmapServer.getJmapPort())
+                .setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
                 .build();
 
         username = "username@" + USERS_DOMAIN;

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
index 4303e23..2e90360 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
@@ -68,7 +68,8 @@ public abstract class SetVacationResponseTest {
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
         		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-        		.setPort(jmapServer.getJmapPort())
+        		.setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
         		.build();
 
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);

http://git-wip-us.apache.org/repos/asf/james-project/blob/978e722e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java
index a5327ed..ed36491 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java
@@ -41,7 +41,8 @@ public class MainStepdefs {
         return new URIBuilder()
                 .setScheme("http")
                 .setHost("localhost")
-                .setPort(jmapServer.getJmapPort())
+                .setPort(jmapServer.getJmapPort()
+                        .orElseThrow(() -> new RuntimeException("Unable to locate JMAP
port")))
                 .setCharset(Charsets.UTF_8);
     }
     


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