Skip to content

Commit 2e5e741

Browse files
committed
feat: #140 Allow using DockerImageName when building an ensemble
Signed-off-by: Laurent Broudoux <laurent.broudoux@gmail.com>
1 parent 52215fc commit 2e5e741

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

src/main/java/io/github/microcks/testcontainers/MicrocksContainersEnsemble.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ public MicrocksContainersEnsemble(String image) {
5353
this(Network.newNetwork(), image);
5454
}
5555

56+
/**
57+
* Build a new MicrocksContainersEnsemble with its base container full image name.
58+
* @param image This image must be compatible with quay.io/microcks/microcks-uber image.
59+
*/
60+
public MicrocksContainersEnsemble(DockerImageName image) {
61+
this(Network.newNetwork(), image);
62+
}
63+
5664
/**
5765
* Build a new MicrocksContainersEnsemble with a pre-existing network and with its base container full image name.
5866
* @param network The network to attach ensemble containers to.
@@ -98,6 +106,19 @@ public MicrocksContainersEnsemble withPostman(String image) {
98106
return this;
99107
}
100108

109+
/**
110+
* Enable the Postman runtime container with provided container image.
111+
* @param image This image must be compatible with quay.io/microcks/microcks-postman-runtime image.
112+
* @return self
113+
*/
114+
public MicrocksContainersEnsemble withPostman(DockerImageName image) {
115+
this.postman = new GenericContainer<>(image)
116+
.withNetwork(network)
117+
.withNetworkAliases("postman")
118+
.waitingFor(Wait.forLogMessage(".*postman-runtime wrapper listening on port.*", 1));
119+
return this;
120+
}
121+
101122
/**
102123
* Enable the Async Feature container with default container image (deduced from Microcks main one).
103124
* @return self
@@ -120,6 +141,16 @@ public MicrocksContainersEnsemble withAsyncFeature(String image) {
120141
return this;
121142
}
122143

144+
/**
145+
* Enable the Async Feature container with provided container image.
146+
* @param image This image must be compatible with quay.io/microcks/microcks-uber-async-minion image.
147+
* @return self
148+
*/
149+
public MicrocksContainersEnsemble withAsyncFeature(DockerImageName image) {
150+
this.asyncMinion = new MicrocksAsyncMinionContainer(network, image, microcks);
151+
return this;
152+
}
153+
123154
/**
124155
* Once the Async Feature is enabled, connects to a Kafka broker.
125156
* @param connection Connection details to a Kafka broker.

src/test/java/io/github/microcks/testcontainers/MicrocksContainerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void testContractTestingFunctionalityWithOAuth2() throws Exception {
160160
@Test
161161
public void testSecretCreation() throws Exception {
162162
try (
163-
MicrocksContainer microcks = new MicrocksContainer(IMAGE)
163+
MicrocksContainer microcks = new MicrocksContainer(MICROCKS_IMAGE)
164164
.withSecret(new Secret.Builder().name("my-secret").token("abc-123-xyz").build());
165165
) {
166166
microcks.start();

src/test/java/io/github/microcks/testcontainers/MicrocksContainersEnsembleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
public class MicrocksContainersEnsembleTest {
9696

9797
private static final String IMAGE = "quay.io/microcks/microcks-uber:1.10.0";
98-
98+
private static final String ASYNC_IMAGE = "quay.io/microcks/microcks-uber-async-minion:nightly";
9999
private static final String NATIVE_IMAGE = "quay.io/microcks/microcks-uber:nightly-native";
100100

101101
private static final DockerImageName BAD_PASTRY_IMAGE = DockerImageName.parse("quay.io/microcks/contract-testing-demo:02");
@@ -171,7 +171,7 @@ public void testAsyncFeatureKafkaMockingFunctionality() throws Exception {
171171
try (
172172
MicrocksContainersEnsemble ensemble = new MicrocksContainersEnsemble(IMAGE)
173173
.withMainArtifacts("pastry-orders-asyncapi.yml")
174-
.withAsyncFeature()
174+
.withAsyncFeature(DockerImageName.parse(ASYNC_IMAGE))
175175
.withKafkaConnection(new KafkaConnection("kafka:19092"));
176176

177177
KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.5.0"))

0 commit comments

Comments
 (0)