Search in sources :

Example 1 with JettyHttpServerDispatch

use of com.twitter.common.net.http.JettyHttpServerDispatch in project commons by twitter.

the class HttpStatsFilterIntegrationTest method setUp.

@Before
public void setUp() {
    Stats.flush();
    server = new JettyHttpServerDispatch();
    server.listen(0);
    server.registerFilter(GuiceFilter.class, "/*");
    clock = new FakeClock();
    final Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(TestServlet.class).in(Singleton.class);
            bind(Clock.class).toInstance(clock);
            bind(HttpStatsFilter.class).in(Singleton.class);
        }
    }, new JerseyServletModule() {

        @Override
        protected void configureServlets() {
            filter("/*").through(HttpStatsFilter.class);
            serve("/*").with(GuiceContainer.class, ImmutableMap.of(PROPERTY_CONTAINER_RESPONSE_FILTERS, HttpStatsFilter.class.getName()));
        }
    });
    server.getRootContext().addEventListener(new GuiceServletContextListener() {

        @Override
        protected Injector getInjector() {
            return injector;
        }
    });
    ClientConfig config = new DefaultClientConfig();
    client = Client.create(config);
}
Also used : JettyHttpServerDispatch(com.twitter.common.net.http.JettyHttpServerDispatch) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) FakeClock(com.twitter.common.util.testing.FakeClock) Injector(com.google.inject.Injector) Singleton(com.google.inject.Singleton) JerseyServletModule(com.sun.jersey.guice.JerseyServletModule) GuiceContainer(com.sun.jersey.guice.spi.container.servlet.GuiceContainer) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) GuiceServletContextListener(com.google.inject.servlet.GuiceServletContextListener) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Singleton (com.google.inject.Singleton)1 GuiceServletContextListener (com.google.inject.servlet.GuiceServletContextListener)1 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)1 DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)1 JerseyServletModule (com.sun.jersey.guice.JerseyServletModule)1 GuiceContainer (com.sun.jersey.guice.spi.container.servlet.GuiceContainer)1 JettyHttpServerDispatch (com.twitter.common.net.http.JettyHttpServerDispatch)1 FakeClock (com.twitter.common.util.testing.FakeClock)1 Before (org.junit.Before)1