Exemplo n.º 1
0
        public void StorageDydraRemoveTriples()
        {
            try
            {
                Options.HttpDebugging = true;

                DydraConnector dydra = DydraTests.GetConnection();

                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                g.BaseUri = new Uri("http://example.org/storage/dydra/update/remove");
                dydra.SaveGraph(g);

                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"))));

                dydra.UpdateGraph(g.BaseUri, null, ts);

                g = new Graph();
                dydra.LoadGraph(g, "http://example.org/storage/dydra/update/remove");

                Assert.IsTrue(ts.All(t => !g.ContainsTriple(t)), "Removed Triple should be in the Graph");
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
Exemplo n.º 2
0
        public void StorageDydraSaveToDefaultGraph()
        {
            try
            {
                Options.HttpDebugging = true;

                Graph orig = new Graph();
                orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                orig.BaseUri = null;

                DydraConnector dydra = DydraTests.GetConnection();
                dydra.SaveGraph(orig);

                Graph g = new Graph();
                dydra.LoadGraph(g, (Uri)null);

                if (orig.Triples.Count == g.Triples.Count)
                {
                    Assert.AreEqual(orig, g, "Graphs should be equal");
                }
                else
                {
                    Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph");
                }
            }
            finally
            {
                Options.HttpFullDebugging = false;
                Options.HttpDebugging     = false;
            }
        }
Exemplo n.º 3
0
        public void StorageDydraConstructQuery()
        {
            try
            {
                Options.HttpDebugging = true;
                //Options.HttpFullDebugging = true;

                DydraConnector dydra   = DydraTests.GetConnection();
                Object         results = dydra.Query("CONSTRUCT { ?s a ?type } WHERE { { ?s a ?type } UNION { GRAPH ?g { ?s a ?type } } }");
                if (results is IGraph)
                {
                    IGraph g = (IGraph)results;
                    TestTools.ShowResults(g);
                }
                else
                {
                    Assert.Fail("Did not get a Graph as expected");
                }
            }
            finally
            {
                Options.HttpFullDebugging = false;
                Options.HttpDebugging     = false;
            }
        }
Exemplo n.º 4
0
        public void StorageDydraListGraphs()
        {
            DydraConnector dydra     = DydraTests.GetConnection();
            List <Uri>     graphUris = dydra.ListGraphs().ToList();

            Console.WriteLine("Dydra returned " + graphUris.Count + " Graph URIs");
            foreach (Uri u in graphUris)
            {
                Console.WriteLine(u.ToString());
            }
        }
Exemplo n.º 5
0
        public void StorageDydraDeleteGraph()
        {
            try
            {
                Options.HttpDebugging = true;

                Graph orig = new Graph();
                orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                orig.BaseUri = new Uri("http://example.org/storage/dydra/delete");

                DydraConnector dydra = DydraTests.GetConnection();
                dydra.SaveGraph(orig);

                Graph g = new Graph();
                dydra.LoadGraph(g, orig.BaseUri);

                if (orig.Triples.Count == g.Triples.Count)
                {
                    GraphDiffReport report = orig.Difference(g);
                    if (!report.AreEqual)
                    {
                        TestTools.ShowDifferences(report);
                    }
                    Assert.AreEqual(orig, g, "Graphs should be equal");
                }
                else
                {
                    Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph");
                }

                //Now delete the Graph
                dydra.DeleteGraph(orig.BaseUri);

                //And retrieve it again
                g = new Graph();
                dydra.LoadGraph(g, orig.BaseUri);

                Assert.IsTrue(g.IsEmpty, "Graph should be empty as was deleted from repository");
                Assert.AreNotEqual(orig, g, "Graphs should not be equal");
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
Exemplo n.º 6
0
        public void StorageDydraSaveToNamedGraph()
        {
            try
            {
                Options.HttpDebugging = true;

                Graph orig = new Graph();
                orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                orig.BaseUri = new Uri("http://example.org/storage/dydra/save/named/");

                DydraConnector dydra = DydraTests.GetConnection();
                dydra.SaveGraph(orig);

                Graph g = new Graph();
                dydra.LoadGraph(g, orig.BaseUri);

                if (orig.Triples.Count == g.Triples.Count)
                {
                    GraphDiffReport report = orig.Difference(g);
                    if (!report.AreEqual)
                    {
                        TestTools.ShowDifferences(report);
                    }
                    Assert.AreEqual(orig, g, "Graphs should be equal");
                }
                else
                {
                    Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph");
                }
            }
            finally
            {
                Options.HttpFullDebugging = false;
                Options.HttpDebugging     = false;
            }
        }
Exemplo n.º 7
0
        public void StorageDydraQuery()
        {
            try
            {
                Options.HttpDebugging = true;

                DydraConnector dydra   = DydraTests.GetConnection();
                Object         results = dydra.Query("SELECT * WHERE { { ?s a ?type } UNION { GRAPH ?g { ?s a ?type } } }");
                if (results is SparqlResultSet)
                {
                    SparqlResultSet rset = (SparqlResultSet)results;
                    TestTools.ShowResults(rset);
                }
                else
                {
                    Assert.Fail("Did not get a SPARQL Result Set as expected");
                }
            }
            finally
            {
                Options.HttpFullDebugging = false;
                Options.HttpDebugging     = false;
            }
        }
Exemplo n.º 8
0
        public void StorageDydraLoadGraphWithHandler()
        {
            try
            {
                Options.HttpDebugging = true;

                Graph orig = new Graph();
                orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                orig.BaseUri = new Uri("http://example.org/storage/dydra/tests/counting");

                DydraConnector dydra = DydraTests.GetConnection();
                dydra.DeleteGraph(orig.BaseUri);
                dydra.SaveGraph(orig);

                CountHandler handler = new CountHandler();
                dydra.LoadGraph(handler, orig.BaseUri);

                Assert.AreEqual(orig.Triples.Count, handler.Count, "Triple Counts should be equal");
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }