@Test public void reset_shouldRebindScope() throws Exception { //GIVEN ScopeImpl scope = new ScopeImpl("root"); //WHEN scope.reset(); //THEN assertThat(scope.getInstance(Scope.class), notNullValue()); }
/** * Clears all scopes. Useful for testing and not getting any leak... */ public static void reset() { MAP_KEY_TO_SCOPE.clear(); ScopeImpl.reset(); }
@Test(expected = NoFactoryFoundException.class) public void reset_shouldResetBoundProviders_andFlagTheTestModuleToFalse() throws Exception { //GIVEN ScopeImpl scope = new ScopeImpl("root"); scope.installTestModules(new Module() { { bind(IFoo.class).to(Foo.class); } }); //WHEN scope.reset(); //THEN scope.installTestModules(); // Should not crash scope.getInstance(IFoo.class); // Should crash as we don't have the binding for IFoo anymore }