예제 #1
0
        public void StorageFusekiSaveDefaultGraph2()
        {
            try
            {
                Options.UriLoaderCaching = false;
                Graph g = new Graph();
                FileLoader.Load(g, "resources\\InferenceTest.ttl");
                g.BaseUri = null;

                //Save Graph to Fuseki
                FusekiConnector fuseki = FusekiTest.GetConnection();
                fuseki.SaveGraph(g);
                Console.WriteLine("Graph saved to Fuseki OK");

                //Now retrieve Graph from Fuseki
                Graph h = new Graph();
                fuseki.LoadGraph(h, (String)null);

                Console.WriteLine();
                foreach (Triple t in h.Triples)
                {
                    Console.WriteLine(t.ToString(this._formatter));
                }

                Assert.Equal(g, h);
                Assert.Null(h.BaseUri);
            }
            finally
            {
                Options.UriLoaderCaching = true;
            }
        }
예제 #2
0
        public void StorageFusekiLoadGraph()
        {
            try
            {
                Options.UriLoaderCaching = false;
                //Ensure that the Graph will be there using the SaveGraph() test
                StorageFusekiSaveGraph();

                Graph g = new Graph();
                FileLoader.Load(g, "resources\\InferenceTest.ttl");
                g.BaseUri = new Uri("http://example.org/fusekiTest");

                //Try to load the relevant Graph back from the Store
                FusekiConnector fuseki = FusekiTest.GetConnection();

                Graph h = new Graph();
                fuseki.LoadGraph(h, "http://example.org/fusekiTest");

                Console.WriteLine();
                foreach (Triple t in h.Triples)
                {
                    Console.WriteLine(t.ToString(this._formatter));
                }

                Assert.Equal(g, h);
            }
            finally
            {
                Options.UriLoaderCaching = true;
            }
        }
