Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rfe11202: SPARQL Update example with batch update
<release-note> rfe11202: SPARQL Update example with batch update With this change, Java tutorial example 13 has been augmented to show how to evaluate SPARQL Update queries, including one that batches updates in a single request. </release-note> Added SparqlUpdateTests to prepush tests make prepush passes ant tutorial runs Change-Id: I1e67e02231c676eb6bb03143c575b1895cb2775c added tutorial prose Change-Id: I78f197767899230d83c6179c5d60745d63d55b4a Reviewed-on: https://gerrit.franz.com:9080/1823 Reviewed-by: Ahmon Dancy <dancy@franz.com> Reviewed-by: John O'Rourke <jor@franz.com> Tested-by: Kevin Layer <layer@franz.com>
- Loading branch information
Showing
4 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/****************************************************************************** | ||
** Copyright (c) 2008-2011 Franz Inc. | ||
** All rights reserved. This program and the accompanying materials | ||
** are made available under the terms of the Eclipse Public License v1.0 | ||
** which accompanies this distribution, and is available at | ||
** http://www.eclipse.org/legal/epl-v10.html | ||
******************************************************************************/ | ||
|
||
package test; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.openrdf.model.Literal; | ||
import org.openrdf.model.URI; | ||
import org.openrdf.query.QueryLanguage; | ||
|
||
public class SparqlUpdateTests extends AGAbstractTest { | ||
|
||
@Test | ||
@Category(TestSuites.Prepush.class) | ||
public void batchSparqlUpdates() throws Exception { | ||
URI s = vf.createURI("http://example/book1"); | ||
URI p = vf.createURI("http://purl.org/dc/elements/1.1/title"); | ||
Literal o_wrong = vf.createLiteral("Fundamentals of Compiler Desing"); | ||
Literal o_right = vf.createLiteral("Fundamentals of Compiler Design"); | ||
URI g = vf.createURI("http://example/bookStore"); | ||
conn.add(s,p,o_wrong,g); | ||
|
||
// Perform a sequence of SPARQL UPDATE queries in one request to correct the title | ||
String queryString = "PREFIX dc: <http://purl.org/dc/elements/1.1/> \n" | ||
+ "DELETE DATA { GRAPH <http://example/bookStore> { <http://example/book1> dc:title \"Fundamentals of Compiler Desing\" } } ; \n" | ||
+ "\n" | ||
+ "PREFIX dc: <http://purl.org/dc/elements/1.1/> \n" | ||
+ "INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book1> dc:title \"Fundamentals of Compiler Design\" } }"; | ||
|
||
// SPARQL Update queries can be executed using a BooleanQuery (for side effect) | ||
conn.prepareBooleanQuery(QueryLanguage.SPARQL, queryString).evaluate(); | ||
Assert.assertTrue("Title should be correct", conn.hasStatement(s,p,o_right,false,g)); | ||
Assert.assertFalse("Incorrect title should be gone", conn.hasStatement(s,p,o_wrong,false,g)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters