Skip to content

Commit 334fe2f

Browse files
author
raju.gupta
committed
Fix compilation errors after merge: add type casts for Neo4j tests and remove deprecated RabbitMQ test file
1 parent 5abbf1f commit 334fe2f

File tree

8 files changed

+50
-373
lines changed

8 files changed

+50
-373
lines changed

core/src/test/java/org/testcontainers/containers/ComposeOverridesTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ void test(boolean localMode, String expectedEnvVar, File... composeFiles) {
5555
.isTrue();
5656
}
5757
try (
58-
ComposeContainer compose = new ComposeContainer(composeFiles)
59-
.withLocalCompose(localMode)
60-
.withExposedService(SERVICE_NAME, SERVICE_PORT)
58+
ComposeContainer compose = new ComposeContainer(composeFiles).withExposedService(SERVICE_NAME, SERVICE_PORT)
6159
) {
6260
compose.start();
6361

core/src/test/java/org/testcontainers/containers/DockerComposeOverridesTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void test(boolean localMode, String expectedEnvVar, File... composeFiles) throws
5454
.doesNotStartWith("Docker Compose version v2");
5555
}
5656
try (
57-
DockerComposeContainer compose = new DockerComposeContainer(composeFiles)
58-
.withLocalCompose(localMode)
57+
DockerComposeContainer<?> compose = new DockerComposeContainer(composeFiles)
5958
.withExposedService(SERVICE_NAME, SERVICE_PORT)
6059
) {
6160
compose.start();

core/src/test/java/org/testcontainers/junit/DockerComposeLocalImageTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ class DockerComposeLocalImageTest {
1313

1414
@Test
1515
void usesLocalImageEvenWhenPullFails() throws InterruptedException {
16-
tagImage("redis:6-alpine", "redis-local", "latest");
16+
tagImage();
1717

18-
DockerComposeContainer composeContainer = new DockerComposeContainer(
19-
DockerImageName.parse("docker/compose:1.29.2"),
20-
new File("src/test/resources/local-compose-test.yml")
21-
)
22-
.withExposedService("redis", 6379);
23-
composeContainer.start();
18+
try (
19+
DockerComposeContainer<?> composeContainer = new DockerComposeContainer<>(
20+
DockerImageName.parse("docker/compose:1.29.2"),
21+
new File("src/test/resources/local-compose-test.yml")
22+
)
23+
.withExposedService("redis", 6379)
24+
) {
25+
composeContainer.start();
26+
}
2427
}
2528

26-
private void tagImage(String sourceImage, String targetImage, String targetTag) throws InterruptedException {
29+
private void tagImage() throws InterruptedException {
2730
DockerClient client = DockerClientFactory.instance().client();
28-
client.pullImageCmd(sourceImage).exec(new PullImageResultCallback()).awaitCompletion();
29-
client.tagImageCmd(sourceImage, targetImage, targetTag).exec();
31+
client.pullImageCmd("redis:6-alpine").exec(new PullImageResultCallback()).awaitCompletion();
32+
client.tagImageCmd("redis:6-alpine", "redis-local", "latest").exec();
3033
}
3134
}

modules/mongodb/src/test/java/org/testcontainers/mongodb/CompatibleImageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.testcontainers.containers;
1+
package org.testcontainers.mongodb;
22

33
import com.mongodb.client.MongoClient;
44
import com.mongodb.client.MongoClients;

modules/mongodb/src/test/java/org/testcontainers/mongodb/MongoDBContainerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.testcontainers.containers;
1+
package org.testcontainers.mongodb;
22

33
import org.assertj.core.api.Assertions;
44
import org.junit.jupiter.api.Test;

modules/mssqlserver/src/test/java/org/testcontainers/mssqlserver/MSSQLServerContainerTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,17 @@ void testSqlServerConnection() throws SQLException {
9393
) {
9494
mssqlServerContainer.start();
9595

96-
ResultSet resultSet = performQuery(mssqlServerContainer, mssqlServerContainer.getTestQueryString());
97-
int resultSetInt = resultSet.getInt(1);
98-
assertThat(resultSetInt).as("A basic SELECT query succeeds").isEqualTo(1);
96+
performQuery(
97+
mssqlServerContainer,
98+
mssqlServerContainer.getTestQueryString(),
99+
resultSet -> {
100+
assertThatNoException()
101+
.isThrownBy(() -> {
102+
int resultSetInt = resultSet.getInt(1);
103+
assertThat(resultSetInt).as("A basic SELECT query succeeds").isEqualTo(1);
104+
});
105+
}
106+
);
99107
}
100108
}
101109

modules/neo4j/src/test/java/org/testcontainers/neo4j/Neo4jContainerTest.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.testcontainers.containers;
1+
package org.testcontainers.neo4j;
22

33
import ch.qos.logback.classic.Level;
44
import ch.qos.logback.classic.Logger;
@@ -192,7 +192,10 @@ void shouldAddConfigToEnvironment() {
192192

193193
@Test
194194
void shouldRespectEnvironmentAuth() {
195-
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withEnv("NEO4J_AUTH", "neo4j/secret")) {
195+
try (
196+
Neo4jContainer neo4jContainer = (Neo4jContainer) new Neo4jContainer("neo4j:4.4")
197+
.withEnv("NEO4J_AUTH", "neo4j/secret")
198+
) {
196199
neo4jContainer.configure();
197200

198201
assertThat(neo4jContainer.getEnvMap()).containsEntry("NEO4J_AUTH", "neo4j/secret");
@@ -214,9 +217,9 @@ void shouldSetCustomPasswordCorrectly() {
214217
@Test
215218
void containerAdminPasswordOverrulesEnvironmentAuth() {
216219
try (
217-
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
218-
.withEnv("NEO4J_AUTH", "neo4j/secret")
219-
.withAdminPassword("anotherSecret")
220+
Neo4jContainer neo4jContainer = (
221+
(Neo4jContainer) new Neo4jContainer("neo4j:4.4").withEnv("NEO4J_AUTH", "neo4j/secret")
222+
).withAdminPassword("anotherSecret")
220223
) {
221224
neo4jContainer.configure();
222225

@@ -227,9 +230,9 @@ void containerAdminPasswordOverrulesEnvironmentAuth() {
227230
@Test
228231
void containerWithoutAuthenticationOverrulesEnvironmentAuth() {
229232
try (
230-
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
231-
.withEnv("NEO4J_AUTH", "neo4j/secret")
232-
.withoutAuthentication()
233+
Neo4jContainer neo4jContainer = (
234+
(Neo4jContainer) new Neo4jContainer("neo4j:4.4").withEnv("NEO4J_AUTH", "neo4j/secret")
235+
).withoutAuthentication()
233236
) {
234237
neo4jContainer.configure();
235238

@@ -239,7 +242,7 @@ void containerWithoutAuthenticationOverrulesEnvironmentAuth() {
239242

240243
@Test
241244
void shouldRespectAlreadyDefinedPortMappingsBolt() {
242-
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7687)) {
245+
try (Neo4jContainer neo4jContainer = (Neo4jContainer) new Neo4jContainer("neo4j:4.4").withExposedPorts(7687)) {
243246
neo4jContainer.configure();
244247

245248
assertThat(neo4jContainer.getExposedPorts()).containsExactly(7687);
@@ -248,7 +251,7 @@ void shouldRespectAlreadyDefinedPortMappingsBolt() {
248251

249252
@Test
250253
void shouldRespectAlreadyDefinedPortMappingsHttp() {
251-
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7474)) {
254+
try (Neo4jContainer neo4jContainer = (Neo4jContainer) new Neo4jContainer("neo4j:4.4").withExposedPorts(7474)) {
252255
neo4jContainer.configure();
253256

254257
assertThat(neo4jContainer.getExposedPorts()).containsExactly(7474);
@@ -257,7 +260,10 @@ void shouldRespectAlreadyDefinedPortMappingsHttp() {
257260

258261
@Test
259262
void shouldRespectAlreadyDefinedPortMappingsWithoutHttps() {
260-
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7687, 7474)) {
263+
try (
264+
Neo4jContainer neo4jContainer = (Neo4jContainer) new Neo4jContainer("neo4j:4.4")
265+
.withExposedPorts(7687, 7474)
266+
) {
261267
neo4jContainer.configure();
262268

263269
assertThat(neo4jContainer.getExposedPorts()).containsExactlyInAnyOrder(7474, 7687);
@@ -275,13 +281,11 @@ void shouldDefaultExportBoltHttpAndHttps() {
275281

276282
@Test
277283
void shouldRespectCustomWaitStrategy() {
278-
try (
279-
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").waitingFor(new CustomDummyWaitStrategy())
280-
) {
281-
neo4jContainer.configure();
284+
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").waitingFor(new CustomDummyWaitStrategy());
282285

283-
assertThat(neo4jContainer.getWaitStrategy()).isInstanceOf(CustomDummyWaitStrategy.class);
284-
}
286+
neo4jContainer.configure();
287+
288+
assertThat(neo4jContainer).extracting("waitStrategy").isInstanceOf(CustomDummyWaitStrategy.class);
285289
}
286290

287291
@Test
@@ -306,7 +310,7 @@ void shouldConfigureMultiplePluginsByName() {
306310
neo4jContainer.configure();
307311

308312
assertThat(neo4jContainer.getEnvMap().get("NEO4JLABS_PLUGINS"))
309-
.containsAnyOf("[\"apoc\",\"bloom\"]", "[\"bloom\",\"apoc\"]");
313+
.isIn("[\"apoc\",\"bloom\"]", "[\"bloom\",\"apoc\"]");
310314
}
311315
}
312316

0 commit comments

Comments
 (0)