james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [2/4] james-project git commit: MAILET-149 Factorize uses of getIp on SwarmGenericContainer
Date Tue, 24 Jan 2017 09:49:44 GMT
MAILET-149 Factorize uses of getIp on SwarmGenericContainer


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

Branch: refs/heads/master
Commit: 65cf1c8cb704e6c1db930c943223f23abe6fd530
Parents: 6cdc4d5
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Jan 24 08:45:01 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Jan 24 16:49:03 2017 +0700

----------------------------------------------------------------------
 .../main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java   | 6 ++----
 .../src/test/java/org/apache/james/DockerCassandraRule.java    | 6 ++----
 .../org/apache/james/util/streams/SwarmGenericContainer.java   | 5 +++++
 .../java/org/apache/james/transport/mailets/amqp/AmqpRule.java | 6 +-----
 4 files changed, 10 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/65cf1c8c/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
index e27c9e0..293e364 100644
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
@@ -35,7 +35,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
-import org.testcontainers.containers.GenericContainer;
 
 import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
@@ -52,7 +51,7 @@ public class ForwardSmtpTest extends AbstractSimpleScriptedTestProtocol
{
     public static final String PASSWORD = "secret";
 
     private final TemporaryFolder folder = new TemporaryFolder();
-    private final GenericContainer<?> fakeSmtp = new SwarmGenericContainer("weave/rest-smtp-sink:latest")
+    private final SwarmGenericContainer fakeSmtp = new SwarmGenericContainer("weave/rest-smtp-sink:latest")
             .withAffinityToContainer();
     
     @Rule
@@ -66,10 +65,9 @@ public class ForwardSmtpTest extends AbstractSimpleScriptedTestProtocol
{
     }
 
     @Before
-    @SuppressWarnings("deprecation")
     public void setUp() throws Exception {
         super.setUp();
-        InetAddress containerIp = InetAddresses.forString(fakeSmtp.getContainerInfo().getNetworkSettings().getIpAddress());
+        InetAddress containerIp = InetAddresses.forString(fakeSmtp.getIp());
         hostSystem.getInMemoryDnsService()
             .registerRecord("yopmail.com", new InetAddress[]{containerIp}, ImmutableList.of("yopmail.com"),
ImmutableList.of());
         hostSystem.addAddressMapping(USER, DOMAIN, "ray@yopmail.com");

http://git-wip-us.apache.org/repos/asf/james-project/blob/65cf1c8c/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
index fa01e1c..e482214 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java
@@ -25,7 +25,6 @@ import org.apache.james.modules.mailbox.CassandraSessionConfiguration;
 import org.apache.james.util.streams.SwarmGenericContainer;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
-import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.shaded.com.github.dockerjava.api.model.ExposedPort;
 import org.testcontainers.shaded.com.github.dockerjava.api.model.Ports;
 import org.testcontainers.shaded.com.github.dockerjava.api.model.Ports.Binding;
@@ -54,7 +53,7 @@ public class DockerCassandraRule implements GuiceModuleTestRule {
         return configuration;
     }
 
-    private GenericContainer<SwarmGenericContainer> cassandraContainer = new SwarmGenericContainer("cassandra:2.2");
+    private SwarmGenericContainer cassandraContainer = new SwarmGenericContainer("cassandra:2.2");
 
     @Override
     public Statement apply(Statement base, Description description) {
@@ -70,9 +69,8 @@ public class DockerCassandraRule implements GuiceModuleTestRule {
         return (binder) -> binder.bind(CassandraSessionConfiguration.class).toInstance(this::getCassandraConfigurationForDocker);
     }
 
-    @SuppressWarnings("deprecation")
     public String getIp() {
-        return cassandraContainer.getContainerInfo().getNetworkSettings().getIpAddress();
+        return cassandraContainer.getIp();
     }
 
     public int getBindingPort() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/65cf1c8c/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
b/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
index cad3018..6bbe0af 100644
--- a/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
+++ b/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
@@ -47,4 +47,9 @@ public class SwarmGenericContainer extends GenericContainer<SwarmGenericContaine
         setEnv(envVariables);
         return self();
     }
+
+    @SuppressWarnings("deprecation")
+    public String getIp() {
+        return getContainerInfo().getNetworkSettings().getIpAddress();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/65cf1c8c/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
index c59f2c3..08e831f 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
@@ -20,7 +20,6 @@
 package org.apache.james.transport.mailets.amqp;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -30,7 +29,6 @@ import org.junit.rules.ExternalResource;
 
 import com.google.common.base.Charsets;
 import com.google.common.base.Throwables;
-import com.google.common.net.InetAddresses;
 import com.jayway.awaitility.Awaitility;
 import com.rabbitmq.client.BuiltinExchangeType;
 import com.rabbitmq.client.Channel;
@@ -56,9 +54,7 @@ public class AmqpRule extends ExternalResource {
 
     @Override
     protected void before() throws Throwable {
-        @SuppressWarnings("deprecation")
-        InetAddress containerIp = InetAddresses.forString(rabbitMqContainer.getContainerInfo().getNetworkSettings().getIpAddress());
-        amqpUri = "amqp://" + containerIp.getHostAddress();
+        amqpUri = "amqp://" + rabbitMqContainer.getIp();
         ConnectionFactory factory = new ConnectionFactory();
         factory.setUri(amqpUri);
         waitingForRabbitToBeReady(factory);


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