title: Using Grizzly as the test container for dropwizard resources
body: <p>I am trying to get this <a href="https://gist.github.com/igstan/3016987" rel="nofollow">GrizzlyResourceTest.java</a>working with dropwizard v0.6.1. The reason I want to use grizzly as the test container is because InMemoryTestContainer does not support Resource with injectable constructor, see this issue in details <a href="http://java.net/jira/browse/JERSEY-623?page=com.atlassian.jira.plugin.system.issuetabpanels%3aall-tabpanel." rel="nofollow">InMemoryTestContainer does not support Resource with injectable constructor</a></p>
  
  <p>Since com.yammer.dropwizard.json.Json and com.yammer.dropwizard.bundles.JavaBundle are not in v0.6.1 anymore, I simply just comment out the lines related to these class.</p>
  
  <pre><code>  @Before
    public void setUpJersey() throws Exception {
      setUpResources();
      this.test = new JerseyTest(new GrizzlyWebTestContainerFactory()) {
        @Override
        protected AppDescriptor configure() {
          ClientConfig config = new DefaultClientConfig();
  
          // taken from DropwizardResourceConfig
          config.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
          config.getSingletons().add(new LoggingExceptionMapper&lt;Throwable&gt;() { }); // create a subclass to pin it to Throwable
          config.getClasses().add(InstrumentedResourceMethodDispatchAdapter.class);
          config.getClasses().add(CacheControlledResourceMethodDispatchAdapter.class);
  
          for (Class&lt;?&gt; provider : providers) {
            config.getClasses().add(provider);
          }
  
          config.getSingletons().addAll(singletons);
  
          return new WebAppDescriptor.Builder("com.example.helloworld.resources").clientConfig(config).build();
        }
      };
      test.setUp();
    }
  </code></pre>
  
  <p>My case is more complex since I have HttpServletRequest injected to my resource class like myMethod(@Context HttpServletRequest request). So here I just use PersonResource under dropwizard-example.</p>
  
  <p>QuickTest.java looks like:</p>
  
  <pre><code>public class QuickTest extends GrizzlyResourceTest{
      @Test
      public void testGrizzly() throws Exception {
          ClientResponse rsp = client()
              .resource("http://localhost:9998/people").get(ClientResponse.class);
          Assert.assertEquals(200, rsp.getStatus());
      }
      @Override
      protected void setUpResources() throws Exception {
      }
  }
  </code></pre>
  
  <p>When I run QuickTest, The error I am getting from Console is this:</p>
  
  <pre><code>SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
  Mar 14, 2013 7:14:11 PM com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer &lt;init&gt;
  INFO: Creating Grizzly2 Web Container configured at the base URI http://localhost:9998/
  Mar 14, 2013 7:14:11 PM org.glassfish.grizzly.http.server.NetworkListener start
  INFO: Started listener bound to [localhost:9998]
  Mar 14, 2013 7:14:11 PM org.glassfish.grizzly.http.server.HttpServer start
  INFO: [HttpServer] Started.
  Mar 14, 2013 7:14:11 PM org.glassfish.grizzly.servlet.WebappContext deploy
  INFO: Starting application [TestContext] ...
  Mar 14, 2013 7:14:11 PM org.glassfish.grizzly.servlet.WebappContext initServlets
  INFO: [TestContext] Servlet [com.sun.jersey.spi.container.servlet.ServletContainer] registered for url pattern(s) [[/*]].
  Mar 14, 2013 7:14:11 PM org.glassfish.grizzly.servlet.WebappContext deploy
  INFO: Application [TestContext] is ready to service requests.  Root: [].
  Mar 14, 2013 7:14:11 PM com.sun.jersey.spi.inject.Errors processErrorMessages
  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
    SEVERE: Missing dependency for field: private javax.servlet.http.HttpServletRequest com.yammer.dropwizard.jersey.LoggingExceptionMapper.request
  </code></pre>
  
  <p>Any ideas?</p>