// first session
Object session = new Object();
Object id = new Object();
testCtx.publish(new RequestStart(this,id));
testCtx.publish(new HttpSessionBound(this,session));
GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
Assert.assertNotNull(source);
GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
Assert.assertNotNull(target);
source.getGenericComponent().setString("foo");
Assert.assertEquals("foo",target.getString());
testCtx.publish(new RequestEnd(this,new Object()));
//second request for session
Object id2 = new Object();
testCtx.publish(new RequestStart(this,id2));
testCtx.publish(new HttpSessionBound(this,session));
GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
Assert.assertEquals("foo",targetR2.getString());
GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
Assert.assertNotNull(sourceR2);
Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
testCtx.publish(new RequestEnd(this,new Object()));
//second session
Object session2 = new Object();
Object id3 = new Object();
testCtx.publish(new RequestStart(this,id3));
testCtx.publish(new HttpSessionBound(this,session2));
GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
Assert.assertNotNull(source2);
GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
Assert.assertNotNull(target2);
Assert.assertEquals(null,target2.getString());
Assert.assertEquals(null,source2.getGenericComponent().getString());
source2.getGenericComponent().setString("baz");
Assert.assertEquals("baz",source2.getGenericComponent().getString());
Assert.assertEquals("baz",target2.getString());
testCtx.publish(new RequestEnd(this,session2));
Object id4 = new Object();
testCtx.publish(new RequestStart(this,id4));
testCtx.publish(new HttpSessionBound(this,session));