@Override protected boolean matchesSPARQL(RepositoryConnection con) throws RepositoryException, QueryEvaluationException, MalformedQueryException { final TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query, baseUri); final TupleQueryResult result = tupleQuery.evaluate(); final List<BindingSet> bindingSets = QueryResults.asList(result); // FIXME: test this! return matcher.matches(bindingSets); }
@Override protected boolean matchesSPARQL(RepositoryConnection con) throws RepositoryException, QueryEvaluationException, MalformedQueryException { final TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query, baseUri); final TupleQueryResult result = tupleQuery.evaluate(); final List<BindingSet> bindingSets = QueryResults.asList(result); // FIXME: test this! return matcher.matches(bindingSets); }
assertTrue("The query should return a result", res.hasNext()); List<BindingSet> result = QueryResults.asList(res); assertEquals(10, result.size()); for (BindingSet bs : result) {
@Test public void testSES1979MinMaxInf() throws Exception { loadTestData("/testdata-query/dataset-ses1979.trig"); String query = "prefix : <http://example.org/> select (min(?o) as ?min) (max(?o) as ?max) where { ?s :float ?o }"; ValueFactory vf = conn.getValueFactory(); TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); try { List<BindingSet> result = QueryResults.asList(tq.evaluate()); assertNotNull(result); assertEquals(1, result.size()); assertEquals(vf.createLiteral(Float.NEGATIVE_INFINITY), result.get(0).getValue("min")); assertEquals(vf.createLiteral(Float.POSITIVE_INFINITY), result.get(0).getValue("max")); } catch (QueryEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testSES2336NegatedPropertyPathMod() throws Exception { loadTestData("/testdata-query/dataset-ses2336.trig"); String query = "prefix : <http://example.org/> select * where { ?s a :Test ; !:p? ?o . }"; ValueFactory vf = conn.getValueFactory(); TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); try { List<BindingSet> result = QueryResults.asList(tq.evaluate()); assertNotNull(result); IRI a = vf.createIRI(EX_NS, "a"); IRI b = vf.createIRI(EX_NS, "b"); IRI c = vf.createIRI(EX_NS, "c"); IRI d = vf.createIRI(EX_NS, "d"); IRI e = vf.createIRI(EX_NS, "e"); IRI test = vf.createIRI(EX_NS, "Test"); assertTrue(containsSolution(result, new SimpleBinding("s", a), new SimpleBinding("o", a))); assertTrue(containsSolution(result, new SimpleBinding("s", a), new SimpleBinding("o", test))); assertTrue(containsSolution(result, new SimpleBinding("s", a), new SimpleBinding("o", c))); assertTrue(containsSolution(result, new SimpleBinding("s", d), new SimpleBinding("o", d))); assertTrue(containsSolution(result, new SimpleBinding("s", d), new SimpleBinding("o", e))); assertTrue(containsSolution(result, new SimpleBinding("s", d), new SimpleBinding("o", test))); assertFalse(containsSolution(result, new SimpleBinding("s", a), new SimpleBinding("o", b))); } catch (QueryEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }