/** * Modified to test SPARQL instead of Serql. */ @Override public void testEmptyRepository() throws Exception { // repository should be empty assertEquals("Empty repository should not return any statements", 0, countAllElements()); assertEquals("Named context should be empty", 0, countContext1Elements()); assertEquals("Empty repository should not return any context identifiers", 0, countElements(con.getContextIDs())); assertEquals("Empty repository should not return any query results", 0, countQueryResults("select * where { ?S ?P ?O }")); }
assertEquals("Repository should contain 5 statements in total", 5, countAllElements()); assertEquals("Named context should contain 3 statements", 3, countContext1Elements()); assertEquals("Repository should have 1 context identifier", 1, countElements(con.getContextIDs())); assertEquals("Repository should contain 5 statements in total", 5, countQueryResults("select * where { ?S ?P ?O }")); assertEquals("Statement (Painter, type, Class) should be in the repository", 1, countQueryResults("select * where { ex:Painter rdf:type rdfs:Class }")); assertEquals("Statement (picasso, type, Painter) should be in the repository", 1, countQueryResults("select * where { ex:picasso rdf:type ex:Painter}")); assertEquals("Statement (Painter, paints, Painting) should not be in the repository", 0, countQueryResults("select * where {ex:Painter ex:paints ex:Painting}")); assertEquals("Statement (picasso, creates, guernica) should not be in the repository", 0, countQueryResults("select * where {ex:picasso ex:creates ex:guernica}")); assertEquals("Repository should contain 2 statements matching (picasso, _, _)", 2, countQueryResults("select * where {ex:picasso ?P ?O}")); assertEquals("Repository should contain 1 statement matching (picasso, paints, _)", 1, countQueryResults("select * where {ex:picasso ex:paints ?O}")); assertEquals("Repository should contain 4 statements matching (_, type, _)", 4, countQueryResults("select * where {?S rdf:type ?O}"));
/** * Modified to test SPARQL instead of Serql. */ @Override public void testEmptyRepository() throws Exception { // repository should be empty assertEquals("Empty repository should not return any statements", 0, countAllElements()); assertEquals("Named context should be empty", 0, countContext1Elements()); assertEquals("Empty repository should not return any context identifiers", 0, countElements(con.getContextIDs())); assertEquals("Empty repository should not return any query results", 0, countQueryResults("select * where { ?S ?P ?O }")); }
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 * where {ex:Painting rdf:type rdfs:Class}")); con.commit(); assertEquals("Repository should contain 1 statement in total", 1, countAllElements()); assertEquals("Named context should be empty", 0, countContext1Elements()); assertEquals("Repository should no longer contain any statements", 0, countAllElements());
assertEquals(0, countAllElements()); con.addStatement(painter, RDF.TYPE, RDFS.CLASS); con.addStatement(painting, RDF.TYPE, RDFS.CLASS); con.addStatement(guernica, RDF.TYPE, painting, context1); con.commit(); assertEquals(4, countAllElements()); con2.addStatement(RDF.NIL, RDF.TYPE, RDF.LIST); String query = "SELECT ?S ?P ?O WHERE { ?S ?P ?O }"; assertEquals(nexpected, countElements(queryResult)); Runnable clearer = new Runnable() {
assertEquals(subj, st.getSubject()); assertEquals(pred, st.getPredicate()); assertEquals(obj, st.getObject()); assertTrue(!stIter.hasNext()); } finally { assertEquals(subj, bindings.getValue("S")); assertEquals(pred, bindings.getValue("P")); assertEquals(obj, bindings.getValue("O")); assertTrue(!iter.hasNext()); } finally {
assertEquals("Wrong number of query results", 2, resultCount); assertEquals("Wrong number of query results", 1, resultCount); assertEquals("Wrong number of query results", 1, resultCount); assertEquals("Wrong number of query results", 2, resultCount); assertEquals("Wrong number of query results", 0, resultCount); assertEquals("Wrong number of query results", 1, resultCount);
assertEquals("Repository should contain 5 statements in total", 5, countAllElements()); assertEquals("Named context should contain 3 statements", 3, countContext1Elements()); assertEquals("Repository should have 1 context identifier", 1, countElements(con.getContextIDs())); assertEquals("Repository should contain 5 statements in total", 5, countQueryResults("select * where { ?S ?P ?O }")); assertEquals("Statement (Painter, type, Class) should be in the repository", 1, countQueryResults("select * where { ex:Painter rdf:type rdfs:Class }")); assertEquals("Statement (picasso, type, Painter) should be in the repository", 1, countQueryResults("select * where { ex:picasso rdf:type ex:Painter}")); assertEquals("Statement (Painter, paints, Painting) should not be in the repository", 0, countQueryResults("select * where {ex:Painter ex:paints ex:Painting}")); assertEquals("Statement (picasso, creates, guernica) should not be in the repository", 0, countQueryResults("select * where {ex:picasso ex:creates ex:guernica}")); assertEquals("Repository should contain 2 statements matching (picasso, _, _)", 2, countQueryResults("select * where {ex:picasso ?P ?O}")); assertEquals("Repository should contain 1 statement matching (picasso, paints, _)", 1, countQueryResults("select * where {ex:picasso ex:paints ?O}")); assertEquals("Repository should contain 4 statements matching (_, type, _)", 4, countQueryResults("select * where {?S rdf:type ?O}"));
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 * where {ex:Painting rdf:type rdfs:Class}")); con.commit(); assertEquals("Repository should contain 1 statement in total", 1, countAllElements()); assertEquals("Named context should be empty", 0, countContext1Elements()); assertEquals("Repository should no longer contain any statements", 0, countAllElements());
assertEquals(0, countAllElements()); con.addStatement(painter, RDF.TYPE, RDFS.CLASS); con.addStatement(painting, RDF.TYPE, RDFS.CLASS); con.addStatement(guernica, RDF.TYPE, painting, context1); con.commit(); assertEquals(4, countAllElements()); con2.addStatement(RDF.NIL, RDF.TYPE, RDF.LIST); String query = "SELECT ?S ?P ?O WHERE { ?S ?P ?O }"; assertEquals(nexpected, countElements(queryResult)); Runnable clearer = new Runnable() {
assertEquals(subj, st.getSubject()); assertEquals(pred, st.getPredicate()); assertEquals(obj, st.getObject()); assertTrue(!stIter.hasNext()); } finally { assertEquals(subj, bindings.getValue("S")); assertEquals(pred, bindings.getValue("P")); assertEquals(obj, bindings.getValue("O")); assertTrue(!iter.hasNext()); } finally {
assertEquals("Wrong number of query results", 2, resultCount); assertEquals("Wrong number of query results", 1, resultCount); assertEquals("Wrong number of query results", 1, resultCount); assertEquals("Wrong number of query results", 2, resultCount); assertEquals("Wrong number of query results", 0, resultCount); assertEquals("Wrong number of query results", 1, resultCount);
assertEquals(3, countElements(con.getStatements(null, RDF.TYPE, RDFS.CLASS, false))); assertEquals(2, countElements(con.getStatements(null, RDF.TYPE, RDF.PROPERTY, false)));
assertEquals(3, countElements(con.getStatements(null, RDF.TYPE, RDFS.CLASS, false))); assertEquals(2, countElements(con.getStatements(null, RDF.TYPE, RDF.PROPERTY, false)));