use of org.apache.jena.graph.Graph in project jena by apache.
the class TestConnectionPooled method reuseJDBCConection.
@Test
public void reuseJDBCConection() {
Triple t1 = SSE.parseTriple("(:x1 :p :z)");
Triple t2 = SSE.parseTriple("(:x2 :p :z)");
boolean explicitTransactions = false;
// Make store.
{
SDBConnection sConn1 = SDBConnectionFactory.create(conn);
Store store1 = StoreFactory.create(sConn1, store.getLayoutType(), store.getDatabaseType());
if (explicitTransactions)
store1.getConnection().getTransactionHandler().begin();
Graph graph1 = SDBFactory.connectDefaultGraph(store1);
graph1.add(t1);
assertTrue(graph1.contains(t1));
if (explicitTransactions) {
store1.getConnection().getTransactionHandler().commit();
assertTrue(graph1.contains(t1));
}
//store1.close() ;
}
// Mythically return conn to the pool.
// Get from pool
// i.e. same connection. Make a store around it
{
SDBConnection sConn2 = SDBConnectionFactory.create(conn);
Store store2 = StoreFactory.create(sConn2, store.getLayoutType(), store.getDatabaseType());
if (explicitTransactions)
store2.getConnection().getTransactionHandler().begin();
Graph graph2 = SDBFactory.connectDefaultGraph(store2);
assertTrue(graph2.contains(t1));
graph2.add(t2);
assertTrue(graph2.contains(t2));
if (explicitTransactions)
store2.getConnection().getTransactionHandler().commit();
//store2.close() ;
}
System.exit(0);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class AbstractTestDatasetGraphAccessor method put_02.
@Test
public void put_02() {
DatasetGraphAccessor updater = getDatasetUpdater();
updater.httpPut(n1, graph1);
Graph graph = updater.httpGet();
assertNullOrEmpty(graph);
graph = updater.httpGet(n1);
assertNotNull("Graph is null", graph);
assertTrue(graph.isIsomorphicWith(graph1));
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class AbstractTestDatasetGraphAccessor method put_01.
@Test
public void put_01() {
DatasetGraphAccessor updater = getDatasetUpdater();
updater.httpPut(graph1);
Graph graph = updater.httpGet();
assertNotNull("Graph is null", graph);
assertTrue(graph.isIsomorphicWith(graph1));
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class GraphMakerContractTest method testListAfterDelete.
/**
* Test that a maker with some things put in and then some removed gets the
* right things listed.
*/
@ContractTest
public void testListAfterDelete() {
String x = "x_y", y = "y//zub", z = "a:b/c";
Graph X = graphMaker.createGraph(x);
Graph Y = graphMaker.createGraph(y);
Graph Z = graphMaker.createGraph(z);
graphMaker.removeGraph(x);
Set<String> s = GraphHelper.iteratorToSet(graphMaker.listGraphs());
assertEquals(TestUtils.setOfStrings(y + " " + z), s);
X.close();
Y.close();
Z.close();
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class GraphMakerContractTest method testGetGraph.
/**
* Foo trivial test that getGraph delivers a proper graph, not cheating with
* null, and that getGraph() "always" delivers the same Graph.
*/
@ContractTest
public void testGetGraph() {
Graph g1 = graphMaker.getGraph();
assertFalse("should deliver a Graph", g1 == null);
assertSame(g1, graphMaker.getGraph());
g1.close();
}
Aggregations