Mikesname
Mikesname

Reputation: 8901

Testing Neo4j unmanaged extensions

Much of our application functionality is exposed via a Neo4j unmanaged extension. Currently, to test this functionality (in as realistic a way possible) we use the WrappingNeoServerBootstrapper class to start a server programmatically, just as other extensions such as the authentication-extension do.

The WrappingNeoServerBootstrapper class is now deprecated, however, and there doesn't appear to be a replacement. So assuming unmanaged extensions aren't going away at some point (and I hope they're not) what's the best way to test them? Is something like the Jersey test framework the recommended approach?

Upvotes: 2

Views: 405

Answers (2)

Mikesname
Mikesname

Reputation: 8901

With a big props to jjaderberg's pointer and Mark Needham's blog, it seems what was needed was the ServerBuilder, used ala:

CommunityNeoServer server = CommunityServerBuilder
    .server()
    .onPort(7575)
    .withThirdPartyJaxRsPackage("my.resource.package", "/endpoint")
    .build();
server.start();

Upvotes: 3

Stefan Armbruster
Stefan Armbruster

Reputation: 39925

You might want to take a look at a project of mine: https://github.com/sarmbruster/neo4j-spock-extension It provides some extensions to Spock to make testing unmanaged extension easy.

For an example of a black box test, see SampleNeo4jServerSpec. This spawns a neo4j server with a unmanaged extension and fires REST requests for testing.

The other type of test is a white box test, see SampleNeo4jSpec. This just instantiates the unmanaged extension and calls the methods there directly.

I will publish a more verbose blog post on neo4j-spock-extension next weeks.

Upvotes: 2

Related Questions