* @version $$Rev: 451895 $$ $$Date: 2006-10-01 23:58:18 -0700 (Sun, 01 Oct 2006) $$
*/
public class HttpSessionScopeRestartTestCase extends TestCase {
public void testRestart() throws Exception {
WorkContext ctx = new WorkContextImpl();
HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx);
scope.start();
MethodEventInvoker<Object> initInvoker = new MethodEventInvoker<Object>(
HttpSessionScopeRestartTestCase.InitDestroyOnce.class.getMethod("init"));
MethodEventInvoker<Object> destroyInvoker =
new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("destroy"));
PojoConfiguration configuration = new PojoConfiguration();
configuration.setScopeContainer(scope);
configuration.addServiceInterface(HttpSessionScopeRestartTestCase.InitDestroyOnce.class);
configuration.setInitInvoker(initInvoker);
configuration.setDestroyInvoker(destroyInvoker);
Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
configuration.setInstanceFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
SystemAtomicComponent context = new SystemAtomicComponentImpl("InitDestroy", configuration);
context.start();
Object session = new Object();
ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
scope.onEvent(new HttpSessionStart(this, session));
Object instance = context.getServiceInstance();
assertSame(instance, context.getServiceInstance());
scope.onEvent(new HttpSessionEnd(this, session));