james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [13/15] james-project git commit: JAMES-2406 Use Host instead of Cassandra IP and port
Date Wed, 06 Jun 2018 07:01:07 GMT
JAMES-2406 Use Host instead of Cassandra IP and port


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

Branch: refs/heads/master
Commit: a1c8bfc209dc473af7c1c0d85a47cc5f68f081c8
Parents: 9df4870
Author: benwa <btellier@linagora.com>
Authored: Thu May 31 16:52:59 2018 +0700
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Wed Jun 6 09:00:10 2018 +0200

----------------------------------------------------------------------
 .../james/backends/cassandra/DockerCassandraRule.java    |  7 +++++++
 .../apache/james/mpt/smtp/CassandraForwardSmtpTest.java  |  2 +-
 .../james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java |  2 +-
 .../java/org/apache/james/mpt/smtp/SmtpTestModule.java   | 11 +++++------
 .../mpt/smtp/host/CassandraJamesSmtpHostSystem.java      |  9 ++++-----
 .../apache/james/modules/CassandraJmapServerModule.java  |  9 ++++-----
 .../org/apache/james/modules/CassandraTestModule.java    | 11 +++++------
 .../james/jmap/cassandra/cucumber/CassandraStepdefs.java |  2 +-
 8 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
index 327fa78..a612e86 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
@@ -20,6 +20,7 @@
 package org.apache.james.backends.cassandra;
 
 import org.apache.commons.text.RandomStringGenerator;
+import org.apache.james.util.Host;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
@@ -125,6 +126,12 @@ public class DockerCassandraRule implements TestRule {
             deleteTmpsFsCmd.exec();
         }
     }
