public void StorageAllegroGraphDeleteTriples() { Graph g = new Graph(); FileLoader.Load(g, "resources\\InferenceTest.ttl"); g.BaseUri = new Uri("http://example.org/AllegroGraphTest"); AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); agraph.SaveGraph(g); Console.WriteLine("Graph before deletion"); TestTools.ShowGraph(g); //Delete all Triples about the Ford Fiesta agraph.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta"))); Graph h = new Graph(); agraph.LoadGraph(h, g.BaseUri); Console.WriteLine("Graph after deletion"); TestTools.ShowGraph(h); Assert.False(h.IsEmpty, "Graph should not be completely empty"); Assert.True(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph"); Assert.False(g.Equals(h), "Graph retrieved should not be equal to original Graph"); Object results = agraph.Query("ASK WHERE { GRAPH <http://example.org/AllegroGraphTest> { <http://example.org/vehicles/FordFiesta> ?p ?o } }"); if (results is SparqlResultSet) { Assert.False(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present"); } }
public void StorageAllegroGraphDeleteGraph2() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); Uri graphUri = null; agraph.DeleteGraph(graphUri); Graph g = new Graph(); FileLoader.Load(g, "resources\\InferenceTest.ttl"); g.BaseUri = graphUri; agraph.SaveGraph(g); Graph h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.False(h.IsEmpty, "Graph should not be empty after loading"); Assert.Equal(g, h); agraph.DeleteGraph(graphUri); h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.True(h.IsEmpty, "Graph should be equal after deletion"); Assert.NotEqual(g, h); }
public void StorageAllegroGraphDeleteGraph1() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); Uri graphUri = new Uri("http://example.org/AllegroGraph/delete"); Graph g = new Graph(); FileLoader.Load(g, "resources\\InferenceTest.ttl"); g.BaseUri = graphUri; agraph.SaveGraph(g); Graph h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.IsFalse(h.IsEmpty, "Graph should not be empty after loading"); Assert.AreEqual(g, h, "Graphs should have been equal"); agraph.DeleteGraph(graphUri); h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.IsTrue(h.IsEmpty, "Graph should be equal after deletion"); Assert.AreNotEqual(g, h, "Graphs should not be equal after deletion"); }
public void StorageAllegroGraphSparqlUpdate() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); String updates = "INSERT DATA { GRAPH <http://example.org/new-graph> { <http://subject> <http://predicate> <http://object> } }"; agraph.Update(updates); SparqlResultSet results = agraph.Query("SELECT * WHERE { GRAPH <http://example.org/new-graph> { ?s ?p ?o } }") as SparqlResultSet; Assert.NotNull(results); Assert.Equal(1, results.Count); }
public void StorageAllegroGraphDescribe() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); String describe = "DESCRIBE <http://example.org/Vehicles/FordFiesta>"; Object results = agraph.Query(describe); Assert.IsAssignableFrom <IGraph>(results); if (results is IGraph) { TestTools.ShowGraph((IGraph)results); } }
public void StorageAllegroGraphAsk() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); String ask = "ASK WHERE { ?s ?p ?o }"; Object results = agraph.Query(ask); Assert.IsAssignableFrom <SparqlResultSet>(results); if (results is SparqlResultSet) { TestTools.ShowResults(results); } }
public void StorageAllegroGraphSaveEmptyGraph1() { Graph g = new Graph(); g.BaseUri = new Uri("http://example.org/AllegroGraph/empty"); AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); agraph.SaveGraph(g); Graph h = new Graph(); agraph.LoadGraph(h, "http://example.org/AllegroGraph/empty"); Assert.True(h.IsEmpty, "Graph should be empty after loading"); Assert.Equal(g, h); }
public void StorageAllegroGraphDescribe() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); String describe = "DESCRIBE <http://example.org/Vehicles/FordFiesta>"; Object results = agraph.Query(describe); if (results is IGraph) { TestTools.ShowGraph((IGraph)results); } else { Assert.Fail("Failed to get a Graph as expected"); } }
public void StorageAllegroGraphAsk() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); String ask = "ASK WHERE { ?s ?p ?o }"; Object results = agraph.Query(ask); if (results is SparqlResultSet) { TestTools.ShowResults(results); } else { Assert.Fail("Failed to get a Result Set as expected"); } }
public void StorageAllegroGraphSaveLoad() { Graph g = new Graph(); FileLoader.Load(g, "resources\\InferenceTest.ttl"); g.BaseUri = new Uri("http://example.org/AllegroGraphTest"); AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); agraph.SaveGraph(g); Graph h = new Graph(); agraph.LoadGraph(h, "http://example.org/AllegroGraphTest"); Assert.False(h.IsEmpty, "Graph should not be empty after loading"); Assert.Equal(g, h); }
public void StorageAllegroGraphSaveEmptyGraph3() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); Uri graphUri = null; Console.WriteLine("Deleting any existing graph"); agraph.DeleteGraph(graphUri); Console.WriteLine("Existing graph deleted"); // First create a non-empty graph Graph g = new Graph(); g.BaseUri = graphUri; g.Assert(g.CreateBlankNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode(new Uri("http://example.org/BNode"))); Console.WriteLine("Saving non-empty graph"); agraph.SaveGraph(g); Console.WriteLine("Non-empty graph saved"); Graph h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.False(h.IsEmpty, "Graph should not be empty after loading"); Assert.Equal(g, h); // Now attempt to overwrite with an empty graph g = new Graph(); g.BaseUri = graphUri; Console.WriteLine("Attempting to save empty graph with same name"); agraph.SaveGraph(g); Console.WriteLine("Empty graph saved"); h = new Graph(); agraph.LoadGraph(h, graphUri); // Since saving to default graph does not overwrite the graph we've just retrieved must contain the empty graph as a sub-graph Assert.True(h.HasSubGraph(g)); }
public void StorageAllegroGraphSaveEmptyGraph2() { AllegroGraphConnector agraph = AllegroGraphTests.GetConnection(); Uri graphUri = new Uri("http://example.org/AllegroGraph/empty2"); Console.WriteLine("Deleting any existing graph"); agraph.DeleteGraph(graphUri); Console.WriteLine("Existing graph deleted"); // First create a non-empty graph Graph g = new Graph(); g.BaseUri = graphUri; g.Assert(g.CreateBlankNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode(new Uri("http://example.org/BNode"))); Console.WriteLine("Saving non-empty graph"); agraph.SaveGraph(g); Console.WriteLine("Non-empty graph saved"); Graph h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.False(h.IsEmpty, "Graph should not be empty after loading"); Assert.Equal(g, h); // Now attempt to save an empty graph as well g = new Graph(); g.BaseUri = graphUri; Console.WriteLine("Attempting to save empty graph with same name"); agraph.SaveGraph(g); Console.WriteLine("Empty graph saved"); h = new Graph(); agraph.LoadGraph(h, graphUri); Assert.True(h.IsEmpty, "Graph should be empty after loading"); Assert.Equal(g, h); }