public void StorageStardogSparqlUpdate1() { StardogConnector stardog = StardogTests.GetConnection(); IGraph g; g = new Graph(); stardog.LoadGraph(g, "http://example.org/stardog/update/1"); if (!g.IsEmpty) { Console.WriteLine("Dropping graph"); stardog.Update("DROP SILENT GRAPH <http://example.org/stardog/update/1>"); Console.WriteLine("Dropped graph"); Thread.Sleep(2500); g = new Graph(); stardog.LoadGraph(g, "http://example.org/stardog/update/1"); Assert.True(g.IsEmpty, "Graph should be empty after DROP command"); } Console.WriteLine("Inserting data"); stardog.Update( "INSERT DATA { GRAPH <http://example.org/stardog/update/1> { <http://x> <http://y> <http://z> } }"); Console.WriteLine("Inserted data"); g = new Graph(); stardog.LoadGraph(g, "http://example.org/stardog/update/1"); Assert.False(g.IsEmpty, "Graph should not be empty"); Assert.Equal(1, g.Triples.Count); }
public void StorageStardogSparqlUpdate3() { StardogConnector stardog = StardogTests.GetConnection(); IGraph g; Console.WriteLine("Dropping graph"); stardog.Update("DROP SILENT GRAPH <http://example.org/stardog/update/3>"); Console.WriteLine("Dropped graph"); Thread.Sleep(2500); g = new Graph(); stardog.LoadGraph(g, "http://example.org/stardog/update/3"); Assert.True(g.IsEmpty, "Graph should be empty after DROP command"); Console.WriteLine("Inserting data"); IGraph newData = new Graph(); newData.BaseUri = new Uri("http://example.org/stardog/update/3"); newData.Assert(newData.CreateUriNode(new Uri("http://x")), newData.CreateUriNode(new Uri("http://y")), newData.CreateUriNode(new Uri("http://z"))); stardog.SaveGraph(newData); Console.WriteLine("Inserted data"); g = new Graph(); stardog.LoadGraph(g, "http://example.org/stardog/update/3"); Assert.False(g.IsEmpty, "Graph should not be empty"); Assert.Equal(1, g.Triples.Count); }
public void StorageStardogDeleteNamedGraph() { try { //Options.UseBomForUtf8 = false; StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/tempGraph"); stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, new Uri("http://example.org/tempGraph")); if (g.Triples.Count == h.Triples.Count) { Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph"); } else { Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph"); } stardog.DeleteGraph("http://example.org/tempGraph"); Graph i = new Graph(); stardog.LoadGraph(i, new Uri("http://example.org/tempGraph")); Assert.IsTrue(i.IsEmpty, "Retrieved Graph should be empty since it has been deleted"); } finally { //Options.UseBomForUtf8 = true; } }
public void StorageStardogSaveToNamedGraphOverwrite() { StardogConnector stardog = StardogTests.GetConnection(); Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/namedGraph"); stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, new Uri("http://example.org/namedGraph")); Assert.Equal(g, h); Graph i = new Graph(); i.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl"); i.BaseUri = new Uri("http://example.org/namedGraph"); stardog.SaveGraph(i); Graph j = new Graph(); stardog.LoadGraph(j, "http://example.org/namedGraph"); Assert.NotEqual(g, j); Assert.Equal(i, j); }
public void StorageStardogSaveToNamedGraphOverwrite() { try { //Options.UseBomForUtf8 = false; Options.HttpDebugging = true; StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/namedGraph"); stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, new Uri("http://example.org/namedGraph")); Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph"); Graph i = new Graph(); i.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl"); i.BaseUri = new Uri("http://example.org/namedGraph"); stardog.SaveGraph(i); Graph j = new Graph(); stardog.LoadGraph(j, "http://example.org/namedGraph"); Assert.AreNotEqual(g, j, "Retrieved Graph should not be equal to overwritten Graph"); Assert.AreEqual(i, j, "Retrieved Graph should be equal to Saved Graph"); } finally { Options.HttpDebugging = false; //Options.UseBomForUtf8 = true; } }
public void StorageStardogLoadNamedGraph() { StardogConnector stardog = StardogTests.GetConnection(); // Ensure graph exists Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/graph"); stardog.SaveGraph(g); // Load it back from the store Graph h = new Graph(); stardog.LoadGraph(h, new Uri("http://example.org/graph")); NTriplesFormatter formatter = new NTriplesFormatter(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(formatter)); } Assert.False(h.IsEmpty); Assert.Equal(g, h); }
public void StorageStardogUpdateNamedGraphRemoveTriples() { try { //Options.UseBomForUtf8 = false; StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/graph"); stardog.SaveGraph(g); INode rdfType = g.CreateUriNode(new Uri(VDS.RDF.Parsing.RdfSpecsHelper.RdfType)); stardog.UpdateGraph(g.BaseUri, null, g.GetTriplesWithPredicate(rdfType)); g.Retract(g.GetTriplesWithPredicate(rdfType).ToList()); Graph h = new Graph(); stardog.LoadGraph(h, new Uri("http://example.org/graph")); if (g.Triples.Count == h.Triples.Count) { Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph"); } else { Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph"); } Assert.IsFalse(h.GetTriplesWithPredicate(rdfType).Any(), "Retrieved Graph should not contain any rdf:type Triples"); } finally { //Options.UseBomForUtf8 = true; } }
public void StorageStardogSaveToDefaultGraph() { try { //Options.UseBomForUtf8 = false; StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = null; stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, (Uri)null); Console.WriteLine("Retrieved " + h.Triples.Count + " Triple(s) from Stardog"); if (g.Triples.Count == h.Triples.Count) { Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph"); } else { Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph"); } } finally { //Options.UseBomForUtf8 = true; } }
public void StorageStardogAmpersandsInDataTest() { try { Options.HttpDebugging = true; StardogConnector stardog = StardogTests.GetConnection();; //Save the Graph Graph g = new Graph(); String fragment = "@prefix : <http://example.org/> . [] :string \"This has & ampersands in it\" ."; g.LoadFromString(fragment); g.BaseUri = new Uri("http://example.org/ampersandGraph"); Console.WriteLine("Original Graph:"); TestTools.ShowGraph(g); stardog.SaveGraph(g); //Retrieve and check it round trips Graph h = new Graph(); stardog.LoadGraph(h, g.BaseUri); Console.WriteLine("Graph as retrieved from Stardog:"); TestTools.ShowGraph(h); Assert.AreEqual(g, h, "Graphs should be equal"); //Now try to delete the data from this Graph GenericUpdateProcessor processor = new GenericUpdateProcessor(stardog); SparqlUpdateParser parser = new SparqlUpdateParser(); processor.ProcessCommandSet(parser.ParseFromString("WITH <http://example.org/ampersandGraph> DELETE WHERE { ?s ?p ?o }")); Graph i = new Graph(); stardog.LoadGraph(i, g.BaseUri); Console.WriteLine("Graph as retrieved after the DELETE WHERE:"); TestTools.ShowGraph(i); Assert.AreNotEqual(g, i, "Graphs should not be equal"); Assert.AreNotEqual(h, i, "Graphs should not be equal"); } finally { Options.HttpDebugging = false; } }
public void StorageStardogLoadNamedGraph() { StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); stardog.LoadGraph(g, new Uri("http://example.org/graph")); NTriplesFormatter formatter = new NTriplesFormatter(); foreach (Triple t in g.Triples) { Console.WriteLine(t.ToString(formatter)); } Assert.IsFalse(g.IsEmpty); }
public void StorageStardogLoadDefaultGraph() { StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); stardog.LoadGraph(g, (Uri)null); NTriplesFormatter formatter = new NTriplesFormatter(); foreach (Triple t in g.Triples) { Console.WriteLine(t.ToString(formatter)); } Assert.IsFalse(g.IsEmpty); }
public void StorageStardogLoadDefaultGraph() { StardogConnector stardog = StardogTests.GetConnection(); Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = null; stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, (Uri)null); NTriplesFormatter formatter = new NTriplesFormatter(); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString(formatter)); } Assert.False(h.IsEmpty); }
public void StorageStardogSparqlUpdate5() { StardogConnector stardog = StardogTests.GetConnection(); IGraph g; // Begin a transaction stardog.Begin(); // Try to make an update stardog.Update( "DROP SILENT GRAPH <http://example.org/stardog/update/5>; INSERT DATA { GRAPH <http://example.org/stardog/update/5> { <http://x> <http://y> <http://z> } }"); // Rollback the transaction stardog.Rollback(); g = new Graph(); stardog.LoadGraph(g, "http://example.org/stardog/update/5"); Assert.False(g.IsEmpty, "Graph should not be empty after update"); Assert.Equal(1, g.Triples.Count); stardog.Dispose(); }
public void StorageStardogSaveToNamedGraph() { try { //Options.UseBomForUtf8 = false; StardogConnector stardog = StardogTests.GetConnection();; Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/graph"); stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, new Uri("http://example.org/graph")); Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph"); } finally { //Options.UseBomForUtf8 = true; } }
public void StorageStardogSaveToNamedGraph2() { try { //Options.UseBomForUtf8 = false; StardogConnector stardog = StardogTests.GetConnection(); Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); Uri u = new Uri("http://example.org/graph/" + DateTime.Now.Ticks); g.BaseUri = u; stardog.SaveGraph(g); Graph h = new Graph(); stardog.LoadGraph(h, u); Assert.Equal(g, h); } finally { //Options.UseBomForUtf8 = true; } }