package com.hubspot.dropwizard.guice;

import com.hubspot.dropwizard.guice.objects.ExplicitDAO;
import com.hubspot.dropwizard.guice.objects.ExplicitResource;
import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.ClassRule;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * this test is created to address to Null Pointer Exceptions in JerseyTest.teardown() related to ServiceLocator
 * See: https://github.com/dropwizard/dropwizard/issues/828 and http://permalink.gmane.org/gmane.comp.java.dropwizard.devel/376
 */
public class InjectedResourcesTest {

    @ClassRule
    public static final ResourceTestRule resources = ResourceTestRule.builder()
            .addResource(new ExplicitResource(new ExplicitDAO()))
            .build();

    @Test
    public void shouldGetExplicitMessage() {
        // when
        String message = resources.client().target("/explicit/message").request().get(String.class);

        // then
        assertThat(message).isEqualTo("this DAO was bound explicitly");
    }

    @Test
    public void shouldGetJitMessage() {
        // when
        String message = resources.client().target("/explicit/message").request().get(String.class);

        // then
        assertThat(message).isEqualTo("this DAO was bound explicitly");
    }
}

@@ -162,52 +162,168 @@
 ort 
-io.dropwizard.testing.junit.ResourceTestRule
+com.squarespace.jersey2.guice.JerseyGuiceUtils;%0A%0Aimport io.dropwizard.testing.junit.ResourceTestRule;%0A%0Aimport org.junit.AfterClass;%0Aimport org.junit.BeforeClass
 ;%0Aim
@@ -718,16 +718,70 @@
 Test %7B%0A%0A
+    static %7B%0A        JerseyGuiceUtils.reset();%0A    %7D%0A%0A
     @Cla

Make sure this is set up before the test runs