@Test public void testInsertNonMatchingWhere() throws Exception { logger.debug("executing test testInsertNonMatchingWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ?x rdfs:label ?y . } WHERE { ?x rdfs:comment ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); operation.execute(); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); }
@Test public void testInsertNonMatchingWhere() throws Exception { logger.debug("executing test testInsertNonMatchingWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ?x rdfs:label ?y . } WHERE { ?x rdfs:comment ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); operation.execute(); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); }
@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 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 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 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.createIRI(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.createIRI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, 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.createIRI(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 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 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 testInsertNonMatchingWhere() throws Exception { logger.debug("executing test testInsertNonMatchingWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ?x rdfs:label ?y . } WHERE { ?x rdfs:comment ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); operation.execute(); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); }
@Test public void testDeleteData() throws Exception { logger.debug("executing testDeleteData"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE DATA { ex:alice foaf:knows ex:bob. } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, true)); operation.execute(); String msg = "statement should have been deleted."; assertFalse(msg, con.hasStatement(alice, FOAF.KNOWS, bob, true)); }
@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 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 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 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 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)); }