protected override bool HasGraphInternal(Uri graphUri)
        {
            AnyHandler any = new AnyHandler();

            this._storage.LoadGraph(any, graphUri);
            return(any.Any);
        }
        private void TestRemoveThenAddGraphDiscarded(IStorageProvider manager)
        {
            this.EnsureTestDataset(manager);

            PersistentTripleStore store = new PersistentTripleStore(manager);

            try
            {
                Uri    toRemove = new Uri(TestGraphUri1);
                IGraph g        = store[toRemove];
                Assert.True(store.HasGraph(toRemove), "In-memory view should contain the Graph we wish to remove");

                store.Remove(toRemove);
                Assert.False(store.HasGraph(toRemove), "In-memory view should no longer contain the Graph we removed prior to the Flush/Discard operation");

                store.Add(g);
                Assert.True(store.HasGraph(toRemove), "In-memory should now contain the Graph we added back");

                store.Discard();

                Assert.True(store.HasGraph(toRemove), "In-Memory view should still contain the Graph we removed and added back regardless as we Discarded that change");
                AnyHandler handler = new AnyHandler();
                manager.LoadGraph(handler, toRemove);
                Assert.True(handler.Any, "Attempting to load Graph from underlying store should return something as the Discard() prevented the removal and add back being persisted");
            }
            finally
            {
                store.Dispose();
            }
        }
        private void TestRemoveThenAddGraphFlushed(IStorageProvider manager)
        {
            this.EnsureTestDataset(manager);

            PersistentTripleStore store = new PersistentTripleStore(manager);

            try
            {
                Uri    toRemove = new Uri(TestGraphUri1);
                IGraph g        = store[toRemove];
                Assert.True(store.HasGraph(toRemove), "In-memory view should contain the Graph we wish to remove");

                store.Remove(toRemove);
                Assert.False(store.HasGraph(toRemove), "In-memory view should no longer contain the Graph we removed prior to the Flush/Discard operation");

                store.Add(g);
                Assert.True(store.HasGraph(toRemove), "In-memory should now contain the Graph we added back");

                store.Flush();

                Assert.True(store.HasGraph(toRemove), "In-Memory view should still contain the Graph we added back after Flushing");
                AnyHandler handler = new AnyHandler();
                manager.LoadGraph(handler, toRemove);
                Assert.True(handler.Any, "Attempting to load Graph from underlying store should return something after the Flush() operation since we didn't remove the graph in the end");
            }
            finally
            {
                store.Dispose();
            }
        }
        private void TestRemoveGraphFlushed(IStorageProvider manager)
        {
            this.EnsureTestDataset(manager);

            PersistentTripleStore store = new PersistentTripleStore(manager);

            try
            {
                Uri toRemove = new Uri(TestGraphUri1);
                Assert.True(store.HasGraph(toRemove), "In-memory view should contain the Graph we wish to remove");

                store.Remove(toRemove);
                Assert.False(store.HasGraph(toRemove), "In-memory view should no longer contain the Graph we removed prior to the Flush/Discard operation");
                store.Flush();

                Assert.False(store.HasGraph(toRemove), "In-Memory view should no longer contain the Graph we removed after Flushing");
                AnyHandler handler = new AnyHandler();
                try
                {
                    manager.LoadGraph(handler, toRemove);
                }
                catch
                {
                }
                Assert.False(handler.Any, "Attempting to load Graph from underlying store should return nothing after the Flush() operation");
            }
            finally
            {
                store.Dispose();
            }
        }
Exemple #5
0
        private bool ContainsInternal(Uri graphUri)
        {
            AnyHandler handler = new AnyHandler();

            try
            {
                _manager.LoadGraph(handler, graphUri);
                return(handler.Any);
            }
            catch
            {
                return(false);
            }
        }
