@Test public void testOldURI() throws Exception { assertEquals(0, countAllElements()); con.begin(); con.addStatement(painter, RDF.TYPE, RDFS.CLASS); con.addStatement(painting, RDF.TYPE, RDFS.CLASS); con.addStatement(picasso, RDF.TYPE, painter, context1); con.addStatement(guernica, RDF.TYPE, painting, context1); con.addStatement(picasso, paints, guernica, context1); assertEquals(5, countAllElements()); con.commit(); con.begin(); con.clear(); con.commit(); con.begin(); con.addStatement(picasso, paints, guernica, context1); con.commit(); assertEquals(1, countAllElements()); }
@Test public void testRemoveAndClear() throws Exception { // Add some data to the repository con.begin(); con.addStatement(painter, RDF.TYPE, RDFS.CLASS); con.addStatement(painting, RDF.TYPE, RDFS.CLASS); con.addStatement(picasso, RDF.TYPE, painter, context1); con.addStatement(guernica, RDF.TYPE, painting, context1); con.addStatement(picasso, paints, guernica, context1); con.commit(); // Test removal of statements con.begin(); con.removeStatements(painting, RDF.TYPE, RDFS.CLASS); con.commit(); assertEquals("Repository should contain 4 statements in total", 4, countAllElements()); assertEquals("Named context should contain 3 statements", 3, countContext1Elements()); assertEquals( "Statement (Painting, type, Class) should no longer be in the repository", 0, countQueryResults("select 1 from {ex:Painting} rdf:type {rdfs:Class}")); con.begin(); con.removeStatements(null, null, null, context1); con.commit(); assertEquals("Repository should contain 1 statement in total", 1, countAllElements()); assertEquals("Named context should be empty", 0, countContext1Elements()); con.begin(); con.clear(); con.commit(); assertEquals("Repository should no longer contain any statements", 0, countAllElements()); }