@Test public void testAddToExistingNamed() throws Exception { logger.debug("executing testAddToExistingNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD GRAPH ex:graph1 TO ex:graph2"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testAddToNewNamed() throws Exception { logger.debug("executing testAddToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testCopyToNewNamed() throws Exception { logger.debug("executing testCopyToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testCopyToExistingNamed() throws Exception { logger.debug("executing testCopyToExistingNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY GRAPH ex:graph1 TO ex:graph2"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph2)); assertFalse(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testClearGraph() throws Exception { logger.debug("executing testClearGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("CLEAR GRAPH <" + graph1.stringValue() + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertTrue(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testMoveToNewNamed() throws Exception { logger.debug("executing testMoveToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("MOVE GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createURI(EX_NS, "graph3"))); assertFalse(con.hasStatement(null, null, null, false, graph1)); }
@Test public void testInsertEmptyWhere() throws Exception { logger.debug("executing test testInsertEmptyWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { <" + bob + "> rdfs:label \"Bob\" . } WHERE { }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); }
@Test public void testAddToExistingNamed() throws Exception { logger.debug("executing testAddToExistingNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD GRAPH ex:graph1 TO ex:graph2"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testAddToNewNamed() throws Exception { logger.debug("executing testAddToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testCopyToNewNamed() throws Exception { logger.debug("executing testCopyToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testDropNamed() throws Exception { logger.debug("executing testDropNamed"); String update = "DROP NAMED"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertFalse(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testClearNamed() throws Exception { logger.debug("executing testClearNamed"); String update = "CLEAR NAMED"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertFalse(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testClearGraph() throws Exception { logger.debug("executing testClearGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("CLEAR GRAPH <" + graph1.stringValue() + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertTrue(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testDropGraph() throws Exception { logger.debug("executing testDropGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DROP GRAPH <" + graph1.stringValue() + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertTrue(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testDeleteDataFromGraph() throws Exception { logger.debug("executing testDeleteDataFromGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE DATA { GRAPH ex:graph1 {ex:alice foaf:knows ex:bob. } } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, true, graph1)); operation.execute(); String msg = "statement should have been deleted from graph1"; assertFalse(msg, con.hasStatement(alice, FOAF.KNOWS, bob, true, graph1)); }
@Test public void testMoveToNewNamed() throws Exception { logger.debug("executing testMoveToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("MOVE GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createURI(EX_NS, "graph3"))); assertFalse(con.hasStatement(null, null, null, false, graph1)); }
@Test public void testInsertEmptyWhere() throws Exception { logger.debug("executing test testInsertEmptyWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { <" + bob + "> rdfs:label \"Bob\" . } WHERE { }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); }
@Test public void testInsertEmptyWhereWithBinding() throws Exception { logger.debug("executing test testInsertEmptyWhereWithBinding"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {?x rdfs:label ?y . } WHERE { }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); operation.setBinding("y", f.createLiteral("Bob")); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); }
@Test public void testClearNamed() throws Exception { logger.debug("executing testClearNamed"); String update = "CLEAR NAMED"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertFalse(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testDropNamed() throws Exception { logger.debug("executing testDropNamed"); String update = "DROP NAMED"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertFalse(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }