Skip to content

Commit

Permalink
fixes the Neo4j docker starting issue in PostRepositoryWithTestContai…
Browse files Browse the repository at this point in the history
…nersTest
  • Loading branch information
hantsy committed Apr 22, 2020
1 parent 9d04105 commit 21c6a8d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
12 changes: 12 additions & 0 deletions boot-data-neo4j-rx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,11 @@

@ContextConfiguration(initializers = PostRepositoryTest.TestContainerInitializer.class)
@ReactiveDataNeo4jTest(excludeAutoConfiguration = Neo4jTestHarnessAutoConfiguration.class)
//@Testcontainers
@Slf4j
public class PostRepositoryTest {

// @Container
// private static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.0");
//
// @DynamicPropertySource
// static void neo4jProperties(DynamicPropertyRegistry registry) {
// registry.add("org.neo4j.driver.uri", neo4jContainer::getBoltUrl);
// registry.add("org.neo4j.driver.authentication.username", () -> "neo4j");
// registry.add("org.neo4j.driver.authentication.password", neo4jContainer::getAdminPassword);
// }

/**
* Note: This code fragment is from Neo4j Data Rx spring boot test starter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.neo4j.driver.springframework.boot.test.autoconfigure.Neo4jTestHarnessAutoConfiguration;
import org.neo4j.springframework.boot.test.autoconfigure.data.ReactiveDataNeo4jTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.data.domain.Example;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.Neo4jContainer;
Expand All @@ -34,10 +29,13 @@
@ReactiveDataNeo4jTest(excludeAutoConfiguration = Neo4jTestHarnessAutoConfiguration.class)
@Testcontainers
@Slf4j
// Testcontainers does not work well with per_class testinstance.
// see: https://stackoverflow.com/questions/61357116/exception-mapped-port-can-only-be-obtained-after-the-container-is-started-when/61358336#61358336
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
public class PostRepositoryWithTestContainersTest {

@Container
private static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.0")
static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.0")
.withStartupTimeout(Duration.ofMinutes(5));

@DynamicPropertySource
Expand Down

0 comments on commit 21c6a8d

Please sign in to comment.