Skip to content

Commit

Permalink
JAMES-2070 Make LDAP integration tests pass and remove unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Jun 30, 2017
1 parent cec7d29 commit eca1bbf
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 43 deletions.
3 changes: 2 additions & 1 deletion backends-common/elasticsearch/pom.xml
Expand Up @@ -178,7 +178,8 @@
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
<version>1.1.7</version> <version>1.3.1</version>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
Expand Down
5 changes: 5 additions & 0 deletions mailbox/elasticsearch/pom.xml
Expand Up @@ -279,6 +279,11 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions mailbox/pom.xml
Expand Up @@ -633,6 +633,11 @@
<artifactId>assertj-guava</artifactId> <artifactId>assertj-guava</artifactId>
<version>1.3.1</version> <version>1.3.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>


Expand Down
4 changes: 3 additions & 1 deletion mailbox/tika/pom.xml
Expand Up @@ -209,7 +209,9 @@
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
<version>1.1.7</version> <scope>test</scope>
<version>1.3.1</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion mpt/pom.xml
Expand Up @@ -496,7 +496,7 @@
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
<version>1.1.7</version> <version>1.3.1</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
Expand Down
Expand Up @@ -25,18 +25,17 @@
import org.apache.james.util.streams.SwarmGenericContainer; import org.apache.james.util.streams.SwarmGenericContainer;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
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;


import com.github.dockerjava.api.model.ExposedPort;
import com.github.dockerjava.api.model.Ports;
import com.google.inject.Module; import com.google.inject.Module;




public class DockerCassandraRule implements GuiceModuleTestRule { public class DockerCassandraRule implements GuiceModuleTestRule {


private static final int CASSANDRA_PORT = 9042; private static final int CASSANDRA_PORT = 9042;


private static boolean isBindingToEveryThing(Binding binding) { private static boolean isBindingToEveryThing(Ports.Binding binding) {
String bindingIp = binding.getHostIp(); String bindingIp = binding.getHostIp();
return bindingIp == null || bindingIp.equals("0.0.0.0"); return bindingIp == null || bindingIp.equals("0.0.0.0");
} }
Expand Down
Expand Up @@ -19,15 +19,11 @@


package org.apache.james; package org.apache.james;


import java.util.Arrays;

import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.james.modules.mailbox.ElasticSearchConfiguration; import org.apache.james.modules.mailbox.ElasticSearchConfiguration;
import org.apache.james.util.streams.SwarmGenericContainer; import org.apache.james.util.streams.SwarmGenericContainer;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
import org.testcontainers.shaded.com.github.dockerjava.api.model.ExposedPort;
import org.testcontainers.shaded.com.github.dockerjava.api.model.Ports.Binding;


import com.google.inject.Module; import com.google.inject.Module;


Expand All @@ -37,11 +33,6 @@ public class DockerElasticSearchRule implements GuiceModuleTestRule {
private static final int ELASTIC_SEARCH_PORT = 9300; private static final int ELASTIC_SEARCH_PORT = 9300;
public static final int ELASTIC_SEARCH_HTTP_PORT = 9200; public static final int ELASTIC_SEARCH_HTTP_PORT = 9200;


private static boolean isBindingToEveryThing(Binding binding) {
String bindingIp = binding.getHostIp();
return bindingIp == null || bindingIp.equals("0.0.0.0");
}

public PropertiesConfiguration getElasticSearchConfigurationForDocker() { public PropertiesConfiguration getElasticSearchConfigurationForDocker() {
PropertiesConfiguration configuration = new PropertiesConfiguration(); PropertiesConfiguration configuration = new PropertiesConfiguration();


Expand Down Expand Up @@ -82,21 +73,6 @@ public String getIp() {
return elasticSearchContainer.getIp(); return elasticSearchContainer.getIp();
} }


public int getBindingPort() {
Binding[] bindings = elasticSearchContainer
.getContainerInfo()
.getNetworkSettings()
.getPorts()
.getBindings()
.get(ExposedPort.tcp(ELASTIC_SEARCH_PORT));

return Integer.valueOf(
Arrays.stream(bindings)
.filter(DockerElasticSearchRule::isBindingToEveryThing)
.map(binding -> binding.getHostPortSpec())
.findFirst().get());
}

public SwarmGenericContainer getElasticSearchContainer() { public SwarmGenericContainer getElasticSearchContainer() {
return elasticSearchContainer; return elasticSearchContainer;
} }
Expand Down
Expand Up @@ -31,8 +31,8 @@
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.WaitStrategy; import org.testcontainers.containers.wait.WaitStrategy;
import org.testcontainers.images.builder.ImageFromDockerfile; import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.shaded.com.github.dockerjava.api.command.InspectContainerResponse;


import com.github.dockerjava.api.command.InspectContainerResponse;
import com.google.common.base.Strings; import com.google.common.base.Strings;


public class SwarmGenericContainer implements TestRule { public class SwarmGenericContainer implements TestRule {
Expand Down Expand Up @@ -105,14 +105,6 @@ public void stop() {
container.stop(); container.stop();
} }


public String getContainerIpAddress() {
return container.getContainerIpAddress();
}

public Integer getMappedPort(int originalPort) {
return container.getMappedPort(originalPort);
}

@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String getIp() { public String getIp() {
return getContainerInfo().getNetworkSettings().getIpAddress(); return getContainerInfo().getNetworkSettings().getIpAddress();
Expand All @@ -121,6 +113,7 @@ public String getIp() {
public InspectContainerResponse getContainerInfo() { public InspectContainerResponse getContainerInfo() {
return container.getContainerInfo(); return container.getContainerInfo();
} }

@Override @Override
public Statement apply(Statement statement, Description description) { public Statement apply(Statement statement, Description description) {
return container.apply(statement, description); return container.apply(statement, description);
Expand Down
Expand Up @@ -85,8 +85,8 @@ public void stop() {


public String getLdapHost() { public String getLdapHost() {
return "ldap://" + return "ldap://" +
container.getContainerIpAddress() + container.getIp() +
":" + ":" +
container.getMappedPort(LdapGenericContainer.DEFAULT_LDAP_PORT); LdapGenericContainer.DEFAULT_LDAP_PORT;
} }
} }
2 changes: 1 addition & 1 deletion server/pom.xml
Expand Up @@ -182,7 +182,7 @@
<assertj-1.version>1.7.1</assertj-1.version> <assertj-1.version>1.7.1</assertj-1.version>
<assertj-1-guava.version>1.3.1</assertj-1-guava.version> <assertj-1-guava.version>1.3.1</assertj-1-guava.version>
<assertj-3.version>3.3.0</assertj-3.version> <assertj-3.version>3.3.0</assertj-3.version>
<testcontainers-version>1.1.7</testcontainers-version> <testcontainers-version>1.3.1</testcontainers-version>
<guavate.version>1.0.0</guavate.version> <guavate.version>1.0.0</guavate.version>
<metrics.version>3.2.1</metrics.version> <metrics.version>3.2.1</metrics.version>
<joda.version>2.9.4</joda.version> <joda.version>2.9.4</joda.version>
Expand Down
Expand Up @@ -265,6 +265,11 @@
<type>test-jar</type> <type>test-jar</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
Expand Down
Expand Up @@ -233,6 +233,11 @@
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId> <artifactId>java-hamcrest</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
Expand Down

0 comments on commit eca1bbf

Please sign in to comment.