use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.
the class AbstractTestRDFConnection method named_graph_put_2_different.
@Test
public void named_graph_put_2_different() {
try (RDFConnection conn = connection()) {
conn.put(graphName, model1);
conn.put(graphName2, model2);
Model m1 = conn.fetch(graphName);
Model m2 = conn.fetch(graphName2);
assertTrue("Models not isomorphic", isomorphic(m1, model1));
assertTrue("Models not isomorphic", isomorphic(m2, model2));
}
}
use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.
the class AbstractTestRDFConnection method transaction_abort_read02.
// Not all RDFConnections support abort.
@Test
public void transaction_abort_read02() {
Assume.assumeTrue(supportsAbort());
String testDataFile = DIR + "data.trig";
try (RDFConnection conn = connection()) {
conn.begin(ReadWrite.WRITE);
conn.loadDataset(testDataFile);
conn.abort();
conn.end();
conn.begin(ReadWrite.READ);
Model m = conn.fetch();
assertTrue(m.isEmpty());
conn.end();
}
}
use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.
the class AbstractTestRDFConnection method connect_01.
// ---- Data
@Test
public void connect_01() {
@SuppressWarnings("resource") RDFConnection conn = connection();
assertFalse(conn.isClosed());
conn.close();
assertTrue(conn.isClosed());
// Allow multiple close()
conn.close();
}
use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.
the class AbstractTestRDFConnection method transaction_bad_01.
//@Test(expected=JenaTransactionException.class)
public void transaction_bad_01() {
try (RDFConnection conn = connection()) {
conn.begin(ReadWrite.WRITE);
// Should have conn.commit();
conn.end();
}
}
use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.
the class RDFConnectionExample1 method main.
public static void main(String... args) {
Query query = QueryFactory.create("SELECT * { {?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }");
Dataset dataset = DatasetFactory.createTxnMem();
RDFConnection conn = RDFConnectionFactory.connect(dataset);
Txn.executeWrite(conn, () -> {
System.out.println("Load a file");
conn.load("data.ttl");
conn.load("http://example/g0", "data.ttl");
System.out.println("In write transaction");
conn.queryResultSet(query, ResultSetFormatter::out);
});
// And again - implicit READ transaction.
System.out.println("After write transaction");
conn.queryResultSet(query, ResultSetFormatter::out);
}
Aggregations