Search in sources :

Example 11 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project frames by tinkerpop.

the class FramedGraphFactoryTest method testFactory.

@Test
public void testFactory() {
    Mockito.when(mockModule.configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).then(new ReturnsArgumentAt(0));
    FramedGraphFactory graphFactory = new FramedGraphFactory(mockModule);
    FramedGraph<Graph> framed = graphFactory.create(base);
    Assert.assertEquals(base, framed.getBaseGraph());
    Mockito.verify(mockModule, Mockito.times(1)).configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class));
    TransactionalGraph baseTransactional = Mockito.mock(TransactionalGraph.class);
    FramedTransactionalGraph<TransactionalGraph> framedTransactional = graphFactory.create(baseTransactional);
    Assert.assertEquals(baseTransactional, framedTransactional.getBaseGraph());
    Mockito.verify(mockModule, Mockito.times(2)).configure(Mockito.any(TransactionalGraph.class), Mockito.any(FramedGraphConfiguration.class));
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) ReturnsArgumentAt(org.mockito.internal.stubbing.answers.ReturnsArgumentAt) Test(org.junit.Test)

Example 12 with TransactionalGraph

use of com.tinkerpop.blueprints.TransactionalGraph in project blueprints by tinkerpop.

the class SparkseeGraphSpecificTestSuite method testMultipleSessions.

public void testMultipleSessions() throws InterruptedException, IOException {
    TransactionalGraph graph = (TransactionalGraph) graphTest.generateGraph();
    ((SparkseeGraph) graph).typeScope.set(true);
    this.stopWatch();
    // This test requires a multiple sessions license, 
    // so just executed if a license has been given, 
    // see SparkseeGraphTest#generateGraph(...) -> blueprints-sparksee.cfg
    com.sparsity.sparksee.gdb.SparkseeConfig cfg = new com.sparsity.sparksee.gdb.SparkseeConfig();
    if (cfg.getLicense() == null || cfg.getLicense().length() == 0) {
        printPerformance(graph.toString(), null, "skip because no license", this.stopWatch());
        graph.shutdown();
        return;
    }
    new GraphMLReader(graph).inputGraph(GraphMLReader.class.getResourceAsStream("graph-example-2.xml"));
    printPerformance(graph.toString(), null, "load", this.stopWatch());
    List<SessionThread> threads = new ArrayList<SessionThread>();
    for (int i = 0; i < 10; i++) threads.add(new SessionThread(graph));
    this.stopWatch();
    for (SessionThread th : threads) th.start();
    Thread.sleep(5000);
    for (SessionThread th : threads) th.stop = true;
    int acum = 0;
    for (SessionThread th : threads) {
        while (!th.finished) ;
        acum += th.counter;
    }
    printPerformance(graph.toString(), acum, "tx (sessions)", this.stopWatch());
    graph.shutdown();
}
Also used : GraphMLReader(com.tinkerpop.blueprints.util.io.graphml.GraphMLReader) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) ArrayList(java.util.ArrayList)

Aggregations

TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)12 Graph (com.tinkerpop.blueprints.Graph)6 Test (org.junit.Test)6 Vertex (com.tinkerpop.blueprints.Vertex)2 FramedGraphConfiguration (com.tinkerpop.frames.FramedGraphConfiguration)2 AbstractModule (com.tinkerpop.frames.modules.AbstractModule)2 ArrayList (java.util.ArrayList)2 Element (com.tinkerpop.blueprints.Element)1 KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)1 GraphTest (com.tinkerpop.blueprints.impls.GraphTest)1 GraphMLReader (com.tinkerpop.blueprints.util.io.graphml.GraphMLReader)1 Module (com.tinkerpop.frames.modules.Module)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ReturnsArgumentAt (org.mockito.internal.stubbing.answers.ReturnsArgumentAt)1 DefaultSailChangedEvent (org.openrdf.sail.helpers.DefaultSailChangedEvent)1