0

I'm using Spring with a Test-Configuration that gives my an InProcessServer Neo4j Database that i use for testing. Sadly, after each @Test method, there is still scrap-data in this database. Is it possible to wipe this DB after each Test-Method?

Luanne
  • 19,145
  • 1
  • 39
  • 51
Urr4
  • 611
  • 9
  • 26

1 Answers1

1

You can inject the Session and use purgeDatabase() to delete everything from the database-

@Autowired
private Session session;

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

Your config that extends Neo4jConfiguration should have

    @Override
    @Bean
    public Session getSession() throws Exception {
        return super.getSession();
    }
Luanne
  • 19,145
  • 1
  • 39
  • 51
  • Btw: My real mistake was forgetting the @Bean annotation for the neo4jServer method in the configuration. Thus there wasn't really an InProcessServer to be used, i just forgot to turn of my remote server that was then used instead without me noticing. – Urr4 Mar 21 '16 at 07:28