HubSpot/dropwizard-guice

Properly reset ServiceLocatorGenerator / RuntimeDelegate in a test environment

Opened this issue · 1 comments

I had problems using the DropwizardAppRule together with a legacy embedded Jersey Server not using Dropwizard, running in the same JVM for our tests.

The dropwizard-guice module overrides the ServiceLocatorGenerator and RuntimeDelegate in BootstrapUtils.install without ever resetting them, breaking our legacy Jersey server when it wants to boot up (saying that the ServiceLocatorImpl "has been shut down").

This can be fixed manually by enhancing the DropwizardAppRule with

BootstrapUtils.reset();

after the Rule has shutdown.

Unfortunately I couldn't find any references to BootstrapUtils.reset() in the dropwizard-guice code. Maybe there's a way to call that generally when the Jersey server is shutting down or at least in the test environment enhancing the DropwizardAppRule (prolly by providing an own test-rule).

Yes this workaround was mentioned in #45 and @oillio added BootstrapUtils.reset() into the GuiceBundleTest: oillio@611a334

This should be documented into the README... along with the rest of the updated 0.8.0 information ...