Example #1
0
        public void StartTest()
        {
            WindowsIdentity  identity  = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal = new WindowsPrincipal(identity);

            if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                Assert.Fail("You must be running this test as an Administrator");
            }

            LogbusServerConfiguration config = new LogbusServerConfiguration();

            using (ILogBus service = new LogbusService(config))
            {
                service.Start();
                int httpPort = 8065; // TODO: Eseguire l'inizializzazione a un valore appropriato
                using (WebServiceActivator webService = new WebServiceActivator(service, httpPort))
                {
                    webService.Start();
                    Thread.Sleep(10000);
                    webService.Stop();
                }
                service.Stop();
            }
        }
Example #2
0
        public void Test2()
        {
            try
            {
                t2_step1  = new AutoResetEvent(false);
                t2_step2  = new AutoResetEvent(false);
                t2_finish = new AutoResetEvent(false);

                Thread source, client;
                source = new Thread(t2_thread_Source);
                client = new Thread(t2_thread_Client);
                using (ILogBus logbus_service = new LogbusService(core_configuration[1]))
                {
                    logbus_service.Start();
                    client.Start(logbus_service);

                    //Wait for client to be synchronized
                    t2_step1.WaitOne();

                    //Prepare source
                    source.Start();
                    //Wait for source to send all the messages
                    t2_step2.WaitOne();

                    //Wait for finish
                    t2_finish.WaitOne();
                    //TestContext.
                }
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
        public void TestDeployAsmx()
        {
            try
            {
                LogbusServerConfiguration config = new LogbusServerConfiguration();
                config.webserver = new WebServerConfiguration {
                    active = true
                };
                PluginDefinition plugDef = new PluginDefinition()
                {
                    type = typeof(DummyPlugin).AssemblyQualifiedName
                };
                config.plugins = new PluginDefinition[] { plugDef };
                using (LogbusService logbus = new LogbusService())
                {
                    logbus.Configure(config);
                    logbus.Start();

                    //Test HTTP request
                    DummyStub stub = new DummyStub()
                    {
                        Url = "http://localhost:8065/Dummy.asmx"
                    };

                    Assert.AreEqual <int>(5, stub.Sum(3, 2));
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Test failed: {0}", ex.ToString());
            }
        }
        public void LogbusTest()
        {
            step1  = new AutoResetEvent(false);
            step2  = new AutoResetEvent(false);
            finish = new AutoResetEvent(false);

            try
            {
                LogbusServerConfiguration config = new LogbusServerConfiguration();
                config.inchannels             = new InboundChannelDefinition[1];
                config.inchannels[0]          = new InboundChannelDefinition();
                config.inchannels[0].type     = "It.Unina.Dis.Logbus.InChannels.SyslogUdpReceiver, It.Unina.Dis.Logbus";
                config.inchannels[0].param    = new KeyValuePair[1];
                config.inchannels[0].param[0] =
                    new KeyValuePair()
                {
                    name  = "port",
                    value = SOURCE_PORT.ToString()
                };

                using (ILogBus service = new LogbusService(config))
                {
                    service.Start();

                    new Thread(thread_Client).Start(service);
                    step1.WaitOne();

                    new Thread(thread_Source).Start();
                    step2.WaitOne();

                    finish.WaitOne();
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Test failed: {0}", ex);
            }
        }
        public void FFDATest()
        {
            FilterBase ffda_filter =
                new FacilityEqualsFilter()
            {
                facility = SyslogFacility.Local0
            } &
            new PropertyFilter()
            {
                comparison = ComparisonOperator.eq, propertyName = Property.MessageID, value = "FFDA"
            };

            StringBuilder markup = new StringBuilder();

            new XmlSerializer(typeof(FilterBase)).Serialize(XmlTextWriter.Create(markup, new XmlWriterSettings()
            {
                Indent = true
            }), ffda_filter, ffda_filter.xmlns);

            TestContext.WriteLine("{0}", markup.ToString());

            const int SEND_PORT = 5427;

            //Init Logbus
            LogbusServerConfiguration core_config = new LogbusServerConfiguration();

            core_config.corefilter = ffda_filter;
            InboundChannelDefinition in_ch = new InboundChannelDefinition();

            in_ch.type  = "SyslogUdpReceiver";
            in_ch.param = new KeyValuePair[]
            {
                new KeyValuePair()
                {
                    name  = "port",
                    value = SEND_PORT.ToString()
                }
            };
            core_config.inchannels = new InboundChannelDefinition[] { in_ch };

            using (ILogBus logbus = new LogbusService(core_config))
            {
                logbus.MessageReceived += new EventHandler <SyslogMessageEventArgs>(logbus_MessageReceived);
                logbus.Start();

                //Init FFDA
                LogbusLoggerConfiguration source_config = new LogbusLoggerConfiguration();
                LoggerDefinition          udp_def       = new LoggerDefinition()
                {
                    type  = "SyslogUdpCollector",
                    param = new KeyValuePair[] { new KeyValuePair()
                                                 {
                                                     name = "port", value = SEND_PORT.ToString()
                                                 }, new KeyValuePair()
                                                 {
                                                     name = "ip", value = "127.0.0.1"
                                                 } }
                };
                source_config.logger       = new LoggerDefinition[] { udp_def };
                LoggerHelper.Configuration = source_config;

                //Send what we want: 2 FFDA messages
                IFieldFailureDataLogger logger = FieldFailureDataHelper.CreateFailureDataLogger("ffda");
                logger.LogSST();
                logger.LogSEN();

                //Send junk
                ILog junk_log = LoggerHelper.GetLogger();
                junk_log.Debug("Hello");
                junk_log.Error("Junk error");

                Thread.Sleep(1000);
                logbus.Stop();
            }

            Assert.AreEqual(2, messages);
        }