+
+    public Host getHost() {
+        return Host.from(
+            getIp(),
+            getBindingPort());
+    }
     
     public String getIp() {
         return cassandraContainer.getContainerIpAddress();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraForwardSmtpTest.java
----------------------------------------------------------------------
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 fdadf26..6f82b82 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
@@ -37,7 +37,7 @@ public class CassandraForwardSmtpTest extends ForwardSmtpTest {
     @Before
     public void setUp() throws Exception {
         Injector injector = Guice.createInjector(
-                new SmtpTestModule(SmtpTestModule.Port.SMTP, cassandraServer.getIp(), cassandraServer.getBindingPort()));
+                new SmtpTestModule(SmtpTestModule.Port.SMTP, cassandraServer.getHost()));
         system = injector.getInstance(SmtpHostSystem.class);
         system.beforeTest();
         super.setUp();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/CassandraSmtpStarttlsCommandTest.java
----------------------------------------------------------------------
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 d448f42..e76ff05 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
@@ -37,7 +37,7 @@ public class CassandraSmtpStarttlsCommandTest extends SmtpStarttlsCommandTest
{
     @Before
     public void setUp() throws Exception {
         Injector injector = Guice.createInjector(
-                new SmtpTestModule(SmtpTestModule.Port.SMTP_START_TTLS, cassandraServer.getIp(),
cassandraServer.getBindingPort()));
+                new SmtpTestModule(SmtpTestModule.Port.SMTP_START_TTLS, cassandraServer.getHost()));
         system = injector.getInstance(SmtpHostSystem.class);
         system.beforeTest();
         super.setUp();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
index d383838..eea9106 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
@@ -19,6 +19,7 @@
 package org.apache.james.mpt.smtp;
 
 import org.apache.james.mpt.smtp.host.CassandraJamesSmtpHostSystem;
+import org.apache.james.util.Host;
 
 import com.google.inject.AbstractModule;
 
@@ -34,20 +35,18 @@ public class SmtpTestModule extends AbstractModule {
             this.port = port;
         }
     }
-    
+
     private final Port smtpPort;
-    private final String cassandraHost;
-    private final int cassandraPort;
+    private final Host cassandraHost;
 
-    public SmtpTestModule(Port smtpPort, String cassandraHost, int cassandraPort) {
+    public SmtpTestModule(Port smtpPort, Host cassandraHost) {
         this.smtpPort = smtpPort;
         this.cassandraHost = cassandraHost;
-        this.cassandraPort = cassandraPort;
     }
     
     @Override
     protected void configure() {
-        bind(SmtpHostSystem.class).toInstance(new CassandraJamesSmtpHostSystem(smtpPort.port,
cassandraHost, cassandraPort));
+        bind(SmtpHostSystem.class).toInstance(new CassandraJamesSmtpHostSystem(smtpPort.port,
cassandraHost));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index e4cd9fa..86dcd33 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -36,6 +36,7 @@ import org.apache.james.mpt.smtp.SmtpHostSystem;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
 import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
 import org.apache.james.server.core.configuration.Configuration;
+import org.apache.james.util.Host;
 import org.apache.james.utils.DataProbeImpl;
 import org.junit.rules.TemporaryFolder;
 
@@ -54,14 +55,12 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory
impleme
 
     private GuiceJamesServer jamesServer;
     private InMemoryDNSService inMemoryDNSService;
-    private final String cassandraHost;
-    private final int cassandraPort;
+    private final Host cassandraHost;
 
 
-    public CassandraJamesSmtpHostSystem(int smtpPort, String cassandraHost, int cassandraPort)
{
+    public CassandraJamesSmtpHostSystem(int smtpPort, Host cassandraHost) {
         super("localhost", smtpPort, new SystemLoggingMonitor(), "220 mydomain.tld smtp");
         this.cassandraHost = cassandraHost;
-        this.cassandraPort = cassandraPort;
     }
 
     @Override
@@ -120,7 +119,7 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory
impleme
                 binder -> binder.bind(MailQueueItemDecoratorFactory.class).to(RawMailQueueItemDecoratorFactory.class),
                 binder -> binder.bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
                     .toInstance(DefaultConfigurationBuilder::new))
-            .overrideWith(new CassandraTestModule(cassandraHost, cassandraPort),
+            .overrideWith(new CassandraTestModule(cassandraHost),
                 (binder) -> binder.bind(DNSService.class).toInstance(inMemoryDNSService));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
index 1a21ca0..23cebc4 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
@@ -22,6 +22,7 @@ package org.apache.james.modules;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
+import org.apache.james.util.Host;
 
 import com.google.inject.AbstractModule;
 
@@ -29,18 +30,16 @@ public class CassandraJmapServerModule extends AbstractModule {
 
     private static final int LIMIT_TO_3_MESSAGES = 3;
     private final EmbeddedElasticSearch embeddedElasticSearch;
-    private final String cassandraHost;
-    private final int cassandraPort;
+    private final Host cassandraHost;
 
-    public CassandraJmapServerModule(EmbeddedElasticSearch embeddedElasticSearch, String
cassandraHost, int cassandraPort) {
+    public CassandraJmapServerModule(EmbeddedElasticSearch embeddedElasticSearch, Host cassandraHost)
{
         this.embeddedElasticSearch = embeddedElasticSearch;
         this.cassandraHost = cassandraHost;
-        this.cassandraPort = cassandraPort;
     }
 
     @Override
     protected void configure() {
-        install(new CassandraTestModule(cassandraHost, cassandraPort));
+        install(new CassandraTestModule(cassandraHost));
         install(new TestElasticSearchModule(embeddedElasticSearch));
         install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
index 6047b85..d2a1415 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraTestModule.java
@@ -22,6 +22,7 @@ package org.apache.james.modules;
 import javax.inject.Singleton;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.util.Host;
 
 import com.datastax.driver.core.Session;
 import com.google.inject.AbstractModule;
@@ -29,22 +30,20 @@ import com.google.inject.Provides;
 import com.google.inject.name.Names;
 
 public class CassandraTestModule extends AbstractModule {
-    private final String cassandraHost;
-    private final int cassandraPort;
+    private final Host cassandraHost;
 
-    public CassandraTestModule(String cassandraHost, int cassandraPort) {
+    public CassandraTestModule(Host cassandraHost) {
         this.cassandraHost = cassandraHost;
-        this.cassandraPort = cassandraPort;
     }
 
     @Override
     protected void configure() {
         install(binder -> binder.bindConstant()
             .annotatedWith(Names.named("cassandraHost"))
-            .to(cassandraHost));
+            .to(cassandraHost.getHostName()));
         install(binder -> binder.bindConstant()
             .annotatedWith(Names.named("cassandraPort"))
-            .to(cassandraPort));
+            .to(cassandraHost.getPort()));
     }
 
     @Provides

http://git-wip-us.apache.org/repos/asf/james-project/blob/a1c8bfc2/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
index 0b17454..cc6f34d 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
@@ -71,7 +71,7 @@ public class CassandraStepdefs {
 
         mainStepdefs.jmapServer = new GuiceJamesServer(configuration)
                 .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
-                .overrideWith(new CassandraJmapServerModule(embeddedElasticSearch, cassandraServer.getIp(),
cassandraServer.getBindingPort()))
+                .overrideWith(new CassandraJmapServerModule(embeddedElasticSearch, cassandraServer.getHost()))
                 .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class));
         mainStepdefs.awaitMethod = () -> embeddedElasticSearch.awaitForElasticSearch();
         mainStepdefs.init();


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