Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Examples of different use cases provided by Testcontainers can be found below:
- [Zookeeper](https://github.com/testcontainers/testcontainers-java/tree/main/examples/zookeeper)
- [NATS](https://github.com/testcontainers/testcontainers-java/tree/main/examples/nats)
- [SFTP](https://github.com/testcontainers/testcontainers-java/tree/main/examples/sftp)
- [Ollama with Hugging Face](https://github.com/testcontainers/testcontainers-java/tree/main/examples/ollama-hugging-face)
2 changes: 2 additions & 0 deletions docs/modules/databases/neo4j.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Note that it's based on the [official Docker image](https://hub.docker.com/_/neo
Even though the latest LTS version of Neo4j 4.4 is used in the examples of this documentation,
the Testcontainers integration supports also newer 5.x images of Neo4j.

For a complete runnable example, see the [Neo4j example](https://github.com/testcontainers/testcontainers-java/tree/main/examples/neo4j-container).

## Usage example

You can start a Neo4j container instance from any Java application by using:
Expand Down
2 changes: 2 additions & 0 deletions docs/modules/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Currently, two different Kafka images are supported:
`org.testcontainers.containers.KafkaContainer` is deprecated.
Please use `org.testcontainers.kafka.ConfluentKafkaContainer` or `org.testcontainers.kafka.KafkaContainer` instead, depending on the used image.

For a runnable multi-broker setup, see the [Kafka cluster example](https://github.com/testcontainers/testcontainers-java/tree/main/examples/kafka-cluster).

## Benefits

* Running a single node Kafka installation with just one line of code
Expand Down
2 changes: 2 additions & 0 deletions docs/modules/ollama.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Testcontainers module for [Ollama](https://hub.docker.com/r/ollama/ollama) .

For a complete runnable application using this module, see the [Ollama Hugging Face example](https://github.com/testcontainers/testcontainers-java/tree/main/examples/ollama-hugging-face).

## Ollama's usage examples

You can start an Ollama container instance from any Java application by using:
Expand Down
2 changes: 2 additions & 0 deletions docs/modules/solr.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This module helps running [solr](https://solr.apache.org/) using Testcontainers.

Note that it's based on the [official Docker image](https://hub.docker.com/_/solr/).

For a complete runnable example, see the [Solr example](https://github.com/testcontainers/testcontainers-java/tree/main/examples/solr-container).

## Usage example

You can start a solr container instance from any Java application by using:
Expand Down
2 changes: 2 additions & 0 deletions docs/modules/webdriver_containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Note the factory must implement `org.testcontainers.containers.RecordingFileFact

A few different examples are shown in [ChromeWebDriverContainerTest.java](https://github.com/testcontainers/testcontainers-java/blob/main/modules/selenium/src/test/java/org/testcontainers/selenium/ChromeWebDriverContainerTest.java).

A complete runnable Spring Boot application using a Selenium container is available in the [Selenium example](https://github.com/testcontainers/testcontainers-java/tree/main/examples/selenium-container).

## Adding this module to your project dependencies

Add the following dependency to your `pom.xml`/`build.gradle` file:
Expand Down
11 changes: 3 additions & 8 deletions docs/test_framework_integration/junit_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@

Add a `@Rule` or `@ClassRule` annotated field to your test class, e.g.:

```java
public class SimpleMySQLTest {
@Rule
public MySQLContainer mysql = new MySQLContainer();

// [...]
}
```
<!--codeinclude-->
[JUnit 4 `@Rule` annotated container field](../examples/junit4/redis/src/test/java/quickstart/RedisBackedCacheIntTest.java) inside_block:rule
<!--/codeinclude-->


## Manually controlling container lifecycle
Expand Down
24 changes: 4 additions & 20 deletions docs/test_framework_integration/manual_lifecycle_control.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,11 @@ Sometimes it might be useful to define a container that is only started once for
There is no special support for this use case provided by the Testcontainers extension.
Instead this can be implemented using the following pattern:

```java
abstract class AbstractContainerBaseTest {

static final MySQLContainer MY_SQL_CONTAINER;

static {
MY_SQL_CONTAINER = new MySQLContainer();
MY_SQL_CONTAINER.start();
}
}
<!--codeinclude-->
[Singleton container base class](../../examples/singleton-container/src/test/java/com/example/AbstractIntegrationTest.java) block:AbstractIntegrationTest
<!--/codeinclude-->

class FirstTest extends AbstractContainerBaseTest {

@Test
void someTestMethod() {
String url = MY_SQL_CONTAINER.getJdbcUrl();

// create a connection and run test as normal
}
}
```
For a complete set of test classes using this pattern, see the [singleton container example](https://github.com/testcontainers/testcontainers-java/tree/main/examples/singleton-container).

The singleton container is started only once when the base class is loaded.
The container can then be used by all inheriting test classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ void shouldCallActualMockserverVersion() {
try (MockServerClient client = new MockServerClient(mockServer.getHost(), mockServer.getServerPort())) {
assertThat(client.hasStarted()).as("Mockserver running").isTrue();

// testSimpleExpectation {
client.when(request().withPath("/hello")).respond(response().withBody(expectedBody));
// }

assertThat(given().when().get(mockServer.getEndpoint() + "/hello").then().extract().body().asString())
.as("MockServer returns correct result")
Expand Down
Loading