Skip to content

Commit dbf1f40

Browse files
authored
Move Neo4j tests to JUnit Jupiter (#10751)
1 parent 67a4701 commit dbf1f40

File tree

3 files changed

+32
-82
lines changed

3 files changed

+32
-82
lines changed

modules/neo4j/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ dependencies {
3333

3434
api project(":testcontainers")
3535

36+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
37+
38+
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
3639
testImplementation 'org.neo4j.driver:neo4j-java-driver:4.4.20'
3740
testImplementation 'org.assertj:assertj-core:3.27.4'
3841
}
@@ -43,3 +46,7 @@ tasks.japicmp {
4346
"org.testcontainers.containers.Neo4jLabsPlugin"
4447
]
4548
}
49+
50+
test {
51+
useJUnitPlatform()
52+
}

modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

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

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import ch.qos.logback.classic.Logger;
55
import ch.qos.logback.classic.spi.ILoggingEvent;
66
import ch.qos.logback.core.AppenderBase;
7-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
88
import org.neo4j.driver.AuthToken;
99
import org.neo4j.driver.AuthTokens;
1010
import org.neo4j.driver.Driver;
@@ -26,16 +26,13 @@
2626
import static org.assertj.core.api.Assertions.assertThatNoException;
2727
import static org.assertj.core.api.Assumptions.assumeThat;
2828

