Skip to content

Commit 316126e

Browse files
michael-simonswilkinsona
authored andcommitted
Replace custom Neo4j container with Testcontainers version
See gh-15638
1 parent a5aceb3 commit 316126e

File tree

5 files changed

+20
-94
lines changed

5 files changed

+20
-94
lines changed

spring-boot-project/spring-boot-parent/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<artifactId>testcontainers</artifactId>
102102
<version>1.10.6</version>
103103
</dependency>
104+
<dependency>
105+
<groupId>org.testcontainers</groupId>
106+
<artifactId>neo4j</artifactId>
107+
<version>1.10.6</version>
108+
</dependency>
104109
<dependency>
105110
<groupId>com.vaadin.external.google</groupId>
106111
<artifactId>android-json</artifactId>

spring-boot-project/spring-boot-test-autoconfigure/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,10 @@
299299
<artifactId>testcontainers</artifactId>
300300
<scope>test</scope>
301301
</dependency>
302+
<dependency>
303+
<groupId>org.testcontainers</groupId>
304+
<artifactId>neo4j</artifactId>
305+
<scope>test</scope>
306+
</dependency>
302307
</dependencies>
303308
</project>

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,11 +20,11 @@
2020
import org.junit.Test;
2121
import org.junit.runner.RunWith;
2222
import org.neo4j.ogm.session.Session;
23+
import org.testcontainers.containers.Neo4jContainer;
2324

2425
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2526
import org.springframework.beans.factory.annotation.Autowired;
2627
import org.springframework.boot.test.util.TestPropertyValues;
27-
import org.springframework.boot.testsupport.testcontainers.Neo4jContainer;
2828
import org.springframework.context.ApplicationContext;
2929
import org.springframework.context.ApplicationContextInitializer;
3030
import org.springframework.context.ConfigurableApplicationContext;
@@ -39,14 +39,15 @@
3939
*
4040
* @author Eddú Meléndez
4141
* @author Stephane Nicoll
42+
* @author Michael Simons
4243
*/
4344
@RunWith(SpringRunner.class)
4445
@ContextConfiguration(initializers = DataNeo4jTestIntegrationTests.Initializer.class)
4546
@DataNeo4jTest
4647
public class DataNeo4jTestIntegrationTests {
4748

4849
@ClassRule
49-
public static Neo4jContainer neo4j = new Neo4jContainer();
50+
public static Neo4jContainer neo4j = new Neo4jContainer().withAdminPassword(null);
5051

5152
@Autowired
5253
private Session session;
@@ -79,8 +80,7 @@ static class Initializer
7980
@Override
8081
public void initialize(
8182
ConfigurableApplicationContext configurableApplicationContext) {
82-
TestPropertyValues
83-
.of("spring.data.neo4j.uri=bolt://localhost:" + neo4j.getMappedPort())
83+
TestPropertyValues.of("spring.data.neo4j.uri=" + neo4j.getBoltUrl())
8484
.applyTo(configurableApplicationContext.getEnvironment());
8585
}
8686

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@
1919
import org.junit.ClassRule;
2020
import org.junit.Test;
2121
import org.junit.runner.RunWith;
22+
import org.testcontainers.containers.Neo4jContainer;
2223

2324
import org.springframework.beans.factory.annotation.Autowired;
2425
import org.springframework.boot.test.util.TestPropertyValues;
25-
import org.springframework.boot.testsupport.testcontainers.Neo4jContainer;
2626
import org.springframework.context.ApplicationContextInitializer;
2727
import org.springframework.context.ConfigurableApplicationContext;
2828
import org.springframework.context.annotation.ComponentScan.Filter;
@@ -36,14 +36,15 @@
3636
* Integration test with custom include filter for {@link DataNeo4jTest}.
3737
*
3838
* @author Eddú Meléndez
39+
* @author Michael Simons
3940
*/
4041
@RunWith(SpringRunner.class)
4142
@ContextConfiguration(initializers = DataNeo4jTestWithIncludeFilterIntegrationTests.Initializer.class)
4243
@DataNeo4jTest(includeFilters = @Filter(Service.class))
4344
public class DataNeo4jTestWithIncludeFilterIntegrationTests {
4445

4546
@ClassRule
46-
public static Neo4jContainer neo4j = new Neo4jContainer();
47+
public static Neo4jContainer neo4j = new Neo4jContainer().withAdminPassword(null);
4748

4849
@Autowired
4950
private ExampleService service;
@@ -59,8 +60,7 @@ static class Initializer
5960
@Override
6061
public void initialize(
6162
ConfigurableApplicationContext configurableApplicationContext) {
62-
TestPropertyValues
63-
.of("spring.data.neo4j.uri=bolt://localhost:" + neo4j.getMappedPort())
63+
TestPropertyValues.of("spring.data.neo4j.uri=" + neo4j.getBoltUrl())
6464
.applyTo(configurableApplicationContext.getEnvironment());
6565
}
6666

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/Neo4jContainer.java

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

0 commit comments

Comments
 (0)