Exemple #6
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("usage logging.exe mw-id=<middleware ID>");
            return(-1);
        }

        //o Load the command-line input into a GMSEC Config object
        // A Config object is basically a key-value pair map which is used to
        // pass configuration options into objects such as Connections,
        // ConnectionManagers, Subscribe and Publish function calls, Messages,
        // etc.
        Config config = new Config(args);

        ErrorHandler   errorHandler   = new ErrorHandler();
        WarningHandler warningHandler = new WarningHandler();
        InfoHandler    infoHandler    = new InfoHandler();
        VerboseHandler verboseHandler = new VerboseHandler();
        DebugHandler   debugHandler   = new DebugHandler();
        AnyHandler     anyHandler     = new AnyHandler();

        Log.RegisterHandler(LoggingLevel.ERROR, errorHandler);
        Log.RegisterHandler(LoggingLevel.WARNING, warningHandler);
        Log.RegisterHandler(LoggingLevel.INFO, infoHandler);
        Log.RegisterHandler(LoggingLevel.VERBOSE, verboseHandler);
        Log.RegisterHandler(LoggingLevel.DEBUG, debugHandler);

        //o Set logging reporting level
        Log.SetReportingLevel(LoggingLevel.VERBOSE);
        Log.Verbose("The log reporting level is now set to: " + Log.GetReportingLevel());

        //o Print the GMSEC API version number using the GMSEC Logging
        // interface
        // This is useful for determining which version of the API is
        // configured within the environment
        // TODO: Once available, replace this statement with usage of
        // ConnectionManager::getAPIVersion (See RTC 4798)
        Log.Info(Connection.GetAPIVersion());

        try
        {
            //o Create the ConnectionManager
            ConnectionManager connMgr = new ConnectionManager(config);

            //o Connect
            Log.Info("Opening the connection to the middleware server");
            connMgr.Initialize();

            //o Output middleware client/wrapper version
            Log.Info(connMgr.GetLibraryVersion());

            //o Publish a message
            PublishTestMessage(connMgr, "GMSEC.TEST.PUBLISH");

            //o Disconnect from the middleware and clean up the Connection
            connMgr.Cleanup();
        }
        catch (Exception e)
        {
            Log.Error(e.ToString());
            return(-1);
        }

        //o Unregister log handlers
        Log.RegisterHandler(null);

        //o Set log stream to stderr
        config.AddValue("LOGFILE", "STDERR");

        Log.Info("This message should go to stderr, not stdout.  " +
                 "For example, in bash test by running as:\n" +
                 "./logging mw-id=bolt 2> testfile.txt\n" +
                 "... and then check the contents of testfile.txt");

        //o Reset log stream to stdout
        config.AddValue("LOGFILE", "STDOUT");

        Log.Error("This is an example error message.");
        Log.Warning("This is an example warning message.");
        Log.Verbose("This is an example \"verbose\" message.");
        Log.Debug("This is an example debug message which should not show.");

        // This last message cannot be shown right now because
        // Log::setReportingLevel(logVERBOSE), used above, does not
        // allow DEBUG messages to come out.
        Log.Verbose("This is another example \"verbose\" message.");

        Log.SetReportingLevel(LoggingLevel.DEBUG);
        if (Log.GetReportingLevel() == LoggingLevel.DEBUG)
        {
            Log.Info("Changed reporting level to logDEBUG");
        }
        else
        {
            Log.Error("Failed to change reporting level to logDEBUG");
        }

        // The DEBUG message below will be shown successfully, unlike the last
        // debug message.
        Log.Debug("This is an example debug message which should show.");

        Log.Debug("NONE reporting level, numerically, is " + Log.LevelFromString("NONE"));
        Log.Debug("ERROR reporting level, numerically, is " + Log.LevelFromString("ERROR"));
        Log.Debug("SECURE reporting level, numerically, is " + Log.LevelFromString("SECURE"));
        Log.Debug("WARNING reporting level, numerically, is " + Log.LevelFromString("WARNING"));
        Log.Debug("INFO reporting level, numerically, is " + Log.LevelFromString("INFO"));
        Log.Debug("VERBOSE reporting level, numerically, is " + Log.LevelFromString("VERBOSE"));
        Log.Debug("DEBUG reporting level, numerically, is " + Log.LevelFromString("DEBUG"));

        //o Register general-purpose handler and test
        Log.RegisterHandler(anyHandler);

        Log.Error("NONE reporting level, numerically, is " + Log.LevelFromString("NONE"));
        Log.Error("ERROR reporting level, numerically, is " + Log.LevelFromString("ERROR"));
        Log.Warning("WARNING reporting level, numerically, is " + Log.LevelFromString("WARNING"));
        Log.Info("INFO reporting level, numerically, is " + Log.LevelFromString("INFO"));
        Log.Verbose("VERBOSE reporting level, numerically, is " + Log.LevelFromString("VERBOSE"));
        Log.Debug("DEBUG reporting level, numerically, is " + Log.LevelFromString("DEBUG"));

        //o Unregister log handlers
        Log.RegisterHandler(null);

        return(0);
    }