29-
/**
30-
* Tests of functionality special to the Neo4jContainer.
31-
*/
32-
public class Neo4jContainerTest {
29+
class Neo4jContainerTest {
3330

3431
// See org.testcontainers.utility.LicenseAcceptance#ACCEPTANCE_FILE_NAME
3532
private static final String ACCEPTANCE_FILE_LOCATION = "/container-license-acceptance.txt";
3633

3734
@Test
38-
public void shouldDisableAuthentication() {
35+
void shouldDisableAuthentication() {
3936
try (
4037
// spotless:off
4138
// withoutAuthentication {
@@ -53,7 +50,7 @@ public void shouldDisableAuthentication() {
5350
}
5451

5552
@Test
56-
public void shouldCopyDatabase() {
53+
void shouldCopyDatabase() {
5754
// no aarch64 image available for Neo4j 3.5
5855
assumeThat(DockerClientFactory.instance().getInfo().getArchitecture()).isNotEqualTo("aarch64");
5956
try (
@@ -72,7 +69,7 @@ public void shouldCopyDatabase() {
7269
}
7370

7471
@Test
75-
public void shouldFailOnCopyDatabaseForDefaultNeo4j4Image() {
72+
void shouldFailOnCopyDatabaseForDefaultNeo4j4Image() {
7673
assertThatIllegalArgumentException()
7774
.isThrownBy(() -> {
7875
new Neo4jContainer("neo4j:4.4.1").withDatabase(MountableFile.forClasspathResource("/test-graph.db"));
@@ -81,7 +78,7 @@ public void shouldFailOnCopyDatabaseForDefaultNeo4j4Image() {
8178
}
8279

8380
@Test
84-
public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() {
81+
void shouldFailOnCopyDatabaseForCustomNeo4j4Image() {
8582
assertThatIllegalArgumentException()
8683
.isThrownBy(() -> {
8784
new Neo4jContainer("neo4j:4.4.1").withDatabase(MountableFile.forClasspathResource("/test-graph.db"));
@@ -90,7 +87,7 @@ public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() {
9087
}
9188

9289
@Test
93-
public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() {
90+
void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() {
9491
assertThatIllegalArgumentException()
9592
.isThrownBy(() -> {
9693
new Neo4jContainer("neo4j:latest").withDatabase(MountableFile.forClasspathResource("/test-graph.db"));
@@ -99,7 +96,7 @@ public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() {
9996
}
10097

10198
@Test
102-
public void shouldCopyPlugins() {
99+
void shouldCopyPlugins() {
103100
try (
104101
// registerPluginsPath {
105102
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
@@ -114,7 +111,7 @@ public void shouldCopyPlugins() {
114111
}
115112

116113
@Test
117-
public void shouldCopyPlugin() {
114+
void shouldCopyPlugin() {
118115
try (
119116
// registerPluginsJar {
120117
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
@@ -136,7 +133,7 @@ private static void assertThatCustomPluginWasCopied(Session session) {
136133
}
137134

138135
@Test
139-
public void shouldCheckEnterpriseLicense() {
136+
void shouldCheckEnterpriseLicense() {
140137
assumeThat(Neo4jContainerTest.class.getResource(ACCEPTANCE_FILE_LOCATION)).isNull();
141138

142139
String expectedImageName = "neo4j:4.4-enterprise";
@@ -147,7 +144,7 @@ public void shouldCheckEnterpriseLicense() {
147144
}
148145

149146
@Test
150-
public void shouldRunEnterprise() {
147+
void shouldRunEnterprise() {
151148
assumeThat(Neo4jContainerTest.class.getResource(ACCEPTANCE_FILE_LOCATION)).isNotNull();
152149

153150
try (
@@ -170,7 +167,7 @@ public void shouldRunEnterprise() {
170167
}
171168

172169
@Test
173-
public void shouldAddConfigToEnvironment() {
170+
void shouldAddConfigToEnvironment() {
174171
// neo4jConfiguration {
175172
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
176173
.withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*")
@@ -183,7 +180,7 @@ public void shouldAddConfigToEnvironment() {
183180
}
184181

185182
@Test
186-
public void shouldRespectEnvironmentAuth() {
183+
void shouldRespectEnvironmentAuth() {
187184
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withEnv("NEO4J_AUTH", "neo4j/secret");
188185

189186
neo4jContainer.configure();
@@ -192,7 +189,7 @@ public void shouldRespectEnvironmentAuth() {
192189
}
193190

194191
@Test
195-
public void shouldSetCustomPasswordCorrectly() {
192+
void shouldSetCustomPasswordCorrectly() {
196193
// withAdminPassword {
197194
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withAdminPassword("verySecret");
198195
// }
@@ -203,7 +200,7 @@ public void shouldSetCustomPasswordCorrectly() {
203200
}
204201

205202
@Test
206-
public void containerAdminPasswordOverrulesEnvironmentAuth() {
203+
void containerAdminPasswordOverrulesEnvironmentAuth() {
207204
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
208205
.withEnv("NEO4J_AUTH", "neo4j/secret")
209206
.withAdminPassword("anotherSecret");
@@ -214,7 +211,7 @@ public void containerAdminPasswordOverrulesEnvironmentAuth() {
214211
}
215212

216213
@Test
217-
public void containerWithoutAuthenticationOverrulesEnvironmentAuth() {
214+
void containerWithoutAuthenticationOverrulesEnvironmentAuth() {
218215
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
219216
.withEnv("NEO4J_AUTH", "neo4j/secret")
220217
.withoutAuthentication();
@@ -225,7 +222,7 @@ public void containerWithoutAuthenticationOverrulesEnvironmentAuth() {
225222
}
226223

227224
@Test
228-
public void shouldRespectAlreadyDefinedPortMappingsBolt() {
225+
void shouldRespectAlreadyDefinedPortMappingsBolt() {
229226
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7687);
230227

231228
neo4jContainer.configure();
@@ -234,7 +231,7 @@ public void shouldRespectAlreadyDefinedPortMappingsBolt() {
234231
}
235232

236233
@Test
237-
public void shouldRespectAlreadyDefinedPortMappingsHttp() {
234+
void shouldRespectAlreadyDefinedPortMappingsHttp() {
238235
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7474);
239236

240237
neo4jContainer.configure();
@@ -243,7 +240,7 @@ public void shouldRespectAlreadyDefinedPortMappingsHttp() {
243240
}
244241

245242
@Test
246-
public void shouldRespectAlreadyDefinedPortMappingsWithoutHttps() {
243+
void shouldRespectAlreadyDefinedPortMappingsWithoutHttps() {
247244
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7687, 7474);
248245

249246
neo4jContainer.configure();
@@ -252,7 +249,7 @@ public void shouldRespectAlreadyDefinedPortMappingsWithoutHttps() {
252249
}
253250

254251
@Test
255-
public void shouldDefaultExportBoltHttpAndHttps() {
252+
void shouldDefaultExportBoltHttpAndHttps() {
256253
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4");
257254

258255
neo4jContainer.configure();
@@ -261,7 +258,7 @@ public void shouldDefaultExportBoltHttpAndHttps() {
261258
}
262259

263260
@Test
264-
public void shouldRespectCustomWaitStrategy() {
261+
void shouldRespectCustomWaitStrategy() {
265262
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").waitingFor(new CustomDummyWaitStrategy());
266263

267264
neo4jContainer.configure();
@@ -270,7 +267,7 @@ public void shouldRespectCustomWaitStrategy() {
270267
}
271268

272269
@Test
273-
public void shouldConfigureSinglePluginByName() {
270+
void shouldConfigureSinglePluginByName() {
274271
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withPlugins("apoc")) {
275272
// needs to get called explicitly for setup
276273
neo4jContainer.configure();
@@ -280,7 +277,7 @@ public void shouldConfigureSinglePluginByName() {
280277
}
281278

282279
@Test
283-
public void shouldConfigureMultiplePluginsByName() {
280+
void shouldConfigureMultiplePluginsByName() {
284281
try (
285282
// configureLabsPlugins {
286283
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4") //
@@ -296,7 +293,7 @@ public void shouldConfigureMultiplePluginsByName() {
296293
}
297294

298295
@Test
299-
public void shouldCreateRandomUuidBasedPasswords() {
296+
void shouldCreateRandomUuidBasedPasswords() {
300297
try (
301298
// withRandomPassword {
302299
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withRandomPassword();
@@ -311,7 +308,7 @@ public void shouldCreateRandomUuidBasedPasswords() {
311308
}
312309

313310
@Test
314-
public void shouldWarnOnPasswordTooShort() {
311+
void shouldWarnOnPasswordTooShort() {
315312
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4");) {
316313
Logger logger = (Logger) DockerLoggerFactory.getLogger("neo4j:4.4");
317314
TestLogAppender testLogAppender = new TestLogAppender();

0 commit comments

Comments
 (0)