1

I'm trying to migrate to SpringBoot 2 and SDN 5, working on just getting a unit test running. My test code:

@SpringBootTest
@ContextConfiguration(classes = com.playerscoach.auth.context.PersistenceContext.class)
@RunWith(SpringRunner.class)
public class AthleteRepositoryTest {
    private static final Logger log = LoggerFactory.getLogger(AthleteRepositoryTest.class);
    @Autowired
    UserRepository userRepository;
    @Autowired
    private Session session;
    @Autowired
    private AthleteRepository athleteRepo;
    private GraphDatabaseService graphDb;
    private GraphAwareRuntime runtime;

    @Before
    public void setUp() {

        GraphDatabaseService graphDb = new GraphDatabaseFactory()
                .newEmbeddedDatabase(new File("var/graphDb"));

        GraphAwareRuntime runtime = GraphAwareRuntimeFactory
                .createRuntime(graphDb);

    }

    @After
    public void tearDown() {
        session.purgeDatabase();
    }

    /**
     * Test of findByTitle method, of class MovieRepository.
     */
    @Test
    public void testFindByEmail() {
        Athlete athlete = new Athlete.Builder()
                .firstName("Alper")
                .lastName("Akture")
                .emailAddress("alper@test.com")
                .password("password").build();
        athleteRepo.save(athlete);
        String email = "alper@test.com";
        Collection<Athlete> result = athleteRepo.findByEmailAddress(email);
        assertThat(result, notNullValue());
        assertThat(result.iterator().next().getPassword(), is("password"));
    }

    @Test
    public void testFindByLastName() {

        String lastName = "Akture";
        Collection<Athlete> result = athleteRepo.findByLastName(lastName);
        assertThat(result, notNullValue());
        assertThat(result.iterator().next().getPassword(), is("password"));
    }

}

My repository:

    public interface AthleteRepository extends Neo4jRepository<Athlete, Long> {

    Collection<Athlete> findByEmailAddress(@Param("emailAddress") String emailAddress);

    Collection<Athlete> findByLastName(@Param("lastName") String lastName);

    @Query("MATCH (a:Athlete) WHERE a.emailAddress =~ ('(?i).*'+{emailAddress}+'.*') RETURN a")
    Collection<Athlete> findByEmailContaining(@Param("emailAddress") String emailAddress);

}

My pom:

 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.M4</version>
    <relativePath/>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <neo4j-ogm.version>3.0.0</neo4j-ogm.version>
    <spring-data-releasetrain.version>Kay-RELEASE</spring-data-releasetrain.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-neo4j</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- uncomment to use embedded -->
    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-embedded-driver</artifactId>
        <version>${neo4j-ogm.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j</artifactId>
        <version>3.1.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.playerscoach.lib</groupId>
        <artifactId>lib</artifactId>
        <version>0.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.graphaware.neo4j</groupId>
        <artifactId>timetree</artifactId>
        <version>3.2.1.51.27</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.graphaware.neo4j/graphaware-framework-embedded -->
    <dependency>
        <groupId>com.graphaware.neo4j</groupId>
        <artifactId>graphaware-framework-embedded</artifactId>
        <version>3.2.5.51</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>com.graphaware.neo4j</groupId>
        <artifactId>tests</artifactId>
        <version>3.2.5.51</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        <version>1.3.4.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.neo4j.test</groupId>
        <artifactId>neo4j-harness</artifactId>
        <version>3.2.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-kernel</artifactId>
        <version>3.1.0</version>
        <type>test-jar</type>
    </dependency>

When I run the test, it hangs with the last line output in the log file:

07:53:03.526 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath:

with a dump of the entire classpath.

Any idea where I went wrong?

Alper Akture
  • 2,445
  • 1
  • 30
  • 44
  • 1
    There should be a more detailed error in the log right after the classpath. Can you double check ? The templates might also be useful to reproduce and share the error you have : https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template/tree/master/boot-2.0 – nmervaillie Oct 12 '17 at 12:35
  • Nothing in the log right after. I saw a similar project in the neo4j slack channel, https://github.com/Artgit/spring-boot-2.0.0.M4-sdn5-ogm3-saving-issue/tree/master/domain, and was able to repro it with that project. That one however works fine running the test from the command line (mine still hangs though). Which led me to this https://youtrack.jetbrains.com/issue/IDEA-107048#comment=27-2110969, but still no luck. I will try the template and report back. – Alper Akture Oct 12 '17 at 18:54
  • That seems to work, so I added some additional code for Graphaware, and Timetree to complete my test, similar to what is described here: https://stackoverflow.com/questions/30285178/neo4j-timetree-in-spring-data-neo4j-4-0, and have a new issue: https://stackoverflow.com/questions/46722136/how-to-i-configure-my-own-graphdatabaseservice-and-graphawareruntime-in-a-spring, but things look much better, thanks Nicolas. – Alper Akture Oct 13 '17 at 03:39
  • 1
    I'll have a look there. BTW, watch out for versions in your POM : TimeTree version `3.2.1.51.27` is compatible with GraphAware framework `3.2.1.51` which itself is compatible with Neo4j version `3.2.1`. In your case it should be `3.2.5.51.27`and Neo4j version `3.2.5` – nmervaillie Oct 13 '17 at 07:15

0 Answers0