MENU +44 (0) 333 44 GRAPH

GraphAware Blog

Neo4j Server Unit Testing with RestTest

19 Jun 2014 by Luanne Misquitta

A couple of days ago, I wrote about unit testing with GraphUnit. GraphUnit tested the state of an embedded Neo4j database. What if you run Neo4j in standalone server mode? Fortunately, you can still test it and match subgraphs using the GraphAware Neo4j RestTest library.

Setup

Grab the GraphAware Neo4j Framework and GraphAware Neo4j RestTest jars from the Downloads page. Drop them into the plugins directory of your Neo4j installation and restart the server to be able to use the API’s.

How to use it

All you have to do is POST your cypher to http://your-server-address:7474/graphaware/resttest/assertSameGraph or http://your-server-address:7474/graphaware/resttest/assertSubgraph to verify the state of your graph.

Emptying the database before the next test is achieved via POSTing to http://your-server-address:7474/graphaware/resttest/clear

Example

Continuing with the sample project from the previous post, we’ve moved away from embedded Neo4j and instead talk to a Neo4j server. ConnectionFactory now returns a handle to a JDBC Connection.

BaseTest uses the RestTest endpoints to

The unit test itself remains mostly unchanged.

Not just Java

Conveniently exposed as REST endpoints, RestTest lends itself nicely to testing against your Neo4j server in any language that can make an HTTP request.

Read more at https://github.com/graphaware/neo4j-resttest

Share this blog post:

+1 LinkedIn
comments powered by Disqus

Popular

Recent

Posts by tag

Neo4j Conference NoSQL Czech Beginner Analytics Advanced Modelling Meetup GraphAware Intermediate GraphUnit Testing Transactions Cypher Events Spring SDN OGM Recommendations Search Elasticsearch Security Enterprise NLP HCM PeopleAnalytics HR HRTech Framework Internationalization Localization

Search this blog