Interface ServerAdapter
public interface ServerAdapter
An adapter for application runtimes can use to define information including:
- Default HTTP port
- Default HTTPS port
- Default startup timeout
- Default Dockerfile
- Default readiness path
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
An optional hook that may be implemented for the purposes of auto-wiring multiple containers the the test environment together.default int
int
int
default org.testcontainers.images.builder.ImageFromDockerfile
getDefaultImage
(File appFile) Returns a default Docker image using the current ServerAdapter as the base later and the provided appFile in addition to any other vendor-speicific items layerd on top.default int
Defines the readiness path for the Server which will be used by default when the developer did not specify such value.default void
setConfigProperties
(Map<String, String> properties) Sets configuration properties on an already-started runtime.
-
Field Details
-
PRIORITY_USER_DEFAULT
static final int PRIORITY_USER_DEFAULT- See Also:
-
PRIORITY_DEFAULT
static final int PRIORITY_DEFAULT- See Also:
-
PRIORITY_RUNTIME_MODULE
static final int PRIORITY_RUNTIME_MODULE- See Also:
-
-
Method Details
-
getPriority
default int getPriority() -
getDefaultHttpPort
int getDefaultHttpPort()- Returns:
- The default HTTP port for this runtime
-
getDefaultHttpsPort
int getDefaultHttpsPort()- Returns:
- The default HTTPS port for this runtime
-
getDefaultAppStartTimeout
default int getDefaultAppStartTimeout()- Returns:
- The default amount of time (in seconds) to wait for a runtime to start before assuming that application start has failed and aborting the start process. Implementation note: It is reccomended to increase the default app start timeout when running in remote CI environments such as TravisCI by checking for the CI=true env var.
-
setConfigProperties
Sets configuration properties on an already-started runtime. If the runtime has not been started yet, it may be more efficient to use other means of setting properties, such asGenericContainer.withEnv(String,String)
in the case of Testcontainers. Calling this method will override any previously set properties using this method- Parameters:
properties
- A map of key/value pairs that should be set on the runtime
-
getDefaultImage
Returns a default Docker image using the current ServerAdapter as the base later and the provided appFile in addition to any other vendor-speicific items layerd on top.- Parameters:
appFile
- The application file to include in the resulting Docker image- Returns:
- The default docker image including the supplied appFile
-
getReadinessPath
Defines the readiness path for the Server which will be used by default when the developer did not specify such value.- Returns:
- the readiness path to be used by default, or an empty Optional if no default value is provided.
-
configure
An optional hook that may be implemented for the purposes of auto-wiring multiple containers the the test environment together.For example, the
LibertyAdapter
detects the presence of a KafkaContainer and will automatically configure the ApplicationContainer to communicate with it by callingGenericContainer.withEnv(String, String)
- Parameters:
allContainers
- An unmodifiable set of the containers discovered in the test environment
-