Skip to content

Commit b008649

Browse files
build(deps): bump org.testcontainers:testcontainers-bom from 1.21.3 to 2.0.2 (#331)
* build(deps): bump org.testcontainers:testcontainers-bom Bumps [org.testcontainers:testcontainers-bom](https://github.com/testcontainers/testcontainers-java) from 1.21.3 to 2.0.2. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](testcontainers/testcontainers-java@1.21.3...2.0.2) --- updated-dependencies: - dependency-name: org.testcontainers:testcontainers-bom dependency-version: 2.0.2 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * test: migrate to testcontainers v2 and Beam tests to Junit Jupiter --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Florent Biville <florent.biville@neo4j.com>
1 parent a165b4f commit b008649

File tree

11 files changed

+108
-90
lines changed

11 files changed

+108
-90
lines changed

core/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
<artifactId>beam-sdks-java-io-jdbc</artifactId>
3030
<scope>test</scope>
3131
</dependency>
32+
<dependency>
33+
<groupId>org.apache.beam</groupId>
34+
<artifactId>beam-sdks-java-testing-junit</artifactId>
35+
<scope>test</scope>
36+
</dependency>
3237
<dependency>
3338
<groupId>org.assertj</groupId>
3439
<artifactId>assertj-core</artifactId>
@@ -67,22 +72,22 @@
6772
</dependency>
6873
<dependency>
6974
<groupId>org.testcontainers</groupId>
70-
<artifactId>junit-jupiter</artifactId>
75+
<artifactId>testcontainers</artifactId>
7176
<scope>test</scope>
7277
</dependency>
7378
<dependency>
7479
<groupId>org.testcontainers</groupId>
75-
<artifactId>neo4j</artifactId>
80+
<artifactId>testcontainers-junit-jupiter</artifactId>
7681
<scope>test</scope>
7782
</dependency>
7883
<dependency>
7984
<groupId>org.testcontainers</groupId>
80-
<artifactId>postgresql</artifactId>
85+
<artifactId>testcontainers-neo4j</artifactId>
8186
<scope>test</scope>
8287
</dependency>
8388
<dependency>
8489
<groupId>org.testcontainers</groupId>
85-
<artifactId>testcontainers</artifactId>
90+
<artifactId>testcontainers-postgresql</artifactId>
8691
<scope>test</scope>
8792
</dependency>
8893
</dependencies>

core/src/test/java/org/neo4j/importer/v1/e2e/AdminImportIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@
5656
import org.neo4j.importer.v1.targets.Target;
5757
import org.neo4j.importer.v1.targets.Targets;
5858
import org.testcontainers.containers.BindMode;
59-
import org.testcontainers.containers.Neo4jContainer;
6059
import org.testcontainers.junit.jupiter.Container;
6160
import org.testcontainers.junit.jupiter.Testcontainers;
61+
import org.testcontainers.neo4j.Neo4jContainer;
6262
import org.testcontainers.utility.DockerImageName;
6363
import org.testcontainers.utility.MountableFile;
6464

6565
@Testcontainers
6666
public class AdminImportIT {
6767

6868
@Container
69-
private static final Neo4jContainer<?> NEO4J = new Neo4jContainer<>(DockerImageName.parse("neo4j:5-enterprise"))
69+
private static final Neo4jContainer NEO4J = new Neo4jContainer(DockerImageName.parse("neo4j:5-enterprise"))
7070
.withEnv("NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes")
7171
.withAdminPassword("letmein!")
7272
.withCreateContainerCmdModifier(cmd -> cmd.withUser("neo4j"))
@@ -328,7 +328,7 @@ private static NodeKeyConstraint singleNodeKey(NodeTarget nodeTarget) {
328328
}
329329

330330
public static void executeImport(
331-
Neo4jContainer<?> neo4j, Driver driver, ImportSpecification importSpec, String neo4jDatabase)
331+
Neo4jContainer neo4j, Driver driver, ImportSpecification importSpec, String neo4jDatabase)
332332
throws Exception {
333333

334334
var command = importCommand(importSpec, neo4jDatabase);

core/src/test/java/org/neo4j/importer/v1/e2e/BeamIT.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.beam.sdk.io.jdbc.JdbcIO.DataSourceConfiguration;
3434
import org.apache.beam.sdk.schemas.SchemaCoder;
3535
import org.apache.beam.sdk.testing.TestPipeline;
36+
import org.apache.beam.sdk.testing.TestPipelineExtension;
3637
import org.apache.beam.sdk.transforms.Create;
3738
import org.apache.beam.sdk.transforms.DoFn;
3839
import org.apache.beam.sdk.transforms.PTransform;
@@ -43,11 +44,10 @@
4344
import org.apache.beam.sdk.values.Row;
4445
import org.assertj.core.api.Assertions;
4546
import org.jetbrains.annotations.NotNull;
46-
import org.junit.After;
47-
import org.junit.Before;
48-
import org.junit.ClassRule;
49-
import org.junit.Rule;
50-
import org.junit.Test;
47+
import org.junit.jupiter.api.AfterEach;
48+
import org.junit.jupiter.api.BeforeEach;
49+
import org.junit.jupiter.api.Test;
50+
import org.junit.jupiter.api.extension.ExtendWith;
5151
import org.neo4j.driver.AuthTokens;
5252
import org.neo4j.driver.Driver;
5353
import org.neo4j.driver.GraphDatabase;
@@ -68,28 +68,29 @@
6868
import org.neo4j.importer.v1.sources.JdbcSource;
6969
import org.neo4j.importer.v1.sources.Source;
7070
import org.neo4j.importer.v1.targets.PropertyMapping;
71-
import org.testcontainers.containers.Neo4jContainer;
72-
import org.testcontainers.containers.PostgreSQLContainer;
71+
import org.testcontainers.junit.jupiter.Container;
72+
import org.testcontainers.junit.jupiter.Testcontainers;
73+
import org.testcontainers.neo4j.Neo4jContainer;
74+
import org.testcontainers.postgresql.PostgreSQLContainer;
7375
import org.testcontainers.utility.DockerImageName;
7476

77+
@ExtendWith(TestPipelineExtension.class)
78+
@Testcontainers
7579
public class BeamIT {
7680

77-
@Rule
78-
public final TestPipeline pipeline = TestPipeline.create();
79-
80-
@ClassRule
81-
public static Neo4jContainer<?> NEO4J = new Neo4jContainer<>(DockerImageName.parse("neo4j:5-enterprise"))
81+
@Container
82+
public static Neo4jContainer NEO4J = new Neo4jContainer(DockerImageName.parse("neo4j:5-enterprise"))
8283
.withEnv("NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes")
8384
.withAdminPassword("letmein!");
8485

85-
@ClassRule
86-
public static PostgreSQLContainer<?> POSTGRES = new PostgreSQLContainer<>(DockerImageName.parse("postgres:16.2"))
86+
@Container
87+
public static PostgreSQLContainer POSTGRES = new PostgreSQLContainer(DockerImageName.parse("postgres:16.2"))
8788
.withDatabaseName("northwind")
8889
.withInitScript("e2e/postgres-dump/northwind.sql");
8990

9091
private Driver neo4jDriver;
9192

92-
@Before
93+
@BeforeEach
9394
public void prepare() {
9495
neo4jDriver = GraphDatabase.driver(NEO4J.getBoltUrl(), AuthTokens.basic("neo4j", NEO4J.getAdminPassword()));
9596
neo4jDriver.verifyConnectivity();
@@ -99,22 +100,22 @@ public void prepare() {
99100
}
100101
}
101102

102-
@After
103+
@AfterEach
103104
public void cleanUp() {
104105
neo4jDriver.close();
105106
}
106107

107108
@Test
108-
public void imports_data_via_Beam_and_json_spec() throws Exception {
109-
runBeamImport("json");
109+
public void imports_data_via_Beam_and_json_spec(TestPipeline pipeline) throws Exception {
110+
runBeamImport(pipeline, "json");
110111
}
111112

112113
@Test
113-
public void imports_data_via_Beam_and_yaml_spec() throws Exception {
114-
runBeamImport("yaml");
114+
public void imports_data_via_Beam_and_yaml_spec(TestPipeline pipeline) throws Exception {
115+
runBeamImport(pipeline, "yaml");
115116
}
116117

117-
private void runBeamImport(String extension) throws Exception {
118+
private void runBeamImport(TestPipeline pipeline, String extension) throws Exception {
118119
String neo4jUrl = NEO4J.getBoltUrl();
119120
String neo4jPassword = NEO4J.getAdminPassword();
120121
var importSpec =

examples/apache-beam/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<artifactId>beam-sdks-java-io-parquet</artifactId>
2929
<scope>test</scope>
3030
</dependency>
31+
<dependency>
32+
<groupId>org.apache.beam</groupId>
33+
<artifactId>beam-sdks-java-testing-junit</artifactId>
34+
<scope>test</scope>
35+
</dependency>
3136
<dependency>
3237
<!-- required by Beam's ParquetIO -->
3338
<groupId>org.apache.hadoop</groupId>
@@ -81,17 +86,17 @@
8186
</dependency>
8287
<dependency>
8388
<groupId>org.testcontainers</groupId>
84-
<artifactId>junit-jupiter</artifactId>
89+
<artifactId>testcontainers</artifactId>
8590
<scope>test</scope>
8691
</dependency>
8792
<dependency>
8893
<groupId>org.testcontainers</groupId>
89-
<artifactId>neo4j</artifactId>
94+
<artifactId>testcontainers-junit-jupiter</artifactId>
9095
<scope>test</scope>
9196
</dependency>
9297
<dependency>
9398
<groupId>org.testcontainers</groupId>
94-
<artifactId>testcontainers</artifactId>
99+
<artifactId>testcontainers-neo4j</artifactId>
95100
<scope>test</scope>
96101
</dependency>
97102
</dependencies>

examples/apache-beam/src/test/java/org/neo4j/importer/BeamExampleIT.java

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.apache.beam.sdk.extensions.avro.coders.AvroCoder;
6161
import org.apache.beam.sdk.io.parquet.ParquetIO;
6262
import org.apache.beam.sdk.testing.TestPipeline;
63+
import org.apache.beam.sdk.testing.TestPipelineExtension;
6364
import org.apache.beam.sdk.transforms.Create;
6465
import org.apache.beam.sdk.transforms.DoFn;
6566
import org.apache.beam.sdk.transforms.GroupIntoBatches;
@@ -70,10 +71,8 @@
7071
import org.apache.beam.sdk.transforms.WithKeys;
7172
import org.apache.beam.sdk.values.KV;
7273
import org.apache.beam.sdk.values.PCollection;
73-
import org.checkerframework.checker.nullness.qual.NonNull;
74-
import org.junit.ClassRule;
75-
import org.junit.Rule;
76-
import org.junit.Test;
74+
import org.junit.jupiter.api.Test;
75+
import org.junit.jupiter.api.extension.ExtendWith;
7776
import org.neo4j.cypherdsl.core.Cypher;
7877
import org.neo4j.cypherdsl.core.Expression;
7978
import org.neo4j.cypherdsl.core.MapExpression;
@@ -102,21 +101,22 @@
102101
import org.neo4j.importer.v1.sources.Source;
103102
import org.neo4j.importer.v1.sources.SourceProvider;
104103
import org.neo4j.importer.v1.targets.PropertyType;
105-
import org.testcontainers.containers.Neo4jContainer;
104+
import org.testcontainers.junit.jupiter.Container;
105+
import org.testcontainers.junit.jupiter.Testcontainers;
106+
import org.testcontainers.neo4j.Neo4jContainer;
106107
import org.testcontainers.utility.DockerImageName;
107108

109+
@ExtendWith(TestPipelineExtension.class)
110+
@Testcontainers
108111
public class BeamExampleIT {
109112

110-
@Rule
111-
public final TestPipeline pipeline = TestPipeline.create();
112-
113-
@ClassRule
114-
public static Neo4jContainer<?> NEO4J = new Neo4jContainer<>(DockerImageName.parse("neo4j:5-enterprise"))
113+
@Container
114+
public static Neo4jContainer NEO4J = new Neo4jContainer(DockerImageName.parse("neo4j:5-enterprise"))
115115
.withEnv("NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes")
116116
.withAdminPassword("letmein!");
117117

118118
@Test
119-
public void imports_dvd_rental_data_set() throws Exception {
119+
public void imports_dvd_rental_data_set(TestPipeline pipeline) throws Exception {
120120
try (InputStream stream = this.getClass().getResourceAsStream("/specs/dvd_rental.yaml")) {
121121
assertThat(stream).isNotNull();
122122

@@ -125,9 +125,9 @@ public void imports_dvd_rental_data_set() throws Exception {
125125
var importPipeline = ImportPipeline.of(ImportSpecificationDeserializer.deserialize(reader));
126126
importPipeline.forEach(step -> {
127127
switch (step) {
128-
case SourceStep source -> handleSource(source, outputs);
129-
case ActionStep action -> handleAction(action, outputs);
130-
case TargetStep target -> handleTarget(target, outputs);
128+
case SourceStep source -> handleSource(source, pipeline, outputs);
129+
case ActionStep action -> handleAction(action, pipeline, outputs);
130+
case TargetStep target -> handleTarget(target, pipeline, outputs);
131131
default -> throw new IllegalStateException("Unexpected value: " + step);
132132
}
133133
});
@@ -152,7 +152,7 @@ public void imports_dvd_rental_data_set() throws Exception {
152152
}
153153
}
154154

155-
private void handleSource(SourceStep step, Map<String, PCollection<?>> outputs) {
155+
private void handleSource(SourceStep step, TestPipeline pipeline, Map<String, PCollection<?>> outputs) {
156156
var name = step.name();
157157
var source = step.source();
158158
assertThat(source).isInstanceOf(ParquetSource.class);
@@ -165,7 +165,7 @@ private void handleSource(SourceStep step, Map<String, PCollection<?>> outputs)
165165
outputs.put(source.getName(), output);
166166
}
167167

168-
private void handleAction(ActionStep step, Map<String, PCollection<?>> outputs) {
168+
private void handleAction(ActionStep step, TestPipeline pipeline, Map<String, PCollection<?>> outputs) {
169169
var actionName = step.name();
170170
var action = step.action();
171171
assertThat(action).isInstanceOf(CypherAction.class);
@@ -183,7 +183,7 @@ private void handleAction(ActionStep step, Map<String, PCollection<?>> outputs)
183183
}
184184

185185
@SuppressWarnings("unchecked")
186-
private void handleTarget(TargetStep step, Map<String, PCollection<?>> outputs) {
186+
private void handleTarget(TargetStep step, TestPipeline pipeline, Map<String, PCollection<?>> outputs) {
187187
var stepName = step.name();
188188
assertThat(step).isInstanceOf(EntityTargetStep.class);
189189
var entityTargetStep = (EntityTargetStep) step;
@@ -347,8 +347,7 @@ public String getName() {
347347
}
348348
}
349349

350-
private static class TargetSchemaIO
351-
extends PTransform<@NonNull PCollection<Integer>, @NonNull PCollection<WriteCounters>> {
350+
private static class TargetSchemaIO extends PTransform<PCollection<Integer>, PCollection<WriteCounters>> {
352351

353352
private final String url;
354353

@@ -362,13 +361,13 @@ private TargetSchemaIO(String url, String password, EntityTargetStep target) {
362361
this.target = target;
363362
}
364363

365-
public static PTransform<@NonNull PCollection<Integer>, @NonNull PCollection<WriteCounters>> initSchema(
364+
public static PTransform<PCollection<Integer>, PCollection<WriteCounters>> initSchema(
366365
String url, String password, EntityTargetStep target) {
367366
return new TargetSchemaIO(url, password, target);
368367
}
369368

370369
@Override
371-
public @NonNull PCollection<WriteCounters> expand(@NonNull PCollection<Integer> input) {
370+
public PCollection<WriteCounters> expand(PCollection<Integer> input) {
372371
return input.apply(ParDo.of(TargetSchemaWriteFn.of(url, password, target)));
373372
}
374373

@@ -552,8 +551,7 @@ private static String propertyType(PropertyType propertyType) {
552551
}
553552

554553
private static class TargetIO
555-
extends PTransform<
556-
@NonNull PCollection<KV<Integer, Iterable<GenericRecord>>>, @NonNull PCollection<WriteCounters>> {
554+
extends PTransform<PCollection<KV<Integer, Iterable<GenericRecord>>>, PCollection<WriteCounters>> {
557555

558556
private final String url;
559557

@@ -567,14 +565,13 @@ private TargetIO(String url, String password, EntityTargetStep target) {
567565
this.target = target;
568566
}
569567

570-
public static PTransform<
571-
@NonNull PCollection<KV<Integer, Iterable<GenericRecord>>>, @NonNull PCollection<WriteCounters>>
568+
public static PTransform<PCollection<KV<Integer, Iterable<GenericRecord>>>, PCollection<WriteCounters>>
572569
writeAll(String boltUrl, String adminPassword, EntityTargetStep target) {
573570
return new TargetIO(boltUrl, adminPassword, target);
574571
}
575572

576573
@Override
577-
public @NonNull PCollection<WriteCounters> expand(PCollection<KV<Integer, Iterable<GenericRecord>>> input) {
574+
public PCollection<WriteCounters> expand(PCollection<KV<Integer, Iterable<GenericRecord>>> input) {
578575
return input.apply(ParDo.of(TargetWriteFn.of(url, password, target)));
579576
}
580577

@@ -774,7 +771,7 @@ public static Coder<GenericRecord> create() {
774771
}
775772

776773
@Override
777-
public void encode(GenericRecord value, @NonNull OutputStream outStream) throws IOException {
774+
public void encode(GenericRecord value, OutputStream outStream) throws IOException {
778775
assertThat(value).isNotNull();
779776
var schema = value.getSchema();
780777
String schemaString = schema.toString();
@@ -786,7 +783,7 @@ public void encode(GenericRecord value, @NonNull OutputStream outStream) throws
786783
}
787784

788785
@Override
789-
public GenericRecord decode(@NonNull InputStream inStream) throws IOException {
786+
public GenericRecord decode(InputStream inStream) throws IOException {
790787
String schemaString = StringUtf8Coder.of().decode(inStream);
791788
String schemaHash = StringUtf8Coder.of().decode(inStream);
792789
AvroCoder<GenericRecord> coder =
@@ -1005,8 +1002,7 @@ public String toString() {
10051002
}
10061003
}
10071004

1008-
private static class CypherActionIO
1009-
extends PTransform<@NonNull PCollection<Integer>, @NonNull PCollection<Integer>> {
1005+
private static class CypherActionIO extends PTransform<PCollection<Integer>, PCollection<Integer>> {
10101006

10111007
private final CypherAction action;
10121008

@@ -1020,13 +1016,13 @@ private CypherActionIO(CypherAction action, String url, String password) {
10201016
this.password = password;
10211017
}
10221018

1023-
public static PTransform<@NonNull PCollection<Integer>, @NonNull PCollection<Integer>> run(
1019+
public static PTransform<PCollection<Integer>, PCollection<Integer>> run(
10241020
CypherAction action, String url, String password) {
10251021
return new CypherActionIO(action, url, password);
10261022
}
10271023

10281024
@Override
1029-
public @NonNull PCollection<Integer> expand(@NonNull PCollection<Integer> input) {
1025+
public PCollection<Integer> expand(PCollection<Integer> input) {
10301026
return input.apply(ParDo.of(new CypherActionFn(action, url, password)));
10311027
}
10321028
}

0 commit comments

Comments
 (0)