Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
sessionScope, members, "target", Target.class, TargetImpl.class, requestScope);
Object session1 = new Object();
ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
sessionScope.onEvent(new HttpSessionStart(this, session1));
requestScope.onEvent(new RequestStart(this));
AtomicComponent sourceComponent = contexts.get("source");
final AtomicComponent targetComponent = contexts.get("target");
final 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));
Target target2 = (Target) targetComponent.getServiceInstance();
assertFalse("foo".equals(target2.getString()));
assertFalse("foo".equals(source.getTarget().getString()));
source.getTarget().setString("bar");
assertEquals("bar", target2.getString());