I have created a new Maven Project:
https://github.com/neosamples/neosamples
where I gradually copy content from:
https://github.com/luanne/flavorwocky
to better understand how it works and which dependencies are needed. For now I would like to just make it possible to unit test adding new items to a GraphRepository. Currently my project has this layout:
Where:
Application.java
package com.samples.neo4j;
...(imports)
@Configuration
@ComponentScan("com.samples.neo4j")
@EnableAutoConfiguration
@EnableTransactionManagement
@EnableNeo4jRepositories("com.samples.neo4j.repository")
public class Application extends Neo4jConfiguration {
final String grapheneUrl;
public Application() {
grapheneUrl = "http://neo4j:neopass@localhost:7474";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
config.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver").setURI(grapheneUrl);
return config;
}
@Override
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(), "com.samples.neo4j.domain");
}
@Override
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();
}
}
Where neo4j is the user and neopass is the password I am using when accessing: http://localhost:7474/browser/
And:
I am trying to run this unit test in:
@ContextConfiguration(classes = { PersistenceContext.class })
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class ServiceTest {
@Autowired
MyNodeRepository nodeRepository;
@Autowired
Session session;
@After
public void tearDown() {
session.purgeDatabase();
}
@Test
public void test() {
MyNode n = new MyNode("test");
nodeRepository.save(n);
MyNode node = IteratorUtil.firstOrNull(nodeRepository.findAll());
assertNotNull(node);
}
}
But when I run the unit test above I get the below error in the console:
2016-07-19 12:39:41,571 WARN o4j.ogm.drivers.http.request.HttpRequest: 235 - Caught response exception: Unauthorized
2016-07-19 12:39:41,596 WARN o4j.ogm.drivers.http.request.HttpRequest: 235 - Caught response exception: Auth scheme may not be null
and this stack trace:
I have been tried to customize my pom dependencies for quite some time, but I get the feeling that I am running in circles, below is my current configuration:
Any suggestions?