Property Graph Model Test Suite

jbmusso edited this page Jul 12, 2016 · 15 revisions

Attention: this Wiki hosts an outdated version of the TinkerPop framework and Gremlin language documentation.

Please visit the Apache TinkerPop website and latest documentation.

Blueprints comes with a suite of test cases to ensure that any implementation of the property graph model interfaces behaves as required in order to work seamlessly within applications that depend on Blueprints. This section will discuss the test suites and how to build a simple JUnit test class to validate an implementation of this model.

There currently exists the following test suites:

  1. GraphTestSuite: ensure that vertices and edges work together properly.
  2. VertexTestSuite: ensure that vertices and their properties are added and removed properly.
  3. EdgeTestSuite: ensure that edges and their properties are added and removed properly.
  4. GraphMLReaderTestSuite: ensure that GraphML files are read properly from disk and represented properly.
  5. GMLReaderTestSuite: ensure that GML files are read properly from disk and represented properly.
  6. GraphSONReaderTestSuite: ensure that GraphSON files are read properly from disk and represented properly.
  7. KeyIndexableGraphTestSuite: ensures that graphs that support automatic key indices work properly.
  8. IndexableGraphTestSuite: ensures that graphs that support indices behave properly.
  9. IndexTestSuite: ensure that the index system works properly.
  10. TransactionalGraphTestSuite: ensures that graphs that support transactions behave properly.

Blueprints-Tests Dependency

It is necessary that the Blueprints test suite is depended when testing a Blueprints-enabled graph framework. Simply import the blueprints-tests. With this dependency the test suite is available.


Testing a Property Graph Model Implementation

To ensure that an implementation of the property graph model is implemented correctly, a simple JUnit test case of the following form will determine its compliance. Unfortunately, there is no perfect general interface solution that will work regardless of the underlying graph framework, while being specific enough to be useful. For this reason, be sure the Features of the respective Graph implementations are set correctly as this allows the test suite to dynamically alter is testing behavior to account for the various nuances of an implementation.

public class TinkerGraphTest extends GraphTest {

    public void testVertexTestSuite() throws Exception {
        doTestSuite(new VertexTestSuite(this));
        printTestPerformance("VertexTestSuite", this.stopWatch());

    public void testEdgeTestSuite() throws Exception {
        doTestSuite(new EdgeTestSuite(this));
        printTestPerformance("EdgeTestSuite", this.stopWatch());

    public void testGraphTestSuite() throws Exception {
        doTestSuite(new GraphTestSuite(this));
        printTestPerformance("GraphTestSuite", this.stopWatch());

    public void testKeyIndexableGraphTestSuite() throws Exception {
        doTestSuite(new KeyIndexableGraphTestSuite(this));
        printTestPerformance("KeyIndexableGraphTestSuite", this.stopWatch());

    public void testIndexableGraphTestSuite() throws Exception {
        doTestSuite(new IndexableGraphTestSuite(this));
        printTestPerformance("IndexableGraphTestSuite", this.stopWatch());

    public void testIndexTestSuite() throws Exception {
        doTestSuite(new IndexTestSuite(this));
        printTestPerformance("IndexTestSuite", this.stopWatch());

    public void testGraphMLReaderTestSuite() throws Exception {
        doTestSuite(new GraphMLReaderTestSuite(this));
        printTestPerformance("GraphMLReaderTestSuite", this.stopWatch());

    public void testGMLReaderTestSuite() throws Exception {
        doTestSuite(new GMLReaderTestSuite(this));
        printTestPerformance("GMLReaderTestSuite", this.stopWatch());

    public void testGraphSONReaderTestSuite() throws Exception {
        doTestSuite(new GraphSONReaderTestSuite(this));
        printTestPerformance("GraphSONReaderTestSuite", this.stopWatch());

    public Graph generateGraph() {
        return new TinkerGraph();

    public void doTestSuite(final TestSuite testSuite) throws Exception {
        String doTest = System.getProperty("testTinkerGraph");
        if (doTest == null || doTest.equals("true")) {
            for (Method method : testSuite.getClass().getDeclaredMethods()) {
                if (method.getName().startsWith("test")) {
                    System.out.println("Testing " + method.getName() + "...");