diff --git a/cassandra/README.md b/cassandra/README.md
index 90f1e20..8e642fe 100644
--- a/cassandra/README.md
+++ b/cassandra/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-cassandra:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-cassandra:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-cassandra:0.6.1"
io.goodforgod
testcontainers-extensions-cassandra
- 0.6.1
+ 0.6.2
test
```
@@ -63,6 +63,7 @@ testImplementation "com.datastax.oss:java-driver-core:4.17.0"
`@TestcontainersCassandra` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -96,9 +97,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `cassandra:4.1`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|cassandra:4.1}`
+
+- Image can have static value: `cassandra:4.1`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|cassandra:4.1}`
### Manual Container
@@ -155,9 +157,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Container Old Driver
diff --git a/cassandra/src/main/java/io/goodforgod/testcontainers/extensions/cassandra/TestcontainersCassandraExtension.java b/cassandra/src/main/java/io/goodforgod/testcontainers/extensions/cassandra/TestcontainersCassandraExtension.java
index 6e0dc8a..255bc78 100644
--- a/cassandra/src/main/java/io/goodforgod/testcontainers/extensions/cassandra/TestcontainersCassandraExtension.java
+++ b/cassandra/src/main/java/io/goodforgod/testcontainers/extensions/cassandra/TestcontainersCassandraExtension.java
@@ -47,10 +47,10 @@ protected CassandraContainer> getContainerDefault(CassandraMetadata metadata)
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(CassandraContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.waitingFor(Wait.forListeningPort())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
diff --git a/cockroachdb/README.md b/cockroachdb/README.md
index be6d24c..562fdb7 100644
--- a/cockroachdb/README.md
+++ b/cockroachdb/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-cockroachdb:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-cockroachdb:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-cockroachdb:0.6.1"
io.goodforgod
testcontainers-extensions-cockroachdb
- 0.6.1
+ 0.6.2
test
```
@@ -62,6 +62,7 @@ testRuntimeOnly "org.postgresql:postgresql:42.6.0"
`@TestcontainersCockroachdb` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -95,9 +96,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `cockroachdb/cockroach:latest-v23.1`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|cockroachdb/cockroach:latest-v23.1}`
+
+- Image can have static value: `cockroachdb/cockroach:latest-v23.1`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|cockroachdb/cockroach:latest-v23.1}`
### Manual Container
@@ -151,9 +153,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Connection
diff --git a/cockroachdb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersCockroachdbExtension.java b/cockroachdb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersCockroachdbExtension.java
index 425dd24..b4a1618 100644
--- a/cockroachdb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersCockroachdbExtension.java
+++ b/cockroachdb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersCockroachdbExtension.java
@@ -2,6 +2,8 @@
import java.lang.annotation.Annotation;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -51,9 +53,9 @@ protected CockroachContainer getContainerDefault(CockroachMetadata metadata) {
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(CockroachContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
diff --git a/gradle.properties b/gradle.properties
index 76d8327..acc0749 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,6 @@
groupId=io.goodforgod
artifactRootId=testcontainers-extensions
-artifactVersion=0.6.1-SNAPSHOT
+artifactVersion=0.6.2-SNAPSHOT
##### GRADLE #####
diff --git a/kafka/README.md b/kafka/README.md
index 0596019..c75eb6b 100644
--- a/kafka/README.md
+++ b/kafka/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-kafka:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-kafka:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-kafka:0.6.1"
io.goodforgod
testcontainers-extensions-kafka
- 0.6.1
+ 0.6.2
test
```
@@ -65,6 +65,7 @@ testRuntimeOnly "org.apache.kafka:kafka-clients:3.5.1"
`@TestcontainersKafka` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -98,9 +99,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `confluentinc/cp-kafka:7.4.1`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|confluentinc/cp-kafka:7.4.1}`
+
+- Image can have static value: `confluentinc/cp-kafka:7.4.1`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|confluentinc/cp-kafka:7.4.1}`
### Manual Container
@@ -157,9 +159,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
### Topics
diff --git a/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/KafkaConnectionImpl.java b/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/KafkaConnectionImpl.java
index 5575813..bdcb106 100644
--- a/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/KafkaConnectionImpl.java
+++ b/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/KafkaConnectionImpl.java
@@ -495,12 +495,14 @@ static void createTopicsIfNeeded(@NotNull KafkaConnection connection, @NotNull S
}
}
- void clear() {
+ void clearProducer() {
if (producer != null) {
producer.close(Duration.ofMinutes(5));
producer = null;
}
+ }
+ void clearConsumer() {
for (var consumer : consumers) {
try {
consumer.close();
@@ -514,12 +516,8 @@ void clear() {
void close() {
if (!isClosed) {
isClosed = true;
- if (producer != null) {
- producer.close(Duration.ofMinutes(5));
- producer = null;
- }
-
- clear();
+ clearProducer();
+ clearConsumer();
}
}
diff --git a/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/TestcontainersKafkaExtension.java b/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/TestcontainersKafkaExtension.java
index 990cc5a..6ec9f12 100644
--- a/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/TestcontainersKafkaExtension.java
+++ b/kafka/src/main/java/io/goodforgod/testcontainers/extensions/kafka/TestcontainersKafkaExtension.java
@@ -39,10 +39,20 @@ private void add(KafkaConnectionImpl connection) {
connections.add(connection);
}
- private void clear() {
+ private void clearProducer() {
for (KafkaConnectionImpl connection : connections) {
try {
- connection.clear();
+ connection.clearProducer();
+ } catch (Exception e) {
+ // do nothing
+ }
+ }
+ }
+
+ private void clearConsumer() {
+ for (KafkaConnectionImpl connection : connections) {
+ try {
+ connection.clearConsumer();
} catch (Exception e) {
// do nothing
}
@@ -94,10 +104,11 @@ protected KafkaContainer getContainerDefault(KafkaMetadata metadata) {
.withEnv("KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE", "false")
.withEnv("AUTO_CREATE_TOPICS", "true")
.withEmbeddedZookeeper()
- .withNetworkAliases(metadata.networkAliasOrDefault())
+ .withExposedPorts(9092, 9093)
.waitingFor(Wait.forListeningPort())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
@@ -244,18 +255,30 @@ public void beforeEach(ExtensionContext context) {
@Override
public void afterEach(ExtensionContext context) {
+ var metadata = getMetadata(context);
var storage = getStorage(context);
var pool = storage.get(KafkaConnectionPool.class, KafkaConnectionPool.class);
- pool.clear();
+ if (metadata.runMode() == ContainerMode.PER_METHOD) {
+ pool.clearProducer();
+ pool.clearConsumer();
+ } else {
+ pool.clearConsumer();
+ }
super.afterEach(context);
}
@Override
public void afterAll(ExtensionContext context) {
+ var metadata = getMetadata(context);
var storage = getStorage(context);
var pool = storage.get(KafkaConnectionPool.class, KafkaConnectionPool.class);
- pool.close();
+ if (metadata.runMode() == ContainerMode.PER_RUN) {
+ pool.clearProducer();
+ pool.clearConsumer();
+ } else {
+ pool.close();
+ }
super.afterAll(context);
}
diff --git a/kafka/src/test/java/io/goodforgod/testcontainers/extensions/kafka/KafkaContainerPerRunFirstTests.java b/kafka/src/test/java/io/goodforgod/testcontainers/extensions/kafka/KafkaContainerPerRunFirstTests.java
new file mode 100644
index 0000000..e913e14
--- /dev/null
+++ b/kafka/src/test/java/io/goodforgod/testcontainers/extensions/kafka/KafkaContainerPerRunFirstTests.java
@@ -0,0 +1,53 @@
+package io.goodforgod.testcontainers.extensions.kafka;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import io.goodforgod.testcontainers.extensions.ContainerMode;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestcontainersKafka(mode = ContainerMode.PER_RUN)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class KafkaContainerPerRunFirstTests {
+
+ static volatile KafkaConnection perRunConnection;
+
+ @ContainerKafkaConnection
+ private KafkaConnection sameConnection;
+
+ @Order(1)
+ @Test
+ void firstConnection(@ContainerKafkaConnection KafkaConnection connection) {
+ assertNotNull(connection);
+ assertNotNull(connection.params().bootstrapServers());
+ assertNotNull(sameConnection);
+ assertEquals(sameConnection, connection);
+
+ if (perRunConnection == null) {
+ perRunConnection = connection;
+ }
+
+ if (KafkaContainerPerRunSecondTests.perRunConnection != null) {
+ assertEquals(perRunConnection, KafkaContainerPerRunSecondTests.perRunConnection);
+ }
+
+ connection.send("my-topic", Event.ofValue("my-value"));
+ sameConnection.send("my-topic", Event.ofValue("my-value"));
+ }
+
+ @Order(2)
+ @Test
+ void secondConnection(@ContainerKafkaConnection KafkaConnection connection) {
+ assertNotNull(connection);
+ assertNotNull(connection.params().bootstrapServers());
+ assertNotNull(sameConnection);
+ assertEquals(sameConnection, connection);
+ assertEquals(perRunConnection, connection);
+
+ connection.send("my-topic", Event.ofValue("my-value"));
+ sameConnection.send("my-topic", Event.ofValue("my-value"));
+ }
+}
diff --git a/kafka/src/test/java/io/goodforgod/testcontainers/extensions/kafka/KafkaContainerPerRunSecondTests.java b/kafka/src/test/java/io/goodforgod/testcontainers/extensions/kafka/KafkaContainerPerRunSecondTests.java
new file mode 100644
index 0000000..269e88c
--- /dev/null
+++ b/kafka/src/test/java/io/goodforgod/testcontainers/extensions/kafka/KafkaContainerPerRunSecondTests.java
@@ -0,0 +1,53 @@
+package io.goodforgod.testcontainers.extensions.kafka;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import io.goodforgod.testcontainers.extensions.ContainerMode;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestcontainersKafka(mode = ContainerMode.PER_RUN)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class KafkaContainerPerRunSecondTests {
+
+ static volatile KafkaConnection perRunConnection;
+
+ @ContainerKafkaConnection
+ private KafkaConnection sameConnection;
+
+ @Order(1)
+ @Test
+ void firstConnection(@ContainerKafkaConnection KafkaConnection connection) {
+ assertNotNull(connection);
+ assertNotNull(connection.params().bootstrapServers());
+ assertNotNull(sameConnection);
+ assertEquals(sameConnection, connection);
+
+ if (perRunConnection == null) {
+ perRunConnection = connection;
+ }
+
+ if (KafkaContainerPerRunFirstTests.perRunConnection != null) {
+ assertEquals(perRunConnection, KafkaContainerPerRunFirstTests.perRunConnection);
+ }
+
+ connection.send("my-topic", Event.ofValue("my-value"));
+ sameConnection.send("my-topic", Event.ofValue("my-value"));
+ }
+
+ @Order(2)
+ @Test
+ void secondConnection(@ContainerKafkaConnection KafkaConnection connection) {
+ assertNotNull(connection);
+ assertNotNull(connection.params().bootstrapServers());
+ assertNotNull(sameConnection);
+ assertEquals(sameConnection, connection);
+ assertEquals(perRunConnection, connection);
+
+ connection.send("my-topic", Event.ofValue("my-value"));
+ sameConnection.send("my-topic", Event.ofValue("my-value"));
+ }
+}
diff --git a/mariadb/README.md b/mariadb/README.md
index d7eff54..aa34e18 100644
--- a/mariadb/README.md
+++ b/mariadb/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-mariadb:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-mariadb:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-mariadb:0.6.1"
io.goodforgod
testcontainers-extensions-mariadb
- 0.6.1
+ 0.6.2
test
```
@@ -62,6 +62,7 @@ testRuntimeOnly "org.mariadb.jdbc:mariadb-java-client:3.1.4"
`@TestcontainersMariadb` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -95,9 +96,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `mariadb:11.0-jammy`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|mariadb:11.0-jammy}`
+
+- Image can have static value: `mariadb:11.0-jammy`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|mariadb:11.0-jammy}`
### Manual Container
@@ -156,9 +158,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Connection
diff --git a/mariadb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMariadbExtension.java b/mariadb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMariadbExtension.java
index 006deae..5939e03 100644
--- a/mariadb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMariadbExtension.java
+++ b/mariadb/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMariadbExtension.java
@@ -2,6 +2,8 @@
import java.lang.annotation.Annotation;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -56,10 +58,10 @@ protected MariaDBContainer> getContainerDefault(MariadbMetadata metadata) {
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(MariaDBContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.waitingFor(Wait.forListeningPort())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
diff --git a/mysql/README.md b/mysql/README.md
index 68fa9ed..4c9ad40 100644
--- a/mysql/README.md
+++ b/mysql/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-mysql:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-mysql:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-mysql:0.6.1"
io.goodforgod
testcontainers-extensions-mysql
- 0.6.1
+ 0.6.2
test
```
@@ -62,6 +62,7 @@ testRuntimeOnly "mysql:mysql-connector-java:8.0.33"
`@TestcontainersMysql` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -95,9 +96,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `mysql:8.0-debian`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|mysql:8.0-debian}`
+
+- Image can have static value: `mysql:8.0-debian`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|mysql:8.0-debian}`
### Manual Container
@@ -156,9 +158,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Connection
diff --git a/mysql/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMysqlExtension.java b/mysql/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMysqlExtension.java
index ef94c5c..fe019ba 100644
--- a/mysql/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMysqlExtension.java
+++ b/mysql/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersMysqlExtension.java
@@ -2,6 +2,8 @@
import java.lang.annotation.Annotation;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -55,10 +57,10 @@ protected MySQLContainer> getContainerDefault(MysqlMetadata metadata) {
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(MySQLContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.waitingFor(Wait.forListeningPort())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
diff --git a/oracle/README.md b/oracle/README.md
index 884ebd6..614f395 100644
--- a/oracle/README.md
+++ b/oracle/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-oracle:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-oracle:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-oracle:0.6.1"
io.goodforgod
testcontainers-extensions-oracle
- 0.6.1
+ 0.6.2
test
```
@@ -65,6 +65,7 @@ Extension tested against image `gvenzl/oracle-xe:18.4.0-faststart` and driver `c
`@TestcontainersOracle` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -98,9 +99,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `gvenzl/oracle-xe:18.4.0-faststart`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|gvenzl/oracle-xe:18.4.0-faststart}`
+
+- Image can have static value: `gvenzl/oracle-xe:18.4.0-faststart`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|gvenzl/oracle-xe:18.4.0-faststart}`
### Manual Container
@@ -157,9 +159,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Connection
diff --git a/oracle/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersOracleExtension.java b/oracle/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersOracleExtension.java
index c641f51..95bf9fd 100644
--- a/oracle/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersOracleExtension.java
+++ b/oracle/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersOracleExtension.java
@@ -2,6 +2,8 @@
import java.lang.annotation.Annotation;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -52,9 +54,9 @@ protected OracleContainer getContainerDefault(OracleMetadata metadata) {
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(OracleContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
diff --git a/postgres/README.md b/postgres/README.md
index a923761..78fe4be 100644
--- a/postgres/README.md
+++ b/postgres/README.md
@@ -18,7 +18,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-postgres:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-postgres:0.6.2"
```
**Maven**
@@ -26,7 +26,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-postgres:0.6.1"
io.goodforgod
testcontainers-extensions-postgres
- 0.6.1
+ 0.6.2
test
```
@@ -62,6 +62,7 @@ testRuntimeOnly "org.postgresql:postgresql:42.6.0"
`@TestcontainersPostgres` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -95,9 +96,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `postgres:15.3-alpine`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|postgres:15.3-alpine}`
+
+- Image can have static value: `postgres:15.3-alpine`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|postgres:15.3-alpine}`
### Manual Container
@@ -156,9 +158,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Connection
diff --git a/postgres/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersPostgresExtension.java b/postgres/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersPostgresExtension.java
index acae847..ff5ea94 100644
--- a/postgres/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersPostgresExtension.java
+++ b/postgres/src/main/java/io/goodforgod/testcontainers/extensions/jdbc/TestcontainersPostgresExtension.java
@@ -2,6 +2,8 @@
import java.lang.annotation.Annotation;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -54,9 +56,9 @@ protected PostgreSQLContainer> getContainerDefault(PostgresMetadata metadata)
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(PostgreSQLContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}
diff --git a/redis/README.md b/redis/README.md
index 92a83b1..29b2a88 100644
--- a/redis/README.md
+++ b/redis/README.md
@@ -17,7 +17,7 @@ Features:
**Gradle**
```groovy
-testImplementation "io.goodforgod:testcontainers-extensions-redis:0.6.1"
+testImplementation "io.goodforgod:testcontainers-extensions-redis:0.6.2"
```
**Maven**
@@ -25,7 +25,7 @@ testImplementation "io.goodforgod:testcontainers-extensions-redis:0.6.1"
io.goodforgod
testcontainers-extensions-redis
- 0.6.1
+ 0.6.2
test
```
@@ -61,6 +61,7 @@ testImplementation "redis.clients:jedis:4.4.3"
`@TestcontainersRedis` - allow **automatically start container** with specified image in different modes without the need to configure it.
Available containers modes:
+
- `PER_RUN` - start container one time per *test execution*. (Containers must have same `image` and `network` to be reused between test classes)
- `PER_CLASS` - start new container each *test class*.
- `PER_METHOD` - start new container each *test method*.
@@ -94,9 +95,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `redis:7.2-alpine`
-2) Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|redis:7.2-alpine}`
+
+- Image can have static value: `redis:7.2-alpine`
+- Image can be provided via environment variable using syntax: `${MY_IMAGE_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_IMAGE_ENV|redis:7.2-alpine}`
### Manual Container
@@ -153,9 +155,10 @@ class ExampleTests {
```
Image syntax:
-1) Image can have static value: `my-alias`
-2) Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
-3) Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
+
+- Image can have static value: `my-alias`
+- Image can be provided via environment variable using syntax: `${MY_ALIAS_ENV}`
+- Image environment variable can have default value if empty using syntax: `${MY_ALIAS_ENV|my-alias-default}`
## Connection
diff --git a/redis/src/main/java/io/goodforgod/testcontainers/extensions/redis/TestcontainersRedisExtension.java b/redis/src/main/java/io/goodforgod/testcontainers/extensions/redis/TestcontainersRedisExtension.java
index 20ebc03..bb51ea5 100644
--- a/redis/src/main/java/io/goodforgod/testcontainers/extensions/redis/TestcontainersRedisExtension.java
+++ b/redis/src/main/java/io/goodforgod/testcontainers/extensions/redis/TestcontainersRedisExtension.java
@@ -3,6 +3,8 @@
import io.goodforgod.testcontainers.extensions.AbstractTestcontainersExtension;
import java.lang.annotation.Annotation;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.NotNull;
@@ -51,10 +53,10 @@ protected RedisContainer getContainerDefault(RedisMetadata metadata) {
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(RedisContainer.class))
.withMdc("image", metadata.image())
.withMdc("alias", metadata.networkAliasOrDefault()))
- .withNetworkAliases(metadata.networkAliasOrDefault())
.waitingFor(Wait.forListeningPort())
.withStartupTimeout(Duration.ofMinutes(5));
+ container.setNetworkAliases(new ArrayList<>(List.of(metadata.networkAliasOrDefault())));
if (metadata.networkShared()) {
container.withNetwork(Network.SHARED);
}