ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
sessionScope.onEvent(new HttpSessionStart(this, session1));
Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
requestScope, members, "target", Target.class, TargetImpl.class, sessionScope);
final AtomicComponent sourceComponent = contexts.get("source");
final AtomicComponent targetComponent = contexts.get("target");
requestScope.onEvent(new RequestStart(this));
Source source = (Source) sourceComponent.getServiceInstance();
Target target = (Target) targetComponent.getServiceInstance();
assertNull(source.getTarget().getString());
assertNull(target.getString());
target.setString("foo");
assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
assertEquals("foo", source.getTarget().getString());
// spin off another request
Executor executor = Executors.newSingleThreadExecutor();
FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
public void run() {
requestScope.onEvent(new RequestStart(this));
Source source2 = (Source) sourceComponent.getServiceInstance();
Target target2 = (Target) targetComponent.getServiceInstance();
assertEquals("foo", target2.getString());
assertEquals("foo", source2.getTarget().getString());
source2.getTarget().setString("bar");
assertEquals("bar", target2.getString());
assertEquals("bar", source2.getTarget().getString());