diff --git a/persistence-modules/spring-data-neo4j/pom.xml b/persistence-modules/spring-data-neo4j/pom.xml index a2fa29e753..705fe35d3c 100644 --- a/persistence-modules/spring-data-neo4j/pom.xml +++ b/persistence-modules/spring-data-neo4j/pom.xml @@ -105,18 +105,6 @@ - - org.neo4j.test - neo4j-harness - 5.5.0 - test - - - org.slf4j - slf4j-nop - - - diff --git a/persistence-modules/spring-data-neo4j/src/test/java/com/baeldung/spring/data/neo4j/MovieRepositoryIntegrationTest.java b/persistence-modules/spring-data-neo4j/src/test/java/com/baeldung/spring/data/neo4j/MovieRepositoryIntegrationTest.java index 1878eb12b6..f91fa2303c 100644 --- a/persistence-modules/spring-data-neo4j/src/test/java/com/baeldung/spring/data/neo4j/MovieRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-neo4j/src/test/java/com/baeldung/spring/data/neo4j/MovieRepositoryIntegrationTest.java @@ -1,9 +1,5 @@ package com.baeldung.spring.data.neo4j; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - import com.baeldung.spring.data.neo4j.config.MovieDatabaseNeo4jTestConfiguration; import com.baeldung.spring.data.neo4j.domain.Movie; import com.baeldung.spring.data.neo4j.domain.Person; @@ -11,44 +7,37 @@ import com.baeldung.spring.data.neo4j.domain.Role; import com.baeldung.spring.data.neo4j.repository.MovieRepository; import com.baeldung.spring.data.neo4j.repository.PersonRepository; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.neo4j.harness.Neo4j; -import org.neo4j.harness.Neo4jBuilders; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.*; +import static junit.framework.TestCase.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MovieDatabaseNeo4jTestConfiguration.class) @ActiveProfiles(profiles = "test") -@DataNeo4jTest -class MovieRepositoryIntegrationTest { +public class MovieRepositoryIntegrationTest { @Autowired - private static MovieRepository movieRepository; + private MovieRepository movieRepository; @Autowired - private static PersonRepository personRepository; + private PersonRepository personRepository; public MovieRepositoryIntegrationTest() { } - private static Neo4j embeddedDatabaseServer; - - @BeforeAll - static void initializeNeo4j() { - - embeddedDatabaseServer = Neo4jBuilders.newInProcessBuilder() - .withDisabledServer() - .build(); - + @Before + public void initializeDatabase() { System.out.println("seeding embedded database"); Movie italianJob = new Movie(); italianJob.setTitle("The Italian Job"); @@ -71,23 +60,9 @@ class MovieRepositoryIntegrationTest { movieRepository.save(italianJob); } - @DynamicPropertySource - static void neo4jProperties(DynamicPropertyRegistry registry) { - - registry.add("spring.neo4j.uri", embeddedDatabaseServer::boltURI); - registry.add("spring.neo4j.authentication.username", () -> "neo4j"); - registry.add("spring.neo4j.authentication.password", () -> null); - } - - @AfterAll - static void stopNeo4j() { - - embeddedDatabaseServer.close(); - } - @Test @DirtiesContext - void testFindByTitle() { + public void testFindByTitle() { System.out.println("findByTitle"); String title = "The Italian Job"; Movie result = movieRepository.findByTitle(title); @@ -97,7 +72,7 @@ class MovieRepositoryIntegrationTest { @Test @DirtiesContext - void testCount() { + public void testCount() { System.out.println("count"); long movieCount = movieRepository.count(); @@ -106,7 +81,7 @@ class MovieRepositoryIntegrationTest { @Test @DirtiesContext - void testFindAll() { + public void testFindAll() { System.out.println("findAll"); Collection result = movieRepository.findAll(); assertNotNull(result); @@ -115,7 +90,7 @@ class MovieRepositoryIntegrationTest { @Test @DirtiesContext - void testFindByTitleContaining() { + public void testFindByTitleContaining() { System.out.println("findByTitleContaining"); String title = "Italian"; Collection result = movieRepository.findByTitleContaining(title); @@ -125,7 +100,7 @@ class MovieRepositoryIntegrationTest { @Test @DirtiesContext - void testGraph() { + public void testGraph() { System.out.println("graph"); List> graph = movieRepository.graph(5); assertEquals(1, graph.size()); @@ -139,7 +114,7 @@ class MovieRepositoryIntegrationTest { @Test @DirtiesContext - void testDeleteMovie() { + public void testDeleteMovie() { System.out.println("deleteMovie"); movieRepository.delete(movieRepository.findByTitle("The Italian Job")); assertNull(movieRepository.findByTitle("The Italian Job")); @@ -147,7 +122,7 @@ class MovieRepositoryIntegrationTest { @Test @DirtiesContext - void testDeleteAll() { + public void testDeleteAll() { System.out.println("deleteAll"); movieRepository.deleteAll(); Collection result = movieRepository.findAll();