EventContext ctx = new EventContextImpl();
ModuleScopeContext scope = new ModuleScopeContext(ctx);
scope.registerFactories(createEagerInitComponents());
scope.start();
scope.onEvent(new ModuleStart(this));
ModuleScopeEagerInitDestroyComponent initDestroy = (ModuleScopeEagerInitDestroyComponent) scope.getContext(
"TestServiceEagerInitDestroy").getInstance(null);
Assert.assertNotNull(initDestroy);
ModuleScopeEagerInitComponent initOnly = (ModuleScopeEagerInitComponent) scope
.getContext("TestServiceEagerInit").getInstance(null);
Assert.assertNotNull(initOnly);
Assert.assertTrue(initDestroy.isInitialized());
Assert.assertTrue(initOnly.isInitialized());
Assert.assertFalse(initDestroy.isDestroyed());
// expire module
scope.onEvent(new ModuleStop(this));
Assert.assertTrue(initDestroy.isDestroyed());
scope.stop();
}