use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestUpdateOperations method load1.
@Test
public void load1() {
DatasetGraph gs = graphStore();
UpdateRequest req = UpdateFactory.create("LOAD <" + DIR + "/D.nt>");
UpdateAction.execute(req, gs);
assertEquals(1, gs.getDefaultGraph().size());
assertFalse(gs.listGraphNodes().hasNext());
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestUpdateOperations method delete_insert_where_01.
// Check constant and template quads
@Test
public void delete_insert_where_01() {
DatasetGraph dsg0 = DatasetGraphFactory.create();
UpdateRequest req = UpdateFactory.create("INSERT DATA { <x> <p> 2 . <z> <q> 2 . <z> <q> 3 . }");
UpdateAction.execute(req, dsg0);
assertEquals(3, dsg0.getDefaultGraph().size());
AtomicLong counterIns = new AtomicLong(0);
AtomicLong counterDel = new AtomicLong(0);
DatasetGraph dsg = new DatasetGraphWrapper(dsg0) {
@Override
public void add(Quad quad) {
counterIns.incrementAndGet();
super.add(quad);
}
@Override
public void delete(Quad quad) {
counterDel.incrementAndGet();
super.delete(quad);
}
};
// WHERE clause doubles the effect.
String s = "DELETE { ?x <p> 2 . <z> <q> 2 } INSERT { ?x <p> 1 . <x> <q> 1 } WHERE { ?x <p> ?o {} UNION {} }";
req = UpdateFactory.create(s);
UpdateAction.execute(req, dsg);
// 3 : 1 constant, 2 from template.
assertEquals(3, counterIns.get());
assertEquals(3, counterIns.get());
assertEquals(3, dsg.getDefaultGraph().size());
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestUpdateOperations method load4.
// Bad: loading quads into a named graph
@Test(expected = UpdateException.class)
public void load4() {
DatasetGraph gs = graphStore();
UpdateRequest req = UpdateFactory.create("LOAD <" + DIR + "/D.nq> INTO GRAPH <" + gName.getURI() + ">");
UpdateAction.execute(req, gs);
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestUpdateOperations method load3.
// Quad loading
@Test
public void load3() {
DatasetGraph gs = graphStore();
UpdateRequest req = UpdateFactory.create("LOAD <" + DIR + "/D.nq>");
UpdateAction.execute(req, gs);
assertEquals(0, gs.getDefaultGraph().size());
gs.containsGraph(NodeFactory.createURI("http://example/"));
assertEquals(1, gs.getGraph(gName).size());
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class AbstractTestUpdateGraph method testUpdateScript4.
@Test
public void testUpdateScript4() {
DatasetGraph gStore = getEmptyDatasetGraph();
script(gStore, "data-1.ru");
assertTrue(graphContains(gStore.getDefaultGraph(), new Triple(s, p, NodeFactoryExtra.parseNode("123"))));
}
Aggregations