public void StorageFourStoreUpdate()
        {
            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            fourstore.Update("CREATE SILENT GRAPH <http://example.org/update>; INSERT DATA { GRAPH <http://example.org/update> { <http://example.org/subject> <http://example.org/predicate> <http://example.org/object> } }");

            Graph g = new Graph();

            fourstore.LoadGraph(g, "http://example.org/update");

            Assert.Equal(1, g.Triples.Count);

            fourstore.Update("DROP SILENT GRAPH <http://example.org/update>");
            Graph h = new Graph();

            fourstore.LoadGraph(h, "http://example.org/update");

            Assert.True(h.IsEmpty, "Graph should be empty after the DROP GRAPH update was issued");
            Assert.Equal(g, h);
        }
Beispiel #2
0
        public void StorageFourStoreUpdate()
        {
            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            fourstore.Update("CREATE SILENT GRAPH <http://example.org/update>; INSERT DATA { GRAPH <http://example.org/update> { <http://example.org/subject> <http://example.org/predicate> <http://example.org/object> } }");

            Graph g = new Graph();

            fourstore.LoadGraph(g, "http://example.org/update");

            Assert.AreEqual(1, g.Triples.Count, "The CREATE GRAPH and INSERT DATA commands should result in 1 Triple in the Graph");

            fourstore.Update("DROP SILENT GRAPH <http://example.org/update>");
            Graph h = new Graph();

            fourstore.LoadGraph(h, "http://example.org/update");

            Assert.IsTrue(h.IsEmpty, "Graph should be empty after the DROP GRAPH update was issued");
            Assert.AreNotEqual(g, h, "Graphs should not be equal");
        }
        public void StorageFourStoreDeleteGraph()
        {
            StorageFourStoreSaveGraph();

            FourStoreConnector fourstore = new FourStoreConnector(FourStoreTestUri);
            fourstore.DeleteGraph("http://example.org/4storeTest");

            Graph g = new Graph();
            fourstore.LoadGraph(g, "http://example.org/4storeTest");

            Assert.IsTrue(g.IsEmpty, "Graph should be empty as it was deleted from 4store");
        }
        public void StorageFourStoreDeleteGraph()
        {
            StorageFourStoreSaveGraph();

            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            fourstore.DeleteGraph("http://example.org/4storeTest");

            Graph g = new Graph();

            fourstore.LoadGraph(g, "http://example.org/4storeTest");

            Assert.True(g.IsEmpty, "Graph should be empty as it was deleted from 4store");
        }
        public void StorageFourStoreSaveGraph()
        {
            Graph g = new Graph();
            FileLoader.Load(g, "InferenceTest.ttl");
            g.BaseUri = new Uri("http://example.org/4storeTest");

            FourStoreConnector fourstore = new FourStoreConnector(FourStoreTestUri);
            fourstore.SaveGraph(g);

            Graph h = new Graph();
            fourstore.LoadGraph(h, "http://example.org/4storeTest");

            Assert.AreEqual(g, h, "Graphs should be equal");
        }
        public void StorageFourStoreAddTriples()
        {
            StorageFourStoreDeleteGraph();
            StorageFourStoreSaveGraph();

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

            FourStoreConnector fourstore = new FourStoreConnector(FourStoreTestUri);
            fourstore.UpdateGraph("http://example.org/4storeTest", ts, null);

            fourstore.LoadGraph(g, "http://example.org/4storeTest");

            Assert.IsTrue(ts.All(t => g.ContainsTriple(t)), "Added Triple should not have been in the Graph");
        }
        public void StorageFourStoreLoadGraph()
        {
            StorageFourStoreSaveGraph();

            Graph g = new Graph();

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

            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            Graph h = new Graph();

            fourstore.LoadGraph(h, "http://example.org/4storeTest");

            Assert.Equal(g, h);
        }
        public void StorageFourStoreSaveGraph()
        {
            Graph g = new Graph();

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

            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            fourstore.SaveGraph(g);

            Graph h = new Graph();

            fourstore.LoadGraph(h, "http://example.org/4storeTest");

            Assert.AreEqual(g, h, "Graphs should be equal");
        }
        public void StorageFourStoreAddTriples()
        {
            StorageFourStoreDeleteGraph();
            StorageFourStoreSaveGraph();

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

            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            fourstore.UpdateGraph("http://example.org/4storeTest", ts, null);

            fourstore.LoadGraph(g, "http://example.org/4storeTest");

            Assert.True(ts.All(t => g.ContainsTriple(t)), "Added Triple should be in the Graph");
        }
        public void StorageFourStoreRemoveTriples()
        {
            StorageFourStoreAddTriples();

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

            FourStoreConnector fourstore = FourStoreTest.GetConnection();

            fourstore.UpdateGraph("http://example.org/4storeTest", null, ts);

            Thread.Sleep(2500);

            fourstore.LoadGraph(g, "http://example.org/4storeTest");

            Assert.True(ts.All(t => !g.ContainsTriple(t)), "Removed Triple should not have been in the Graph");
        }
        public static void Main(String[] args)
        {
            StreamWriter output = new StreamWriter("4StoreTest.txt");
            try
            {
                Console.SetOut(output);
                Console.WriteLine("## 4store Test");
                Console.WriteLine();

                //Load the Graph we want to use as a Test
                Graph g = new Graph();
                TurtleParser ttlparser = new TurtleParser();
                ttlparser.Load(g, "InferenceTest.ttl");
                Console.WriteLine("Test Graph contains the following Triples:");
                foreach (Triple t in g.Triples)
                {
                    Console.WriteLine(t.ToString());
                }
                Console.WriteLine();

                //Create the 4store Connector
                FourStoreConnector fourstore = new FourStoreConnector("http://nottm-virtual.ecs.soton.ac.uk:8080/");

                //Try to save a Graph to the Store
                Console.WriteLine("Attempting to save a Graph to the Store");
                g.BaseUri = new Uri("http://example.org/test");
                fourstore.SaveGraph(g);
                Console.WriteLine("Graph saved OK");
                Console.WriteLine();

                //Try to retrieve the Graph from the Store
                Console.WriteLine("Attempting to load the Graph back from the Store");
                Graph h = new Graph();
                fourstore.LoadGraph(h, g.BaseUri);
                Console.WriteLine("Graph loaded OK");
                Console.WriteLine("Contains the following Triples:");
                foreach (Triple t in h.Triples)
                {
                    Console.WriteLine(t.ToString());
                }
                Console.WriteLine();

                //Make a couple of queries against the store
                Console.WriteLine("Attempting to make an ASK query against the Store");
                Object results;
                results = fourstore.Query("ASK WHERE {<http://example.org/vehicles/FordFiesta> ?p ?o}");
                ShowResults(results);

                Console.WriteLine();
                Console.WriteLine("Attempting to make a SELECT query against the Store");
                results = fourstore.Query("SELECT * WHERE {<http://example.org/vehicles/FordFiesta> ?p ?o}");
                ShowResults(results);

                Console.WriteLine();
                Console.WriteLine("Attempting to make a DESCRIBE query against the Store");
                results = fourstore.Query("DESCRIBE <http://example.org/vehicles/FordFiesta>");
                ShowResults(results);

                Console.WriteLine();
                Console.WriteLine("Attempting to make a CONSTRUCT query against the Store");
                results = fourstore.Query("CONSTRUCT {<http://example.org/vehicles/FordFiesta> ?p ?o} WHERE {<http://example.org/vehicles/FordFiesta> ?p ?o}");
                ShowResults(results);

                //Now delete the data we added
                Console.WriteLine();
                Console.WriteLine("Attempting to delete the Graph from the Store");
                fourstore.DeleteGraph(g.BaseUri);
                Console.WriteLine("Graph deleted Ok");

            }
            catch (IOException ioEx)
            {
                reportError(output, "IO Exception", ioEx);
            }
            catch (RdfParseException parseEx)
            {
                reportError(output, "Parsing Exception", parseEx);
            }
            catch (RdfStorageException storeEx)
            {
                reportError(output, "Storage Exception", storeEx);
            }
            catch (RdfException rdfEx)
            {
                reportError(output, "RDF Exception", rdfEx);
            }
            catch (WebException webEx)
            {
                reportError(output, "HTTP Exception", webEx);
            }
            catch (Exception ex)
            {
                reportError(output, "Other Exception", ex);
            }
            finally
            {
                output.Close();
            }
        }
        public void StorageFourStoreUpdate()
        {
            FourStoreConnector fourstore = new FourStoreConnector(FourStoreTestUri);
            fourstore.Update("CREATE SILENT GRAPH <http://example.org/update>; INSERT DATA { GRAPH <http://example.org/update> { <http://example.org/subject> <http://example.org/predicate> <http://example.org/object> } }");

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

            Assert.AreEqual(1, g.Triples.Count, "The CREATE GRAPH and INSERT DATA commands should result in 1 Triple in the Graph");

            fourstore.Update("DROP SILENT GRAPH <http://example.org/update>");
            Graph h = new Graph();
            fourstore.LoadGraph(h, "http://example.org/update");

            Assert.IsTrue(h.IsEmpty, "Graph should be empty after the DROP GRAPH update was issued");
            Assert.AreNotEqual(g, h, "Graphs should not be equal");
        }