Exemple #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);
        }
Exemple #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());
                }
            }
        }
Exemple #3
0
        public void TestEvaluatorRuntime()
        {
            ConfigurationModule module =
                new ConfigurationModuleBuilder()
                .BindSetEntry <RuntimeStartHandler, EvaluatorRuntime, IObserver <RuntimeStart> >(GenericType <RuntimeStartHandler> .Class, GenericType <EvaluatorRuntime> .Class)
                .Build();
            IConfiguration clockConfiguraiton = module.Build();

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

            Assert.AreEqual(r.Count, 1);
            foreach (var e in r)
            {
                Assert.IsTrue(e is EvaluatorRuntime);
            }
        }
Exemple #4
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
            }
        }