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.Equal(starts.Count, 1); foreach (var e in starts) { Assert.True(e is HttpRunTimeStartHandler); start = (HttpRunTimeStartHandler)e; } Assert.Equal(stops.Count, 1); foreach (var e in stops) { Assert.True(e is HttpRunTimeStopHandler); stop = (HttpRunTimeStopHandler)e; } Assert.Equal(start.Server, stop.Server); Assert.Equal(start.Server.JettyHandler.HttpeventHanlders, stop.Server.JettyHandler.HttpeventHanlders); Assert.Same(start.Server, stop.Server); }
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.Equal(rh.Count, 1); foreach (var e in rh) { Assert.True(e is HttpRunTimeStartHandler); HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e; var s = r.Server; foreach (IHttpHandler h in s.JettyHandler.HttpeventHanlders) { System.Diagnostics.Debug.WriteLine(h.GetUriSpecification()); } } }
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.Equal(rh.Count, 1); foreach (var e in rh) { Assert.True(e is HttpRunTimeStartHandler); HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e; var s = r.Server; Assert.Equal(s.JettyHandler.HttpeventHanlders.Count, 0); // no handlers are bound } }