return ShrinkWrap.create(BeanArchive.class).addPackage(SessionBeanInterceptorTest.class.getPackage());
}
@Test
public void testSessionBeanInterceptor(final BeanManager manager) throws Throwable {
final SessionBeanInterceptor interceptor = new SessionBeanInterceptor();
final AtomicReference<Object> result = new AtomicReference<Object>();
// ctx.proceed() returns true if and only if the request scope is active
final InvocationContext ctx = new DummyInvocationContext() {
@Override
public Object proceed() throws Exception {
return manager.getContext(RequestScoped.class).isActive();
}
};
// spawn a new thread an run the interceptor in it to verify that the interceptor properly starts the request context
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
result.set(interceptor.aroundInvoke(ctx));
} catch (Exception e) {
result.set(e);
}
}
});