public void StorageReadWriteSparqlUpdate() { try { Options.HttpDebugging = true; ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); //Try doing a SPARQL Update LOAD command String command = "LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/Ilson>"; readWrite.Update(command); //Then see if we can retrieve the newly loaded graph IGraph g = new Graph(); readWrite.LoadGraph(g, "http://example.org/Ilson"); Assert.IsFalse(g.IsEmpty, "Graph should be non-empty"); foreach (Triple t in g.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Console.WriteLine(); //Try a DROP Graph to see if that works command = "DROP GRAPH <http://example.org/Ilson>"; readWrite.Update(command); g = new Graph(); readWrite.LoadGraph(g, "http://example.org/Ilson"); Assert.IsTrue(g.IsEmpty, "Graph should be empty as it should have been DROPped by ReadWriteSparql"); } finally { Options.HttpDebugging = false; } }
public void StorageReadWriteSparqlSaveDefaultGraph() { try { SetUriLoaderCaching(false); Graph g = new Graph(); g.LoadFromFile("resources\\InferenceTest.ttl"); g.BaseUri = null; //Save Graph to ReadWriteSparql ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.SaveGraph(g); Console.WriteLine("Graph saved to ReadWriteSparql OK"); //Now retrieve Graph from ReadWriteSparql Graph h = new Graph(); readWrite.LoadGraph(h, (Uri)null); Console.WriteLine(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Assert.Equal(g, h); Assert.Null(h.BaseUri); } finally { SetUriLoaderCaching(true); } }
public void StorageReadWriteSparqlDeleteDefaultGraph2() { try { SetUriLoaderCaching(false); StorageReadWriteSparqlSaveDefaultGraph(); ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.DeleteGraph((String)null); Graph g = new Graph(); try { readWrite.LoadGraph(g, (Uri)null); } catch (Exception ex) { Console.WriteLine("Errored as expected since the Graph was deleted"); TestTools.ReportError("Error", ex); } Console.WriteLine(); //If we do get here without erroring then the Graph should be empty Assert.True(g.IsEmpty, "Graph should be empty even if an error wasn't thrown as the data should have been deleted from the Store"); } finally { SetUriLoaderCaching(true); } }
public void StorageReadWriteSparqlLoadGraph() { try { SetUriLoaderCaching(false); //Ensure that the Graph will be there using the SaveGraph() test StorageReadWriteSparqlSaveGraph(); Graph g = new Graph(); g.LoadFromFile("resources\\InferenceTest.ttl"); g.BaseUri = new Uri("http://example.org/readWriteTest"); //Try to load the relevant Graph back from the Store ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); Graph h = new Graph(); readWrite.LoadGraph(h, "http://example.org/readWriteTest"); Console.WriteLine(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Assert.Equal(g, h); } finally { SetUriLoaderCaching(true); } }
public void StorageReadWriteSparqlSaveDefaultGraph() { try { Options.UriLoaderCaching = false; Graph g = new Graph(); FileLoader.Load(g, "InferenceTest.ttl"); g.BaseUri = null; //Save Graph to ReadWriteSparql ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.SaveGraph(g); Console.WriteLine("Graph saved to ReadWriteSparql OK"); //Now retrieve Graph from ReadWriteSparql Graph h = new Graph(); readWrite.LoadGraph(h, (Uri)null); Console.WriteLine(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Assert.AreEqual(g, h, "Graphs should be equal"); Assert.IsNull(h.BaseUri, "Retrieved Graph should have a null Base URI"); } finally { Options.UriLoaderCaching = true; } }
public void StorageReadWriteSparqlDeleteGraph() { try { Options.UriLoaderCaching = false; StorageReadWriteSparqlSaveGraph(); ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.DeleteGraph("http://example.org/readWriteTest"); Graph g = new Graph(); try { readWrite.LoadGraph(g, "http://example.org/readWriteTest"); } catch (Exception ex) { Console.WriteLine("Errored as expected since the Graph was deleted"); TestTools.ReportError("Error", ex); } Console.WriteLine(); //If we do get here without erroring then the Graph should be empty Assert.IsTrue(g.IsEmpty, "Graph should be empty even if an error wasn't thrown as the data should have been deleted from the Store"); } finally { Options.UriLoaderCaching = true; } }
public void StorageReadWriteSparqlLoadGraph() { try { Options.UriLoaderCaching = false; //Ensure that the Graph will be there using the SaveGraph() test StorageReadWriteSparqlSaveGraph(); Graph g = new Graph(); FileLoader.Load(g, "InferenceTest.ttl"); g.BaseUri = new Uri("http://example.org/readWriteTest"); //Try to load the relevant Graph back from the Store ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); Graph h = new Graph(); readWrite.LoadGraph(h, "http://example.org/readWriteTest"); Console.WriteLine(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Assert.AreEqual(g, h, "Graphs should be equal"); } finally { Options.UriLoaderCaching = true; } }
public void StorageReadWriteSparqlSaveGraph() { try { SetUriLoaderCaching(false); Graph g = new Graph(); g.LoadFromFile("resources\\InferenceTest.ttl"); g.BaseUri = new Uri("http://example.org/readWriteTest"); //Save Graph to ReadWriteSparql ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.SaveGraph(g); Console.WriteLine("Graph saved to ReadWriteSparql OK"); //Now retrieve Graph from ReadWriteSparql Graph h = new Graph(); readWrite.LoadGraph(h, "http://example.org/readWriteTest"); Console.WriteLine(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Assert.AreEqual(g, h, "Graphs should be equal"); } finally { SetUriLoaderCaching(true); } }
public void StorageReadWriteSparqlUpdate() { if (!TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing)) { throw new SkipTestException("Test Config marks Remote Parsing as unavailable, test cannot be run"); } try { Options.HttpDebugging = true; ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); //Try doing a SPARQL Update LOAD command String command = "LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/Ilson>"; readWrite.Update(command); //Then see if we can retrieve the newly loaded graph IGraph g = new Graph(); readWrite.LoadGraph(g, "http://example.org/Ilson"); Assert.False(g.IsEmpty, "Graph should be non-empty"); foreach (Triple t in g.Triples) { Console.WriteLine(t.ToString(this._formatter)); } Console.WriteLine(); //Try a DROP Graph to see if that works command = "DROP GRAPH <http://example.org/Ilson>"; readWrite.Update(command); g = new Graph(); readWrite.LoadGraph(g, "http://example.org/Ilson"); Assert.True(g.IsEmpty, "Graph should be empty as it should have been DROPped by ReadWriteSparql"); } finally { Options.HttpDebugging = false; } }
public void StorageReadWriteSparqlRemoveTriples() { try { SetUriLoaderCaching(false); StorageReadWriteSparqlSaveGraph(); Graph g = new Graph(); List <Triple> ts = new List <Triple>(); ts.Add(new Triple(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object")))); ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.UpdateGraph("http://example.org/readWriteTest", null, ts); readWrite.LoadGraph(g, "http://example.org/readWriteTest"); Assert.True(ts.All(t => !g.ContainsTriple(t)), "Removed Triple should not have been in the Graph"); } finally { SetUriLoaderCaching(true); } }
public void StorageReadWriteSparqlAddTriples() { try { Options.UriLoaderCaching = false; StorageReadWriteSparqlSaveGraph(); Graph g = new Graph(); List <Triple> ts = new List <Triple>(); ts.Add(new Triple(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object")))); ReadWriteSparqlConnector readWrite = ReadWriteSparqlTests.GetConnection(); readWrite.UpdateGraph("http://example.org/readWriteTest", ts, null); readWrite.LoadGraph(g, "http://example.org/readWriteTest"); Assert.IsTrue(ts.All(t => g.ContainsTriple(t)), "Added Triple should have been in the Graph"); } finally { Options.UriLoaderCaching = true; } }