Exemplo n.º 1
0
        public void RuntimeStartStopHandlerTest()
        {
            IConfiguration clockConfiguraiton = HttpRuntimeConfiguration.CONF.Build();
            RuntimeClock   clock  = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>();
            var            starts = clock.ClockRuntimeStartHandler.Get();
            var            stops  = clock.ClockRuntimeStopHandler.Get();

            HttpRunTimeStartHandler start = null;
            HttpRunTimeStopHandler  stop  = null;

            Assert.AreEqual(starts.Count, 1);
            foreach (var e in starts)
            {
                Assert.IsTrue(e is HttpRunTimeStartHandler);
                start = (HttpRunTimeStartHandler)e;
            }

            Assert.AreEqual(stops.Count, 1);
            foreach (var e in stops)
            {
                Assert.IsTrue(e is HttpRunTimeStopHandler);
                stop = (HttpRunTimeStopHandler)e;
            }

            Assert.AreEqual(start.Server, stop.Server);
            Assert.AreEqual(start.Server.JettyHandler.HttpeventHanlders, stop.Server.JettyHandler.HttpeventHanlders);
            Assert.AreSame(start.Server, stop.Server);
        }
Exemplo n.º 2
0
        public void RuntimeStartHandlerMergeTest()
        {
            IConfiguration clockConfiguraiton = HttpHandlerConfiguration.CONF
                                                .Set(HttpHandlerConfiguration.P,
                                                     GenericType <HttpServerReefEventHandler> .Class)
                                                .Set(HttpHandlerConfiguration.P,
                                                     GenericType <HttpServerNrtEventHandler> .Class)
                                                .Build();

            RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>();

            var rh = clock.ClockRuntimeStartHandler.Get();

            Assert.AreEqual(rh.Count, 1);
            foreach (var e in rh)
            {
                Assert.IsTrue(e is HttpRunTimeStartHandler);
                HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e;
                var s = r.Server;
                foreach (IHttpHandler h in s.JettyHandler.HttpeventHanlders)
                {
                    System.Diagnostics.Debug.WriteLine(h.GetUriSpecification());
                }
            }
        }
Exemplo n.º 3
0
        public void RuntimeStartHandlerTest()
        {
            ConfigurationModule module =
                new ConfigurationModuleBuilder()
                .BindSetEntry <RuntimeStartHandler, HttpRunTimeStartHandler, IObserver <RuntimeStart> >(
                    GenericType <RuntimeStartHandler> .Class, GenericType <HttpRunTimeStartHandler> .Class)
                .Build();
            IConfiguration clockConfiguraiton = module.Build();

            RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>();
            var          rh    = clock.ClockRuntimeStartHandler.Get();

            Assert.AreEqual(rh.Count, 1);
            foreach (var e in rh)
            {
                Assert.IsTrue(e is HttpRunTimeStartHandler);
                HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e;
                var s = r.Server;
                Assert.AreEqual(s.JettyHandler.HttpeventHanlders.Count, 0); // no handlers are bound
            }
        }