Java Code Examples for org.eclipse.rdf4j.query.TupleQueryResult#next()
The following examples show how to use
org.eclipse.rdf4j.query.TupleQueryResult#next() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLuceneSailTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testQueryWithSpecifiedSubject() throws RepositoryException, MalformedQueryException, QueryEvaluationException { try (RepositoryConnection connection = repository.getConnection()) { // fire a query with the subject pre-specified TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SERQL, QUERY_STRING); query.setBinding("Subject", SUBJECT_1); query.setBinding("Query", vf.createLiteral("one")); TupleQueryResult result = query.evaluate(); // check that this subject and only this subject is returned assertTrue(result.hasNext()); BindingSet bindings = result.next(); assertEquals(SUBJECT_1, (IRI) bindings.getValue("Subject")); assertNotNull(bindings.getValue("Score")); assertFalse(result.hasNext()); } }
Example 2
Source File: RepositoryConnectionTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private int size(IRI defaultGraph) throws RepositoryException, MalformedQueryException, QueryEvaluationException { TupleQuery qry = testCon.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT * { ?s ?p ?o }"); SimpleDataset dataset = new SimpleDataset(); dataset.addDefaultGraph(defaultGraph); qry.setDataset(dataset); TupleQueryResult result = qry.evaluate(); try { int count = 0; while (result.hasNext()) { result.next(); count++; } return count; } finally { result.close(); } }
Example 3
Source File: AbstractQueryResultIOTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void doTupleMissingStartQueryResult(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links, String stylesheetUrl) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); // Test for handling when startDocument and startHeader are not called writer.startDocument(); writer.handleStylesheet(stylesheetUrl); writer.startHeader(); writer.handleLinks(links); writer.endHeader(); try { while (input.hasNext()) { BindingSet bindingSet = input.next(); writer.handleSolution(bindingSet); } writer.endQueryResult(); fail("Expected exception when calling handleSolution without startQueryResult"); } catch (IllegalStateException ise) { // Expected exception } finally { input.close(); } }
Example 4
Source File: RemoteRepositoryTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static int runQuery(RepositoryConnection conn, IRI instance) throws Exception { TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT * WHERE { <" + instance.stringValue() + "> ?p ?o }"); TupleQueryResult res = null; try { res = query.evaluate(); int count = 0; while (res.hasNext()) { res.next(); count++; } return count; } finally { if (res != null) { res.close(); } } }
Example 5
Source File: SparqlAggregatesTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelect() throws Exception { TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, selectNameMbox); TupleQueryResult result = query.evaluate(); assertTrue(result.hasNext()); result.next(); result.next(); assertFalse(result.hasNext()); result.close(); }
Example 6
Source File: SpifSailTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSplit() throws Exception { TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, "prefix spif: <http://spinrdf.org/spif#> " + "select ?x where {?x spif:split ('1,2,3' ',')}"); TupleQueryResult tqr = tq.evaluate(); for (int i = 1; i <= 3; i++) { BindingSet bs = tqr.next(); assertThat(((Literal) bs.getValue("x")).stringValue()).isEqualTo(Integer.toString(i)); } assertFalse(tqr.hasNext()); }
Example 7
Source File: StatsGenerator.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
private static Set<String> getActualResults(String queryName) throws RepositoryException, MalformedQueryException, QueryEvaluationException { Set<String> actualResults = new HashSet<String>() ; String queryString = "PREFIX bigrdfbench: <http://bigrdfbench.aksw.org/schema/> \n" + " Select ?names ?values \n" + " WHERE \n" + " {\n" + " ?s bigrdfbench:queryName <http://aksw.org/bigrdfbench/query/"+queryName+">.\n" + " <http://aksw.org/bigrdfbench/query/"+queryName+"> bigrdfbench:bindingNames ?names.\n" + " <http://aksw.org/bigrdfbench/query/"+queryName+"> bigrdfbench:bindingValues ?values\n" + " }"; TupleQuery tupleQuery = ResultsLoader.con.prepareTupleQuery(QueryLanguage.SPARQL, queryString); TupleQueryResult res = tupleQuery.evaluate(); while(res.hasNext()) { BindingSet result = res.next(); String[] bindingNames = result.getValue("names").stringValue().replace("'", "\"").replace("[", "").replace("]", "").split(";"); String[] bindingValues = result.getValue("values").stringValue().replace("'", "\"").replace("[", "").replace("]", "").split(";"); String actualResult = "["; for(int i=0 ; i < bindingNames.length;i++) { if(i<bindingNames.length-1) actualResult= actualResult+bindingNames[i]+"="+bindingValues[i]+";"; else actualResult= actualResult+bindingNames[i]+"="+bindingValues[i]+"]"; } actualResults.add(actualResult); // System.out.println(actualResult); } // System.out.println(actualResults.size()); return actualResults; }
Example 8
Source File: HalyardExport.java From Halyard with Apache License 2.0 | 5 votes |
@Override public void writeTupleQueryResult(TupleQueryResult queryResult) throws ExportException { try { while (queryResult.hasNext()) { queryResult.next(); tick(); } } catch (QueryEvaluationException e) { throw new ExportException(e); } }
Example 9
Source File: TriGParserTestCase.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parseNegativeTriGEvalTests(TestSuite suite, String fileBasePath, String testBaseUrl, String manifestBaseUrl, RepositoryConnection con) throws Exception { StringBuilder negativeEvalQuery = new StringBuilder(); negativeEvalQuery.append(" PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>\n"); negativeEvalQuery.append(" PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>\n"); negativeEvalQuery.append(" PREFIX rdft: <http://www.w3.org/ns/rdftest#>\n"); negativeEvalQuery.append(" SELECT ?test ?testName ?inputURL ?outputURL \n"); negativeEvalQuery.append(" WHERE { \n"); negativeEvalQuery.append(" ?test a rdft:TestTrigNegativeEval . "); negativeEvalQuery.append(" ?test mf:name ?testName . "); negativeEvalQuery.append(" ?test mf:action ?inputURL . "); negativeEvalQuery.append(" }"); TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SPARQL, negativeEvalQuery.toString()) .evaluate(); // Add all negative eval tests to the test suite while (queryResult.hasNext()) { BindingSet bindingSet = queryResult.next(); IRI nextTestUri = (IRI) bindingSet.getValue("test"); String nextTestName = ((Literal) bindingSet.getValue("testName")).getLabel(); String nextTestFile = removeBase(((IRI) bindingSet.getValue("inputURL")).stringValue(), manifestBaseUrl); String nextInputURL = fileBasePath + nextTestFile; String nextBaseUrl = testBaseUrl + nextTestFile; suite.addTest(new NegativeParserTest(nextTestUri, nextTestName, nextInputURL, nextBaseUrl, createTriGParser(), FailureMode.DO_NOT_IGNORE_FAILURE)); } queryResult.close(); }
Example 10
Source File: SpifSailTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testFor() throws Exception { TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, "prefix spif: <http://spinrdf.org/spif#> " + "select ?x where {?x spif:for (1 4)}"); TupleQueryResult tqr = tq.evaluate(); for (int i = 1; i <= 4; i++) { BindingSet bs = tqr.next(); assertThat(((Literal) bs.getValue("x")).intValue()).isEqualTo(i); } assertFalse(tqr.hasNext()); }
Example 11
Source File: TurtleParserTestCase.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parseNegativeTurtleEvalTests(TestSuite suite, String fileBasePath, String testBaseUrl, String manifestBaseUrl, RepositoryConnection con) throws Exception { StringBuilder negativeEvalQuery = new StringBuilder(); negativeEvalQuery.append(" PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>\n"); negativeEvalQuery.append(" PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>\n"); negativeEvalQuery.append(" PREFIX rdft: <http://www.w3.org/ns/rdftest#>\n"); negativeEvalQuery.append(" SELECT ?test ?testName ?inputURL ?outputURL \n"); negativeEvalQuery.append(" WHERE { \n"); negativeEvalQuery.append(" ?test a rdft:TestTurtleNegativeEval . "); negativeEvalQuery.append(" ?test mf:name ?testName . "); negativeEvalQuery.append(" ?test mf:action ?inputURL . "); negativeEvalQuery.append(" }"); TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SPARQL, negativeEvalQuery.toString()) .evaluate(); // Add all negative eval tests to the test suite while (queryResult.hasNext()) { BindingSet bindingSet = queryResult.next(); IRI nextTestUri = (IRI) bindingSet.getValue("test"); String nextTestName = ((Literal) bindingSet.getValue("testName")).getLabel(); String nextTestFile = removeBase(((IRI) bindingSet.getValue("inputURL")).toString(), manifestBaseUrl); String nextInputURL = fileBasePath + nextTestFile; String nextBaseUrl = testBaseUrl + nextTestFile; suite.addTest(new NegativeParserTest(nextTestUri, nextTestName, nextInputURL, nextBaseUrl, createTurtleParser(), FailureMode.DO_NOT_IGNORE_FAILURE)); } queryResult.close(); }
Example 12
Source File: QuetzalSummary.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
void fillMap(RepositoryConnection con, String query, SortedMap<KeyTuple, ValueTuple> map, Map<String, ValueTuple> purls, boolean isSbj) { TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); while (result.hasNext()) { BindingSet row = result.next(); String endpoint = row.getValue("url").stringValue(); String eid = endpoints.get(endpoint); if (eid == null) { eid = "sparql_" + endpoint.replace("http://", "").replace("/", "_"); endpoints.put(endpoint, eid); } String predicate = getString(row.getValue("p").stringValue()); String val = getString(row.getValue("val").stringValue()); KeyTuple kt = new KeyTuple(predicate, val); updateMap(map, kt, eid); KeyTuple kt0 = new KeyTuple(null, val); updateMap(map, kt0, eid); if (purls != null) { updateMap(purls, predicate, eid); Set<String> ps = urlToPredicates.get(eid); if (ps == null) { ps = new HashSet<String>(); urlToPredicates.put(eid, ps); } ps.add(predicate); } updateSbjObjAuths(new UrlPredicateKey(eid, predicate), val, isSbj); //updateSbjObjAuths(new UrlPredicateKey(eid, null), val, isSbj); } }
Example 13
Source File: AbstractNTriplesParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parsePositiveNTriplesSyntaxTests(TestSuite suite, String fileBasePath, String testLocationBaseUri, RepositoryConnection con) throws Exception { StringBuilder positiveQuery = new StringBuilder(); positiveQuery.append(" PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>\n"); positiveQuery.append(" PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>\n"); positiveQuery.append(" PREFIX rdft: <http://www.w3.org/ns/rdftest#>\n"); positiveQuery.append(" SELECT ?test ?testName ?inputURL ?outputURL \n"); positiveQuery.append(" WHERE { \n"); positiveQuery.append(" ?test a rdft:TestNTriplesPositiveSyntax . "); positiveQuery.append(" ?test mf:name ?testName . "); positiveQuery.append(" ?test mf:action ?inputURL . "); positiveQuery.append(" }"); TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SPARQL, positiveQuery.toString()).evaluate(); // Add all positive parser tests to the test suite while (queryResult.hasNext()) { BindingSet bindingSet = queryResult.next(); IRI nextTestUri = (IRI) bindingSet.getValue("test"); String nextTestName = ((Literal) bindingSet.getValue("testName")).getLabel(); String nextTestFile = removeBase(((IRI) bindingSet.getValue("inputURL")).toString(), testLocationBaseUri); String nextInputURL = fileBasePath + nextTestFile; String nextBaseUrl = testLocationBaseUri + nextTestFile; suite.addTest(new PositiveParserTest(nextTestUri, nextTestName, nextInputURL, null, nextBaseUrl, createRDFParser(), createRDFParser())); } queryResult.close(); }
Example 14
Source File: AbstractNQuadsParserTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parsePositiveNQuadsSyntaxTests(TestSuite suite, String fileBasePath, String testLocationBaseUri, RepositoryConnection con) throws Exception { StringBuilder positiveQuery = new StringBuilder(); positiveQuery.append(" PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>\n"); positiveQuery.append(" PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>\n"); positiveQuery.append(" PREFIX rdft: <http://www.w3.org/ns/rdftest#>\n"); positiveQuery.append(" SELECT ?test ?testName ?inputURL ?outputURL \n"); positiveQuery.append(" WHERE { \n"); positiveQuery.append(" ?test a rdft:TestNQuadsPositiveSyntax . "); positiveQuery.append(" ?test mf:name ?testName . "); positiveQuery.append(" ?test mf:action ?inputURL . "); positiveQuery.append(" }"); TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SPARQL, positiveQuery.toString()).evaluate(); // Add all positive parser tests to the test suite while (queryResult.hasNext()) { BindingSet bindingSet = queryResult.next(); IRI nextTestUri = (IRI) bindingSet.getValue("test"); String nextTestName = ((Literal) bindingSet.getValue("testName")).getLabel(); String nextTestFile = removeBase(((IRI) bindingSet.getValue("inputURL")).toString(), testLocationBaseUri); String nextInputURL = fileBasePath + nextTestFile; String nextBaseUrl = testLocationBaseUri + nextTestFile; suite.addTest(new PositiveParserTest(nextTestUri, nextTestName, nextInputURL, null, nextBaseUrl, createRDFParser(), createRDFParser())); } queryResult.close(); }
Example 15
Source File: FedSumConfig.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
/** * Load common predicate list using the threshold value specified as input * @throws RepositoryException * @throws MalformedQueryException * @throws QueryEvaluationException */ public static void loadCommonPredList() throws RepositoryException, MalformedQueryException, QueryEvaluationException { String queryString = "Prefix ds:<http://aksw.org/fedsum/> " + "SELECT DISTINCT ?p " + " WHERE {?s ds:predicate ?p. }"; TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString); TupleQueryResult result = tupleQuery.evaluate(); ArrayList<String> FedSumPredicates = new ArrayList<String>(); while(result.hasNext()) { FedSumPredicates.add(result.next().getValue("p").stringValue()); } //---check each distinct for(String predicate:FedSumPredicates) { int count = 0; queryString = "Prefix ds:<http://aksw.org/fedsum/> " + "SELECT Distinct ?url " + " WHERE {?s ds:url ?url. " + " ?s ds:capability ?cap. " + " ?cap ds:predicate <" + predicate + "> }" ; tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString); result = tupleQuery.evaluate(); while(result.hasNext()) { result.next(); count++; } double threshold = (double) count/dataSources.size(); if(threshold>=commonPredThreshold) commonPredicates.add(predicate); } // System.out.println(commonPredicates); }
Example 16
Source File: ProviderUtil.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
/** * Checks the connection by submitting a SPARQL SELECT query: * * SELECT * WHERE { ?s ?p ?o } LIMIT 1 * * Throws an exception if the query cannot be evaluated * successfully for some reason (indicating that the * endpoint is not ok) * * @param repo * @throws RepositoryException * @throws QueryEvaluationException * @throws MalformedQueryException */ public static long checkConnectionIfConfigured(Config cfg, Repository repo) { if (!cfg.isValidateRepositoryConnections()) { return 0; } long startTime = System.currentTimeMillis(); RepositoryConnection conn = repo.getConnection(); try { TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT * WHERE { ?s ?p ?o } LIMIT 1"); TupleQueryResult qRes = null; try { qRes = query.evaluate(); if (!qRes.hasNext()) { log.warn("No data in provided repository (" + repo + ")"); } while (qRes.hasNext()) qRes.next(); } finally { if (qRes != null) { Iterations.closeCloseable(qRes); } } } finally { conn.close(); } return System.currentTimeMillis() - startTime; }
Example 17
Source File: QuetzalConfig.java From CostFed with GNU Affero General Public License v3.0 | 4 votes |
/** * Load common predicate list using the threshold value specified as input */ public void loadCommonPredList(List<RepositoryConnection> conns) { String queryString = "Prefix ds:<http://aksw.org/quetsal/> " + "SELECT DISTINCT ?p " + " WHERE {?s ds:predicate ?p. }"; for (RepositoryConnection con : conns) { TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString); TupleQueryResult result = tupleQuery.evaluate(); ArrayList<String> fedSumPredicates = new ArrayList<String>(); while(result.hasNext()) { fedSumPredicates.add(result.next().getValue("p").stringValue()); } //---check each distinct int dscount = summary_.lookupSources(null, null, null).size(); for (String predicate : fedSumPredicates) { int count = 0; queryString = "Prefix ds:<http://aksw.org/quetsal/> " + "SELECT Distinct ?url " + " WHERE {?s ds:url ?url. " + " ?s ds:capability ?cap. " + " ?cap ds:predicate <" + predicate + "> }" ; tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString); result = tupleQuery.evaluate(); while(result.hasNext()) { result.next(); count++; } double threshold = (double) count/dscount; if (threshold >= commonPredThreshold) { commonPredicates.add(predicate); } } } // System.out.println(commonPredicates); }
Example 18
Source File: TriGParserTestCase.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void parsePositiveTriGEvalTests(TestSuite suite, String fileBasePath, String testBaseUrl, String manifestBaseUrl, RepositoryConnection con) throws Exception { StringBuilder positiveEvalQuery = new StringBuilder(); positiveEvalQuery.append(" PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>\n"); positiveEvalQuery.append(" PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>\n"); positiveEvalQuery.append(" PREFIX rdft: <http://www.w3.org/ns/rdftest#>\n"); positiveEvalQuery.append(" SELECT ?test ?testName ?inputURL ?outputURL \n"); positiveEvalQuery.append(" WHERE { \n"); positiveEvalQuery.append(" ?test a rdft:TestTrigEval . "); positiveEvalQuery.append(" ?test mf:name ?testName . "); positiveEvalQuery.append(" ?test mf:action ?inputURL . "); positiveEvalQuery.append(" ?test mf:result ?outputURL . "); positiveEvalQuery.append(" }"); TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SPARQL, positiveEvalQuery.toString()) .evaluate(); // Add all positive eval tests to the test suite while (queryResult.hasNext()) { BindingSet bindingSet = queryResult.next(); IRI nextTestUri = (IRI) bindingSet.getValue("test"); String nextTestName = ((Literal) bindingSet.getValue("testName")).getLabel(); String nextTestFile = removeBase(((IRI) bindingSet.getValue("inputURL")).toString(), manifestBaseUrl); String nextInputURL = fileBasePath + nextTestFile; String nextOutputURL = fileBasePath + removeBase(((IRI) bindingSet.getValue("outputURL")).toString(), manifestBaseUrl); String nextBaseUrl = testBaseUrl + nextTestFile; if (nextTestName.contains("CARRIAGE_RETURN")) { // FIXME: Sesame seems not to preserve the CARRIAGE_RETURN character // right now logger.warn("Ignoring TriG Positive Parser Eval Test: " + nextInputURL); continue; } else if (nextTestName.contains("UTF8_boundaries") || nextTestName.contains("PN_CHARS_BASE_character_boundaries")) { // FIXME: UTF8 support not implemented yet logger.warn("Ignoring TriG Positive Parser Eval Test: " + nextInputURL); continue; } suite.addTest(new PositiveParserTest(nextTestUri, nextTestName, nextInputURL, nextOutputURL, nextBaseUrl, createTriGParser(), createNQuadsParser())); } queryResult.close(); }
Example 19
Source File: TurtleParserTestCase.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void parsePositiveTurtleEvalTests(TestSuite suite, String fileBasePath, String testBaseUrl, String manifestBaseUrl, RepositoryConnection con) throws Exception { StringBuilder positiveEvalQuery = new StringBuilder(); positiveEvalQuery.append(" PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>\n"); positiveEvalQuery.append(" PREFIX qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>\n"); positiveEvalQuery.append(" PREFIX rdft: <http://www.w3.org/ns/rdftest#>\n"); positiveEvalQuery.append(" SELECT ?test ?testName ?inputURL ?outputURL \n"); positiveEvalQuery.append(" WHERE { \n"); positiveEvalQuery.append(" ?test a rdft:TestTurtleEval . "); positiveEvalQuery.append(" ?test mf:name ?testName . "); positiveEvalQuery.append(" ?test mf:action ?inputURL . "); positiveEvalQuery.append(" ?test mf:result ?outputURL . "); positiveEvalQuery.append(" }"); TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SPARQL, positiveEvalQuery.toString()) .evaluate(); // Add all positive eval tests to the test suite while (queryResult.hasNext()) { BindingSet bindingSet = queryResult.next(); IRI nextTestUri = (IRI) bindingSet.getValue("test"); String nextTestName = ((Literal) bindingSet.getValue("testName")).getLabel(); String nextTestFile = removeBase(((IRI) bindingSet.getValue("inputURL")).toString(), manifestBaseUrl); String nextInputURL = fileBasePath + nextTestFile; String nextOutputURL = fileBasePath + removeBase(((IRI) bindingSet.getValue("outputURL")).toString(), manifestBaseUrl); String nextBaseUrl = testBaseUrl + nextTestFile; // if (nextTestName.contains("CARRIAGE_RETURN")) { // // FIXME: Sesame seems not to preserve the CARRIAGE_RETURN character // // right now // System.err.println("Ignoring Turtle Positive Parser Eval Test: " + nextInputURL); // continue; // } suite.addTest(new PositiveParserTest(nextTestUri, nextTestName, nextInputURL, nextOutputURL, nextBaseUrl, createTurtleParser(), createNTriplesParser())); } queryResult.close(); }
Example 20
Source File: SPARQLUpdateTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 2 votes |
@Test public void testInsertWhereWithBlankNode() throws Exception { logger.debug("executing testInsertWhereWithBlankNode"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append(" INSERT { ?s ex:complexAge [ rdf:value ?age; rdfs:label \"old\" ] . } "); update.append(" WHERE { ?s ex:age ?age . "); update.append(" } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); IRI age = f.createIRI(EX_NS, "age"); IRI complexAge = f.createIRI(EX_NS, "complexAge"); assertTrue(con.hasStatement(bob, age, null, true)); operation.execute(); RepositoryResult<Statement> sts = con.getStatements(bob, complexAge, null, true); assertTrue(sts.hasNext()); Value v1 = sts.next().getObject(); sts.close(); sts = con.getStatements(null, RDF.VALUE, null, true); assertTrue(sts.hasNext()); Value v2 = sts.next().getSubject(); assertEquals(v1, v2); sts.close(); String query = getNamespaceDeclarations() + " SELECT ?bn ?age ?l WHERE { ex:bob ex:complexAge ?bn. ?bn rdf:value ?age. ?bn rdfs:label ?l .} "; TupleQueryResult result = con.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate(); assertTrue(result.hasNext()); BindingSet bs = result.next(); assertFalse(result.hasNext()); }