I am using Spring Data Neo4j, have created one application in Spring. I could run my application with the help of JUnit test cases. But every time I run my test cases it creates a new database in the directory path specified using <neo4j:config storeDirectory="target/neo4j-db"/>. This creates db in the same location where my workspace is present in Eclipse.
I have installed Neo4j debian package in my ubuntu which has by default database in /var/lib/neo4j/data/graph.db. I want my application to use this database instead of creating the one in target/neo4j-db. I tried to replace target/neo4j-db by /var/lib/neo4j/data/graph.db and have given permission to read and write to the database. But it does not work.
What is wrong with this configurations? Am I missing anything?
To run your JUnit tests against a Neo4j DB you have 3 choices
@Rollback(false)on the methods you want. This has to be done because SpringJUnit4ClassRunner.class will rollback all changes done to the DB during the tests.Use a REST approach (and again use the trick with
@Rollback(false)for the SpringJUnit4ClassRunner.class). For this to work contrary to the local method you have to have started the Neo4j server before you run your tests. You also have to configure your xml file like this:<neo4j:config graphDatabaseService="graphDatabaseService"/><bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data/" index="0" />
</bean>
<neo4j:config graphDatabaseService="graphDatabaseService"/><bean id="graphDatabaseService" class="org.neo4j.test.ImpermanentGraphDatabase" destroy-method="shutdown"/>