Пример #1
0
        public void TestSparqlUpdate()
        {
            // Create an initial store for sync
            var client =
                BrightstarService.GetClient("type=embedded;storesDirectory=c:\\brightstar\\coreA");

            client.CreateStore("TestStore4");
            var result = client.ExecuteTransaction("TestStore4", null, null,
                                                   "<http://brightstardb.com/foo> <http://brightstardb.com/isa> <http://brightstardb.com/bar>.");

            Assert.IsTrue(result.JobCompletedOk, "Setup transaction failed on TestStore2");

            _coreA.Start(10001);
            _coreB.Start(10002);
            _clusterManager.Start();

            WaitForState(_coreB, CoreState.RunningSlave, 5000);
            Assert.IsTrue(Directory.Exists("c:\\brightstar\\coreB\\TestStore4"));

            var       results    = _coreB.ProcessQuery("TestStore4", "SELECT * WHERE { <http://brightstardb.com/foo> ?s ?p }");
            XDocument resultsDoc = XDocument.Parse(results);

            Assert.AreEqual(1, resultsDoc.SparqlResultRows().Count());

            _coreA.ProcessUpdate(new ClusterSparqlTransaction {
                StoreId    = "TestStore4",
                Expression =
                    @"
INSERT DATA
{ 
  <http://brightstardb.com/foo> <http://brightstardb.com/property> <http://brightstardb.com/value> .
}
"
            });

            Thread.Sleep(500);
            results = _coreB.ProcessQuery("TestStore4", "SELECT * WHERE {<http://brightstardb.com/foo> ?s ?p }");
            XDocument newResultsDoc = XDocument.Parse(results);

            Assert.AreEqual(2, newResultsDoc.SparqlResultRows().Count());
        }