Class ContainerConnectionDetailsFactory<D extends ConnectionDetails,C extends org.testcontainers.containers.Container<?>>
java.lang.Object
org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory<D,C>
- Type Parameters:
D
- the connection details typeC
- the generic container type
- All Implemented Interfaces:
ConnectionDetailsFactory<ContainerConnectionSource<C>,
D>
public abstract class ContainerConnectionDetailsFactory<D extends ConnectionDetails,C extends org.testcontainers.containers.Container<?>>
extends Object
implements ConnectionDetailsFactory<ContainerConnectionSource<C>,D>
Base class for
ConnectionDetailsFactory
implementations that provide
ConnectionDetails
from a ContainerConnectionSource
.- Since:
- 3.1.0
- Author:
- Moritz Halbritter, Andy Wilkinson, Phillip Webb
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Convenient base class forConnectionDetails
results that are backed by aContainerConnectionSource
. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Constant passed to the constructor when any connection name is accepted. -
Constructor Summary
ModifierConstructorDescriptionprotected
Create a newContainerConnectionDetailsFactory
instance that acceptsany connection name
.protected
ContainerConnectionDetailsFactory
(String connectionName, String... requiredClassNames) Create a newContainerConnectionDetailsFactory
instance with the given connection name restriction. -
Method Summary
Modifier and TypeMethodDescriptionfinal D
Get theConnectionDetails
from the givensource
.protected abstract D
-
Field Details
-
ANY_CONNECTION_NAME
Constant passed to the constructor when any connection name is accepted.
-
-
Constructor Details
-
ContainerConnectionDetailsFactory
protected ContainerConnectionDetailsFactory()Create a newContainerConnectionDetailsFactory
instance that acceptsany connection name
. -
ContainerConnectionDetailsFactory
Create a newContainerConnectionDetailsFactory
instance with the given connection name restriction.- Parameters:
connectionName
- the required connection name orANY_CONNECTION_NAME
requiredClassNames
- the names of classes that must be present
-
-
Method Details
-
getConnectionDetails
Description copied from interface:ConnectionDetailsFactory
- Specified by:
getConnectionDetails
in interfaceConnectionDetailsFactory<D extends ConnectionDetails,
C extends org.testcontainers.containers.Container<?>> - Parameters:
source
- the source- Returns:
- the connection details or
null
-
getContainerConnectionDetails
Get theConnectionDetails
from the givenContainerConnectionSource
source
. May returnnull
if no connection can be created. Result types should consider extendingContainerConnectionDetailsFactory.ContainerConnectionDetails
.- Parameters:
source
- the source- Returns:
- the service connection or
null
.
-