Anyone have an example of unit tests running for Neo4j inside a Spring Boot 
1.4m2 webapp? 

I've followed the latest Spring Boot docs, but it seems unable to wire up 
the Neo4j repository, maybe b/c there is no web session, but a mock and/or 
webEnvironment didn't help.

Error: *"Injection of autowired dependencies failed; nested exception is 
java.lang.IllegalStateException: No thread-bound request found: Are you 
referring to request attributes outside of an actual web request"*

Someone asked about How to do Integration Testing with Spring Data Neo4j & 
SDN 
<http://stackoverflow.com/questions/29668685/how-to-do-integration-test-in-spring-data-neo4j-sdn4>
 last 
year, but no answer/example.
SDN4-University 
<https://github.com/neo4j-examples/sdn4-university/tree/master/src> doesn't 
have a test folder, so no ready examples there... but maybe somewhere else? 

Thanks,
Tim

package com.foo.tcolson;

import (others removed for brevity)

import static org.assertj.core.api.Assertions.assertThat;


@RunWith(SpringRunner.class)

//@DataJpaTest // ideaJPA slice doesn't seem to work 

@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)


public class NeoApplicationTests {

    @Autowired

    private ServerRepository repository; // didn't help, only needed by the 
ServerService anyway


    @Autowired

    private ServerService serverService;


    @Autowired

    MockHttpServletRequest request; // didn't help


    @Autowired

    MockHttpSession session; // didn't help


    @Test

    public void testServerLoad() {

        Server s = this.serverService.findByName("wiki.foo.com");

        assertThat(s.getName().equals("wiki.foo.com"));

    }

}


-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to