Пример #1
0
        private void TestCreateGraphRollbackWithoutAutoCommit()
        {
            ISparqlDataset dataset = this.GetEmptyDataset();

            String updates = "CREATE GRAPH <" + TestGraphUri.ToString() + ">; CREATE GRAPH <" + TestGraphUri.ToString() + ">";

            SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates);

            LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset);

            processor.AutoCommit = false;
            try
            {
                processor.ProcessCommandSet(cmds);
                Assert.True(false, "Did not throw a SparqlUpdateException as expected");
            }
            catch (SparqlUpdateException upEx)
            {
                TestTools.ReportError("Update Exception", upEx);
            }

            Assert.True(dataset.HasGraph(TestGraphUri), "Graph should exist as the Transaction has not been committed yet as Auto-Commit is off");

            //Try to Flush() which should error
            try
            {
                processor.Flush();
                Assert.True(false, "Did not throw a SparqlUpdateException as expected on call to Flush()");
            }
            catch (SparqlUpdateException upEx)
            {
                Console.WriteLine("Threw error when attempting to Flush() as expected");
                TestTools.ReportError("Update Exception", upEx);
            }

            //Now discard
            processor.Discard();
            Assert.False(dataset.HasGraph(TestGraphUri), "Graph should not exist as the Discard() should cause it to be removed from the Dataset");
        }
        private void TestCreateGraphRollbackWithoutAutoCommit()
        {
            ISparqlDataset dataset = this.GetEmptyDataset();

            String updates = "CREATE GRAPH <" + TestGraphUri.ToString() + ">; CREATE GRAPH <" + TestGraphUri.ToString() + ">";

            SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates);

            LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset);
            processor.AutoCommit = false;
            try
            {
                processor.ProcessCommandSet(cmds);
                Assert.Fail("Did not throw a SparqlUpdateException as expected");
            }
            catch (SparqlUpdateException upEx)
            {
                TestTools.ReportError("Update Exception", upEx, false);
            }

            Assert.IsTrue(dataset.HasGraph(TestGraphUri), "Graph should exist as the Transaction has not been committed yet as Auto-Commit is off");

            //Try to Flush() which should error
            try
            {
                processor.Flush();
                Assert.Fail("Did not throw a SparqlUpdateException as expected on call to Flush()");
            }
            catch (SparqlUpdateException upEx)
            {
                Console.WriteLine("Threw error when attempting to Flush() as expected");
                TestTools.ReportError("Update Exception", upEx, false);
            }
            
            //Now discard
            processor.Discard();
            Assert.IsFalse(dataset.HasGraph(TestGraphUri), "Graph should not exist as the Discard() should cause it to be removed from the Dataset");

        }