Please switch to branch 'workshop'
This is an overview of the exercises for the workshop. There are several exercises spread across the source files.
You can find all exercises when you do a fulltext search for EXERCISE
. There is also an overview below.
- EXERCISE 1: HelloWorld integration test with testcontainer on-the-fly (JUnit 5)
- EXERCISE 2: HelloWorld cucumber test with manual container management (JUnit 4)
- EXERCISE 3: DbUnit persistence test with Postgres DB (JUnit 4)
- EXERCISE 4: Todo-List integration test with two testcontainers (JUnit 4)
- EXERCISE 5: Todo-List integration test with DockerCompose (JUnit 4)
- EXERCISE 6: TodoGatewayResource integration test with Mockserver (JUnit 5)
The exercise can be found in HelloWorldResourceIT.java.
Todos:
- add
@Testcontainers
annotation to test class - add
GenericContainer
withImageFromDockerfile
& useDockerfileBuilder
- add log consumer to receive container logs
- get host and port from container
The exercise can be found in HelloWorldResourceCucumberIT while the implementation has to be done in hello-world/Dockerfile and in HelloWorldResourceCucumberTestContainerBaseClass.java
Todos:
- prepare
Dockerfile
- add
GenericContainer
withImageFromDockerfile
- call start/stop
- get host and port from container
The exercise can be found in TodoRepositoryIT.java. The schema for the tables can be found in in the resources/docker folder of the todo-list-service.
Todos:
- add
FixedHostPortGenericContainer
with postgres image - set environment variables for database configuration (database, user, password)
- add DDL script
- replace
FixedHostPortGenericContainer
byGenericContainer
- override JDBC Url
The exercise can be found in TodoResourceIT.java.
Note: Exercise 5 is also in the same file.
Todos:
- add
Network
to link the two testcontainers - add
FixedHostGenericContainer
with postgres image (name = database) - add
GenericContainer
with todo-list-service image (name = service) - get host and port from container
The exercise can be found in TodoResourceIT.java.
Todos:
5. set up DockerCompose
Container
6. replace GenericContainer
with DockerComposeContainer
7. override JDBC Url
8. get host and port from container
The exercise can be found in TodoGatewayResourceIT.java.
Todos:
- add
@Testcontainers
annotation to test class - add
Network
to link the two testcontainers - add
MockServerContainer
- add
GenericContainer
with todo-list-gateway image - get host and port from gateway container