예제 #3
0
        public void StorageFusekiSaveGraph()
        {
            try
            {
                Options.UriLoaderCaching = false;

                Graph g = new Graph();
                FileLoader.Load(g, "InferenceTest.ttl");
                g.BaseUri = new Uri("http://example.org/fusekiTest");

                //Save Graph to Fuseki
                FusekiConnector fuseki = FusekiTest.GetConnection();
                fuseki.SaveGraph(g);
                Console.WriteLine("Graph saved to Fuseki OK");

                //Now retrieve Graph from Fuseki
                Graph h = new Graph();
                fuseki.LoadGraph(h, "http://example.org/fusekiTest");

                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 StoragePersistentTripleStoreFusekiQueryAsk()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestQueryAsk(fuseki, "ASK WHERE { GRAPH ?g { ?s a ?type } }", true);
            this.TestQueryAsk(fuseki, "ASK WHERE { GRAPH ?g { ?s <http://example.org/noSuchThing> ?o } }", false);
        }
예제 #5
0
        public void StorageFusekiUpdate()
        {
            try
            {
                Options.HttpDebugging = true;

                FusekiConnector fuseki = FusekiTest.GetConnection();

                //Try doing a SPARQL Update LOAD command
                String command = "LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/Ilson>";
                fuseki.Update(command);

                //Then see if we can retrieve the newly loaded graph
                IGraph g = new Graph();
                fuseki.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>";
                fuseki.Update(command);

                g = new Graph();
                fuseki.LoadGraph(g, "http://example.org/Ilson");
                Assert.IsTrue(g.IsEmpty, "Graph should be empty as it should have been DROPped by Fuseki");
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
예제 #6
0
        public void StorageFusekiRemoveTriples()
        {
            try
            {
#if !NO_URICACHE
                Options.UriLoaderCaching = false;
#endif
                StorageFusekiSaveGraph();

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

                FusekiConnector fuseki = FusekiTest.GetConnection();
                fuseki.UpdateGraph("http://example.org/fusekiTest", null, ts);

                fuseki.LoadGraph(g, "http://example.org/fusekiTest");
                Assert.IsTrue(ts.All(t => !g.ContainsTriple(t)), "Removed Triple should not have been in the Graph");
            }
            finally
            {
#if !NO_URICACHE
                Options.UriLoaderCaching = true;
#endif
            }
        }
예제 #7
0
        public void StorageFusekiDeleteDefaultGraph()
        {
            try
            {
                Options.UriLoaderCaching = false;
                StorageFusekiSaveDefaultGraph();

                FusekiConnector fuseki = FusekiTest.GetConnection();
                fuseki.DeleteGraph((Uri)null);

                Graph g = new Graph();
                try
                {
                    fuseki.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
            {
                Options.UriLoaderCaching = true;
            }
        }
예제 #8
0
        public void StorageFusekiSaveGraph(string mimeType = null)
        {
            try
            {
                Options.UriLoaderCaching = false;
                Graph g = new Graph();
                FileLoader.Load(g, "resources\\InferenceTest.ttl");
                g.BaseUri = new Uri("http://example.org/fusekiTest");

                //Save Graph to Fuseki
                FusekiConnector fuseki = FusekiTest.GetConnection(mimeType);
                fuseki.SaveGraph(g);
                _testOutputHelper.WriteLine("Graph saved to Fuseki OK");

                //Now retrieve Graph from Fuseki
                Graph h = new Graph();
                fuseki.LoadGraph(h, "http://example.org/fusekiTest");

                _testOutputHelper.WriteLine("");
                foreach (Triple t in h.Triples)
                {
                    _testOutputHelper.WriteLine(t.ToString(this._formatter));
                }

                Assert.Equal(g, h);
            }
            finally
            {
                Options.UriLoaderCaching = true;
            }
        }
예제 #9
0
        public void StorageFusekiQuery()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            Object results = fuseki.Query("SELECT * WHERE { {?s ?p ?o} UNION { GRAPH ?g {?s ?p ?o} } }");

            if (results is SparqlResultSet)
            {
                TestTools.ShowResults(results);
            }
            else
            {
                Assert.True(false, "Did not get a SPARQL Result Set as expected");
            }
        }
예제 #10
0
        public void StorageFusekiUpdate()
        {
            if (!TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing))
            {
                throw new SkipTestException("Test Config marks Remote Parsing as unavailable, test cannot be run");
            }

            try
            {
                Options.HttpDebugging = true;

                FusekiConnector fuseki = FusekiTest.GetConnection();

                //Try doing a SPARQL Update LOAD command
                String command = "LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/Ilson>";
                fuseki.Update(command);

                //Then see if we can retrieve the newly loaded graph
                IGraph g = new Graph();
                fuseki.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>";
                fuseki.Update(command);

                g = new Graph();
                fuseki.LoadGraph(g, "http://example.org/Ilson");
                Assert.True(g.IsEmpty, "Graph should be empty as it should have been DROPped by Fuseki");
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
예제 #11
0
        public void StorageFusekiAddTriples()
        {
            try
            {
                Options.UriLoaderCaching = false;
                StorageFusekiSaveGraph();

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

                FusekiConnector fuseki = FusekiTest.GetConnection();
                fuseki.UpdateGraph("http://example.org/fusekiTest", ts, null);

                fuseki.LoadGraph(g, "http://example.org/fusekiTest");
                Assert.True(ts.All(t => g.ContainsTriple(t)), "Added Triple should have been in the Graph");
            }
            finally
            {
                Options.UriLoaderCaching = true;
            }
        }
예제 #12
0
        public void StorageFusekiDescribe()
        {
            try
            {
                Options.HttpDebugging = true;

                FusekiConnector fuseki = FusekiTest.GetConnection();

                Object results = fuseki.Query("DESCRIBE <http://example.org/vehicles/FordFiesta>");
                if (results is IGraph)
                {
                    TestTools.ShowGraph((IGraph)results);
                }
                else
                {
                    Assert.True(false, "Did not return a Graph as expected");
                }
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
예제 #13
0
        public void StorageFusekiSaveDefaultGraph()
        {
            try
            {
#if !NO_URICACHE
                Options.UriLoaderCaching = false;
#endif

                Graph g = new Graph();
                FileLoader.Load(g, "resources\\InferenceTest.ttl");
                g.BaseUri = null;

                //Save Graph to Fuseki
                FusekiConnector fuseki = FusekiTest.GetConnection();
                fuseki.SaveGraph(g);
                Console.WriteLine("Graph saved to Fuseki OK");

                //Now retrieve Graph from Fuseki
                Graph h = new Graph();
                fuseki.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
            {
#if !NO_URICACHE
                Options.UriLoaderCaching = true;
#endif
            }
        }
        public void StoragePersistentTripleStoreFusekiRemoveTriplesFlushed()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestRemoveTriplesFlushed(fuseki);
        }
        public void StoragePersistentTripleStoreFusekiAddTriplesDiscarded()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestAddTriplesDiscarded(fuseki);
        }
        public void StoragePersistentTripleStoreFusekiGetGraph()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestGetGraph(fuseki);
        }
        public void StoragePersistentTripleStoreFusekiUpdate()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestUpdate(fuseki);
        }
        public void StoragePersistentTripleStoreFusekiUpdateUnsynced()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            Assert.Throws <SparqlUpdateException>(() => this.TestUpdateUnsynced(fuseki));
        }
        public void StoragePersistentTripleStoreFusekiQueryDescribe()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestQueryDescribe(fuseki, "DESCRIBE ?type WHERE { GRAPH ?g { ?s a ?type } } LIMIT 5");
        }
        public void StoragePersistentTripleStoreFusekiQueryConstruct()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestQueryConstruct(fuseki, "CONSTRUCT { ?s a ?type } WHERE { ?s a ?type }");
        }
        public void StoragePersistentTripleStoreFusekiQuerySelect()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestQuerySelect(fuseki, "SELECT * WHERE { ?s a ?type }");
        }
        public void StoragePersistentTripleStoreFusekiQueryUnsynced()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            Assert.Throws <RdfQueryException>(() => this.TestQueryUnsynced(fuseki));
        }
        public void StoragePersistentTripleStoreFusekiRemoveThenAddGraphDiscarded()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestRemoveThenAddGraphDiscarded(fuseki);
        }
        public void StoragePersistentTripleStoreFusekiAddThenRemoveGraphFlushed()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestAddThenRemoveGraphFlushed(fuseki);
        }
예제 #25
0
        public void StoragePersistentTripleStoreFusekiQueryUnsynced()
        {
            FusekiConnector fuseki = FusekiTest.GetConnection();

            this.TestQueryUnsynced(fuseki);
        }