-
Notifications
You must be signed in to change notification settings - Fork 40.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow org.testcontainers.containers.DockerComposeContainer as a source for ContainerConnectionDetailsFactory #43174
Labels
type: enhancement
A general enhancement
Milestone
Comments
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged
label
Nov 15, 2024
With the following patch, Spring Boot project still compiles: Index: spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java
--- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java (revision f77c3bbd6bddfb09041a63470a10974e09ebf424)
+++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java (date 1731667616310)
@@ -20,8 +20,6 @@
import java.util.Set;
import java.util.stream.Collectors;
-import org.testcontainers.containers.Container;
-
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
@@ -91,7 +89,7 @@
* Relevant details from {@link ContainerConnectionSource} used as a
* MergedContextConfiguration cache key.
*/
- private record CacheKey(String connectionName, Set<Class<?>> connectionDetailsTypes, Container<?> container) {
+ private record CacheKey(String connectionName, Set<Class<?>> connectionDetailsTypes, Object container) {
CacheKey(ContainerConnectionSource<?> source) {
this(source.getConnectionName(), source.getConnectionDetailsTypes(), source.getContainerSupplier().get());
Index: spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionSource.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionSource.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionSource.java
--- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionSource.java (revision f77c3bbd6bddfb09041a63470a10974e09ebf424)
+++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionSource.java (date 1731667535088)
@@ -42,7 +42,7 @@
* @since 3.1.0
* @see ContainerConnectionDetailsFactory
*/
-public final class ContainerConnectionSource<C extends Container<?>> implements OriginProvider {
+public final class ContainerConnectionSource<C> implements OriginProvider {
private static final Log logger = LogFactory.getLog(ContainerConnectionSource.class);
Index: spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionDetailsFactory.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionDetailsFactory.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionDetailsFactory.java
--- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionDetailsFactory.java (revision f77c3bbd6bddfb09041a63470a10974e09ebf424)
+++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionDetailsFactory.java (date 1731667526709)
@@ -53,7 +53,7 @@
* @author Phillip Webb
* @since 3.1.0
*/
-public abstract class ContainerConnectionDetailsFactory<C extends Container<?>, D extends ConnectionDetails>
+public abstract class ContainerConnectionDetailsFactory<C, D extends ConnectionDetails>
implements ConnectionDetailsFactory<ContainerConnectionSource<C>, D> {
/**
|
philwebb
changed the title
Allow
Allow org.testcontainers.containers.DockerComposeContainer as a source for ContainerConnectionDetailsFactory
Nov 15, 2024
org.testcontainers.containers.DockerComposeContainer
as a source for ContainerConnectionDetailsFactory
philwebb
added
for: team-meeting
An issue we'd like to discuss as a team to make progress
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged
for: team-meeting
An issue we'd like to discuss as a team to make progress
labels
Nov 15, 2024
Thanks for the report. We discussed this today as a team and we would like to support We'll have to think about how we can support this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to define a new
ConnectionDetails
type for https://github.com/eclipse/kapua .Eclipse Kapua
can only be run via Docker compose. To achieve that, I run it successfully viaorg.testcontainers.containers.DockerComposeContainer
.I added a
KapuaConnectionDetails
:I would have expected to be able to plug
DockerComposeContainer
as source ofContainerConnectionDetailsFactory
.But the current signature of
ContainerConnectionDetailsFactory
is:Because of that,
C
excludesorg.testcontainers.containers.DockerComposeContainer
.By looking at
ContainerConnectionDetailsFactory
, I didn't find a good reason for whyC
is restricted toContainer<?>
.ContainerConnectionDetailsFactory
and its dependencies do not useContainer<?>
's method. The only used method is fromStartable
, and it is only used after a cast check:spring-boot/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionDetailsFactory.java
Lines 190 to 192 in c6619dd
Could we relax
C
restriction to allowDockerComposeContainer
usage?The text was updated successfully, but these errors were encountered: