{"action":"created","issue":{"url":"https://api.github.com/repos/HubSpot/dropwizard-guice/issues/61","labels_url":"https://api.github.com/repos/HubSpot/dropwizard-guice/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/HubSpot/dropwizard-guice/issues/61/comments","events_url":"https://api.github.com/repos/HubSpot/dropwizard-guice/issues/61/events","html_url":"https://github.com/HubSpot/dropwizard-guice/issues/61","id":83179045,"number":61,"title":"Instantiating a test configuration instance from a test yaml file.","user":{"login":"patricioe","id":250893,"avatar_url":"https://avatars.githubusercontent.com/u/250893?v=3","gravatar_id":"","url":"https://api.github.com/users/patricioe","html_url":"https://github.com/patricioe","followers_url":"https://api.github.com/users/patricioe/followers","following_url":"https://api.github.com/users/patricioe/following{/other_user}","gists_url":"https://api.github.com/users/patricioe/gists{/gist_id}","starred_url":"https://api.github.com/users/patricioe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patricioe/subscriptions","organizations_url":"https://api.github.com/users/patricioe/orgs","repos_url":"https://api.github.com/users/patricioe/repos","events_url":"https://api.github.com/users/patricioe/events{/privacy}","received_events_url":"https://api.github.com/users/patricioe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-31T20:27:03Z","updated_at":"2015-06-06T11:58:46Z","closed_at":null,"body":"Hi all, I'm having issues instantiating a test configuration instance for my local dev environment.\r\n \r\nafter following the example here: https://github.com/HubSpot/dropwizard-guice/blob/master/src/test/java/com/hubspot/dropwizard/guice/GuiceBundleTest.java\r\n\r\n(in that example the author does a \"new Configuration()\" but I interested in loading the test info located at \"config-test.yml\" instead.\r\n\r\nI wrote this class: \r\n\r\n```\r\n@RunWith(MockitoJUnitRunner.class)\r\npublic class GuiceBundleTest {\r\n    \r\n   Environment environment;\r\n\r\n    private GuiceBundle<Configuration> guiceBundle;\r\n\r\n    @ClassRule\r\n    public static final DropwizardAppRule<APIConfigurationForTest> RULE =\r\n            new DropwizardAppRule<APIConfigurationForTest>(TestApplication.class, ResourceHelpers.resourceFilePath(\"config-test.yml\"));\r\n\r\n    @Before\r\n    public void setUp() {\r\n        environment = RULE.getEnvironment();\r\n        guiceBundle = GuiceBundle.newBuilder()\r\n                .addModule(new TestModule(RULE.getConfiguration()))\r\n                .build();\r\n        Bootstrap bootstrap = mock(Bootstrap.class);\r\n        guiceBundle.initialize(bootstrap);\r\n        guiceBundle.run(RULE.getConfiguration(), environment);\r\n    }\r\n    ....\r\n```\r\n\r\n\r\nand got a:\r\n\r\n```\r\njava.lang.IllegalStateException: Started\r\n\tat org.eclipse.jetty.servlet.BaseHolder.illegalStateIfContextStarted(BaseHolder.java:181)\r\n\tat org.eclipse.jetty.servlet.FilterHolder$Registration.addMappingForUrlPatterns(FilterHolder.java:238)\r\n\tat com.hubspot.dropwizard.guice.JerseyUtil.registerGuiceFilter(JerseyUtil.java:69)\r\n\tat com.hubspot.dropwizard.guice.GuiceBundle.run(GuiceBundle.java:115)\r\n\tat io.codigo.guice.GuiceBundleTest.setUp(GuiceBundleTest.java:55)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)\r\n\tat org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)\r\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\tat org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)\r\n\tat org.junit.rules.RunRules.evaluate(RunRules.java:20)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\tat org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)\r\n\tat org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)\r\n\tat org.junit.runner.JUnitCore.run(JUnitCore.java:137)\r\n\tat com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)\r\n```\r\n\r\nI spend around 2 hours trying to figure this out. If you have any hint on how to get the server to start please let me know.\r\n\r\nThanks\r\n"},"comment":{"url":"https://api.github.com/repos/HubSpot/dropwizard-guice/issues/comments/109571036","html_url":"https://github.com/HubSpot/dropwizard-guice/issues/61#issuecomment-109571036","issue_url":"https://api.github.com/repos/HubSpot/dropwizard-guice/issues/61","id":109571036,"user":{"login":"yunspace","id":218128,"avatar_url":"https://avatars.githubusercontent.com/u/218128?v=3","gravatar_id":"","url":"https://api.github.com/users/yunspace","html_url":"https://github.com/yunspace","followers_url":"https://api.github.com/users/yunspace/followers","following_url":"https://api.github.com/users/yunspace/following{/other_user}","gists_url":"https://api.github.com/users/yunspace/gists{/gist_id}","starred_url":"https://api.github.com/users/yunspace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yunspace/subscriptions","organizations_url":"https://api.github.com/users/yunspace/orgs","repos_url":"https://api.github.com/users/yunspace/repos","events_url":"https://api.github.com/users/yunspace/events{/privacy}","received_events_url":"https://api.github.com/users/yunspace/received_events","type":"User","site_admin":false},"created_at":"2015-06-06T11:58:46Z","updated_at":"2015-06-06T11:58:46Z","body":"Can you clarify what is this `test env` that you are trying to inject? A Hibernate DAO for example only requires `SessionFactory` to be injected. If you want to connect to a test database, that information is configured in your `config.yml` file and, not injected into your DAO.\r\n\r\nI would suggest maybe try:\r\n\r\n1. get your application running first without dependency injection. \r\n2. once you understand your dependencies, add Guice to your applicaiton\r\n3. when all that works, add Guice to your integration tests\r\n"}}