public void StorageSesameSparqlUpdate1() { try { Options.HttpDebugging = true; SesameHttpProtocolConnector sesame = SesameTests.GetConnection(); sesame.Update("DROP GRAPH <http://example.org/sparqlUpdateLoad>; LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/sparqlUpdateLoad>"); Graph orig = new Graph(); orig.LoadFromUri(new Uri("http://dbpedia.org/resource/Ilkeston")); Graph actual = new Graph(); sesame.LoadGraph(actual, "http://example.org/sparqlUpdateLoad"); GraphDiffReport diff = orig.Difference(actual); if (!diff.AreEqual) { TestTools.ShowDifferences(diff); } Assert.AreEqual(orig, actual, "Graphs should be equal"); } finally { Options.HttpDebugging = false; } }
public void StorageSesameSparqlUpdate4() { // Test case adapted from CORE-374 sample update SesameHttpProtocolConnector sesame = SesameTests.GetConnection(); // Insert the Data StringBuilder updates = new StringBuilder(); using (StreamReader reader = File.OpenText(@"..\\resources\core-374.ru")) { updates.Append(reader.ReadToEnd()); reader.Close(); } sesame.Update(updates.ToString()); String ask = "ASK WHERE { GRAPH <http://example.org/sesame/core-374> { ?s ?p 'République du Niger'@fr } }"; // Issue query to validate data was added Object results = sesame.Query(ask); Assert.IsAssignableFrom <SparqlResultSet>(results); if (results is SparqlResultSet) { TestTools.ShowResults(results); Assert.True(((SparqlResultSet)results).Result); } }
public void StorageSesameSparqlUpdate1() { Skip.IfNot(TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing), "Test Config marks Remote Parsing as unavailable, test cannot be run"); SesameHttpProtocolConnector sesame = SesameTests.GetConnection(); sesame.Update(@"DROP GRAPH <http://example.org/sparqlUpdateLoad>; LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/sparqlUpdateLoad>; DELETE WHERE { GRAPH <http://example.org/sparqlUpdateLoad> { ?s <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long ; <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat } }"); Graph orig = new Graph(); orig.LoadFromUri(new Uri("http://dbpedia.org/resource/Ilkeston")); orig.Retract(orig.GetTriplesWithPredicate(new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#long")).ToList()); orig.Retract(orig.GetTriplesWithPredicate(new Uri("http://www.w3.org/2003/01/geo/wgs84_pos#lat")).ToList()); Graph actual = new Graph(); sesame.LoadGraph(actual, "http://example.org/sparqlUpdateLoad"); GraphDiffReport diff = orig.Difference(actual); if (!diff.AreEqual) { TestTools.ShowDifferences(diff); } Assert.Equal(orig, actual); }
public void StorageSesameSparqlUpdate2() { SesameHttpProtocolConnector sesame = SesameTests.GetConnection(); Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/sparqlUpdateDeleteWhere"); sesame.SaveGraph(g); sesame.Update("WITH <http://example.org/sparqlUpdateDeleteWhere> DELETE { ?s a ?type } WHERE { ?s a ?type }"); Graph h = new Graph(); sesame.LoadGraph(h, "http://example.org/sparqlUpdateDeleteWhere"); INode rdfType = h.CreateUriNode("rdf:type"); Assert.False(h.GetTriplesWithPredicate(rdfType).Any(), "Should not be any rdf:type triples after SPARQL Update operation"); }
public void StorageSesameSparqlUpdate3() { SesameHttpProtocolConnector sesame = SesameTests.GetConnection(); // Ensure required graph is present Graph g = new Graph(); g.BaseUri = new Uri("http://example.org/sesame/chinese"); FileLoader.Load(g, @"resources\chinese.ttl"); sesame.SaveGraph(g); String ask = "ASK WHERE { GRAPH <http://example.org/sesame/chinese> { ?s ?p '例子' } }"; // Issue query to validate data was added Object results = sesame.Query(ask); if (results is SparqlResultSet) { TestTools.ShowResults(results); Assert.IsTrue(((SparqlResultSet)results).Result); } else { Assert.Fail("Failed to get a Result Set as expected"); } // Issue a DELETE for the Chinese literal String update = "DELETE WHERE { GRAPH <http://example.org/sesame/chinese> { ?s ?p '例子' } }"; sesame.Update(update); // Re-issue query to validate triple was deleted results = sesame.Query(ask); if (results is SparqlResultSet) { TestTools.ShowResults(results); Assert.IsFalse(((SparqlResultSet)results).Result); } else { Assert.Fail("Failed to get a Result Set as expected"); } }