You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/04/05 08:22:28 UTC
(camel) 01/02: (chores) camel-test-infra-openldap: decouple the container from the local service
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 88d6be77241b69ac933a3000e0251c7c5e91e711
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Apr 4 17:39:02 2024 +0200
(chores) camel-test-infra-openldap: decouple the container from the local service
---
.../infra/openldap/services/OpenLdapContainer.java | 18 ++++++++
.../services/OpenldapLocalContainerService.java | 53 ++--------------------
2 files changed, 22 insertions(+), 49 deletions(-)
diff --git a/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenLdapContainer.java b/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenLdapContainer.java
new file mode 100644
index 00000000000..ccb6a0a33ea
--- /dev/null
+++ b/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenLdapContainer.java
@@ -0,0 +1,18 @@
+package org.apache.camel.test.infra.openldap.services;
+
+import org.apache.camel.test.infra.common.LocalPropertyResolver;
+import org.apache.camel.test.infra.openldap.common.OpenldapProperties;
+import org.testcontainers.containers.GenericContainer;
+
+public class OpenLdapContainer extends GenericContainer<OpenLdapContainer> {
+ public static final String CONTAINER_NAME = "openldap";
+ public static final int CONTAINER_PORT_LDAP = 389;
+ public static final int CONTAINER_PORT_LDAP_OVER_SSL = 636;
+
+ public OpenLdapContainer() {
+ super(LocalPropertyResolver.getProperty(OpenldapLocalContainerService.class, OpenldapProperties.OPENLDAP_CONTAINER));
+
+ this.withExposedPorts(CONTAINER_PORT_LDAP, CONTAINER_PORT_LDAP_OVER_SSL)
+ .withNetworkAliases(CONTAINER_NAME);
+ }
+}
diff --git a/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenldapLocalContainerService.java b/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenldapLocalContainerService.java
index 58efb15d1f8..bc2b057ca97 100644
--- a/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenldapLocalContainerService.java
+++ b/test-infra/camel-test-infra-openldap/src/test/java/org/apache/camel/test/infra/openldap/services/OpenldapLocalContainerService.java
@@ -16,66 +16,21 @@
*/
package org.apache.camel.test.infra.openldap.services;
-import org.apache.camel.test.infra.common.LocalPropertyResolver;
import org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.openldap.common.OpenldapProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.FixedHostPortGenericContainer;
-import org.testcontainers.containers.GenericContainer;
-public class OpenldapLocalContainerService implements OpenldapService, ContainerService<GenericContainer> {
-
- public static final String OPENLDAP_CONTAINER_PROPERTY = "openldap.container";
- public static final String CONTAINER_NAME = "openldap";
+public class OpenldapLocalContainerService implements OpenldapService, ContainerService<OpenLdapContainer> {
public static final int CONTAINER_PORT_LDAP = 389;
public static final int CONTAINER_PORT_LDAP_OVER_SSL = 636;
private static final Logger LOG = LoggerFactory.getLogger(OpenldapLocalContainerService.class);
- private final GenericContainer container;
+ private final OpenLdapContainer container;
public OpenldapLocalContainerService() {
- this(LocalPropertyResolver.getProperty(OpenldapLocalContainerService.class, OPENLDAP_CONTAINER_PROPERTY));
- }
-
- public OpenldapLocalContainerService(int port, int sslPort) {
- String imageName = System.getProperty(
- OpenldapProperties.OPENLDAP_CONTAINER,
- LocalPropertyResolver.getProperty(OpenldapLocalContainerService.class, OPENLDAP_CONTAINER_PROPERTY));
-
- container = initContainer(imageName, port, sslPort);
- }
-
- public OpenldapLocalContainerService(String imageName) {
- container = initContainer(imageName, null, null);
- }
-
- public OpenldapLocalContainerService(GenericContainer container) {
- this.container = container;
- }
-
- protected GenericContainer initContainer(String imageName, Integer port, Integer sslPort) {
- GenericContainer ret;
-
- if (port == null) {
- ret = new GenericContainer(imageName)
- .withExposedPorts(CONTAINER_PORT_LDAP, CONTAINER_PORT_LDAP_OVER_SSL);
- } else {
- @SuppressWarnings("deprecation")
- FixedHostPortGenericContainer fixedPortContainer = new FixedHostPortGenericContainer(imageName)
- .withFixedExposedPort(port, CONTAINER_PORT_LDAP);
-
- if (sslPort != null) {
- fixedPortContainer.withFixedExposedPort(sslPort, CONTAINER_PORT_LDAP_OVER_SSL);
- }
-
- ret = fixedPortContainer;
- }
-
- ret.withNetworkAliases(CONTAINER_NAME);
-
- return ret;
+ container = new OpenLdapContainer();
}
@Override
@@ -100,7 +55,7 @@ public class OpenldapLocalContainerService implements OpenldapService, Container
}
@Override
- public GenericContainer getContainer() {
+ public OpenLdapContainer getContainer() {
return container;
}