package be.datablend.blueprints.impls.mongodb;
import com.foursquare.fongo.Fongo;
import com.mongodb.DB;
import com.tinkerpop.blueprints.*;
import static com.tinkerpop.blueprints.BaseTest.printTestPerformance;
import com.tinkerpop.blueprints.impls.GraphTest;
import com.tinkerpop.blueprints.util.io.gml.GMLReaderTestSuite;
import com.tinkerpop.blueprints.util.io.graphml.GraphMLReaderTestSuite;
import com.tinkerpop.blueprints.util.io.graphson.GraphSONReaderTestSuite;
import java.lang.reflect.Method;
/**
* Test suite for MongoDB graph implementation.
*
* @author Davy Suvee (http://datablend.be)
*/
public class MongoDBGraphTest extends GraphTest {
private MongoDBGraph currentGraph;
/* public void testMongoDBBenchmarkTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new MongoDBBenchmarkTestSuite(this));
printTestPerformance("MongoDBBenchmarkTestSuite", this.stopWatch());
} */
public void testVertexTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new VertexTestSuite(this));
printTestPerformance("VertexTestSuite", this.stopWatch());
}
public void testEdgeTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new EdgeTestSuite(this));
printTestPerformance("EdgeTestSuite", this.stopWatch());
}
public void testGraphTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new GraphTestSuite(this));
printTestPerformance("GraphTestSuite", this.stopWatch());
}
public void testGraphQueryTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new GraphQueryTestSuite(this));
printTestPerformance("QueryTestSuite", this.stopWatch());
}
public void testVertexQueryTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new VertexQueryTestSuite(this));
printTestPerformance("QueryTestSuite", this.stopWatch());
}
public void testKeyIndexableGraphTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new KeyIndexableGraphTestSuite(this));
printTestPerformance("KeyIndexableGraphTestSuite", this.stopWatch());
}
public void testGraphMLReaderTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new GraphMLReaderTestSuite(this));
printTestPerformance("GraphMLReaderTestSuite", this.stopWatch());
}
public void testGraphSONReaderTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new GraphSONReaderTestSuite(this));
printTestPerformance("GraphSONReaderTestSuite", this.stopWatch());
}
public void testGMLReaderTestSuite() throws Exception {
this.stopWatch();
doTestSuite(new GMLReaderTestSuite(this));
printTestPerformance("GMLReaderTestSuite", this.stopWatch());
}
@Override
public Graph generateGraph() {
this.currentGraph = new MongoDBGraph("localhost", 27017);
// DB db = new Fongo("test").getDB("graph");
// this.currentGraph = new MongoDBGraph(db);
return this.currentGraph;
}
@Override
public void doTestSuite(final TestSuite testSuite) throws Exception {
for (Method method : testSuite.getClass().getDeclaredMethods()) {
if (method.getName().startsWith("test")) {
System.out.println("Testing " + method.getName() + "...");
method.invoke(testSuite);
this.currentGraph.clear();
try {
if (this.currentGraph != null)
this.currentGraph.shutdown();
} catch (Exception e) {
}
}
}
}
@Override
public Graph generateGraph(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
}