Exemplo n.º 1
0
        private void thread_Client(object Logbus)
        {
            try
            {
                ILogBus ctrl = Logbus as ILogBus;
                ctrl.CreateChannel("simple", "Simple", new TrueFilter(), "Very simple channel", 0);
                Dictionary <string, string> input;
                input = new Dictionary <string, string>();
                IEnumerable <KeyValuePair <string, string> > output;
                input.Add("ip", "127.0.0.1");
                input.Add("port", MONITOR_PORT.ToString());
                string clientid = ctrl.SubscribeClient("simple", "udp", input, out output);
                TestContext.WriteLine("Client ID obtained by logbus: {0}", clientid);

                //Go ahead and send
                step1.Set();


                IPEndPoint remote_ep = new IPEndPoint(IPAddress.Any, 0);
                using (UdpClient client = new UdpClient(MONITOR_PORT))
                {
                    byte[]        payload = client.Receive(ref remote_ep);
                    SyslogMessage msg     = SyslogMessage.Parse(payload);
                    TestContext.WriteLine("Message1: {0}", msg);
                    payload = client.Receive(ref remote_ep);
                    msg     = SyslogMessage.Parse(payload);
                    TestContext.WriteLine("Message2: {0}", msg);
                }

                ctrl.UnsubscribeClient(clientid);
                finish.Set();
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
Exemplo n.º 2
0
        public void StopTest()
        {
            ILogBus target = CreateILogBus();

            target.Stop();
            Assert.Inconclusive("Impossibile verificare un metodo che non restituisce valori.");
        }
Exemplo n.º 3
0
        public void TestTlsLogger()
        {
            try
            {
                if (!File.Exists(@"C:\\logbus.p12"))
                {
                    Assert.Inconclusive("Please copy first logbus.p12 to C:\\ path");
                }

                logbus = LogbusSingletonHelper.Instance;
                logger = LoggerHelper.GetLogger();

                logbus.Start();
                logbus.MessageReceived += logbus_MessageReceived;

                logger.Info("TLS test");

                Assert.IsTrue(testSuccess.WaitOne(5000));
            }
            finally
            {
                logbus.Dispose();
                logger = null;
            }
        }
Exemplo n.º 4
0
 public void StartTest()
 {
     using (ILogBus target = CreateILogBus())
     {
         target.Start();
     }
 }
Exemplo n.º 5
0
        public void RuntimeTest()
        {
            using (ILogBus target = CreateILogBus())
            {
                inject_finish   = new AutoResetEvent(false);
                injector_thread = new Thread(Injector);
                injector_thread.IsBackground = true;


                target.Started         += new System.EventHandler(target_Started);
                target.Stopped         += new System.EventHandler(target_Stopped);
                target.MessageReceived += new EventHandler <SyslogMessageEventArgs>(target_MessageReceived);

                TestContext.WriteLine("Starting Logbus instance");
                target.Start();
                injector_thread.Start();

                TestContext.WriteLine("Waiting for test completion");
                inject_finish.WaitOne();
                target.Stop();
                injector_thread.Join();

                TestContext.WriteLine("Test finished");

                Assert.AreEqual(messages_to_match, messages_matched);
            }
        }
Exemplo n.º 6
0
        private void t2_thread_Client(object Logbus)
        {
            try
            {
                ILogBus ctrl = Logbus as ILogBus;
                ctrl.CreateChannel("simple", "Simple", new TrueFilter(), "Very simple channel", 0);
                Dictionary <string, string> input;
                input = new Dictionary <string, string>();
                IEnumerable <KeyValuePair <string, string> > output;
                input.Add("ip", "127.0.0.1");
                input.Add("port", t2_client_port.ToString());
                string clientid = ctrl.SubscribeClient("simple", "udp", input, out output);
                TestContext.WriteLine("Client ID obtained by logbus: {0}", clientid);

                //Go ahead and send
                t2_step1.Set();

                //Only 6 messages expected
                IPEndPoint remote_ep = new IPEndPoint(IPAddress.Any, 0);
                using (UdpClient client = new UdpClient(t2_client_port))
                {
                    byte[] payload = client.Receive(ref remote_ep);
                    TestContext.WriteLine("Time occurred for a message to traverse the bus: {0} milliseconds", (DateTime.Now - t2_start).TotalMilliseconds.ToString(CultureInfo.CurrentUICulture));
                    SyslogMessage msg = SyslogMessage.Parse(payload);
                }

                ctrl.UnsubscribeClient(clientid);
                t2_finish.Set();
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
Exemplo n.º 7
0
        private void t1_thread_Client(object Logbus)
        {
            try
            {
                ILogBus ctrl = Logbus as ILogBus;
                ctrl.CreateChannel("simple", "Simple", new TrueFilter(), "Very simple channel", 0);
                Dictionary <string, string> input;
                input = new Dictionary <string, string>();
                IEnumerable <KeyValuePair <string, string> > output;
                input.Add("ip", "127.0.0.1");
                input.Add("port", t1_client_port.ToString());
                string clientid = ctrl.SubscribeClient("simple", "udp", input, out output);
                TestContext.WriteLine("Client ID obtained by logbus: {0}", clientid);

                //Go ahead and send
                t1_step1.Set();

                //Only 6 messages expected
                IPEndPoint remote_ep = new IPEndPoint(IPAddress.Any, 0);
                using (UdpClient client = new UdpClient(t1_client_port))
                    for (int i = 0; i < 5; i++)
                    {
                        byte[] payload = client.Receive(ref remote_ep);

                        SyslogMessage msg = SyslogMessage.Parse(payload);
                        Assert.AreEqual(SyslogFacility.Audit, msg.Facility);
                    }

                ctrl.UnsubscribeClient(clientid);
                t1_finish.Set();
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes the wrapper with a properly initialized target
 /// </summary>
 /// <param name="targetInstance">Logbus service</param>
 public Logbus2SoapAdapter(ILogBus targetInstance)
 {
     if (targetInstance == null)
     {
         throw new ArgumentNullException("targetInstance");
     }
     _target = targetInstance;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Implements IPlugin.Register
        /// </summary>
        public void Register(ILogBus logbus)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            _logbus = logbus;
            logbus.MessageReceived += LogbusMessageReceived;
        }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes the proxy with an existing instance of ILogBus
 /// </summary>
 /// <param name="targetInstance">ILogBus instance to use</param>
 public LogBusTie(ILogBus targetInstance)
 {
     if (targetInstance == null)
     {
         throw new ArgumentNullException("targetInstance");
     }
     _target                     = targetInstance;
     _target.Error              += Error;
     _target.MessageReceived    += MessageReceived;
     _target.Started            += Started;
     _target.Starting           += Starting;
     _target.Stopped            += Stopped;
     _target.Stopping           += Stopping;
     _target.OutChannelCreated  += OutChannelCreated;
     _target.OutChannelDeleted  += OutChannelDeleted;
     _target.ClientSubscribed   += ClientSubscribed;
     _target.ClientSubscribing  += ClientSubscribing;
     _target.ClientUnsubscribed += ClientUnsubscribed;
 }
Exemplo n.º 11
0
        public void TestTlsClient()
        {
            _success = new AutoResetEvent(false);
            using (ILogBus logbus = LogbusSingletonHelper.Instance)
            {
                logbus.Start();

                using (ILogClient client = ClientHelper.CreateReliableClient(new TrueFilter()))
                {
                    client.Start();
                    client.MessageReceived += client_MessageReceived;

                    ILog logger = LoggerHelper.GetLogger();
                    logger.Notice("Hello K.I.T.T.!");

                    Assert.IsTrue(_success.WaitOne(10000));
                }
            }
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);

            Console.WriteLine("Starting the Logbus-ng daemon. You MUST be running this program as Administrator");

            try
            {
                _logbus = LogbusSingletonHelper.Instance;

                _logbus.Start();

                Console.WriteLine("Logbus is started");

                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Something went wrong...");
                Console.WriteLine(ex);
                Environment.Exit(1);
            }
        }
 public WebServiceActivator(ILogBus instance)
     : this()
 {
     _target = instance;
 }
 /// <remarks/>
 public WebServiceActivator(ILogBus instance, int port)
     : this()
 {
     _target = instance; HttpPort = port;
 }
 public void Register(ILogBus logbus)
 {
 }