public void testModuleToSession() throws Exception{
RuntimeContext runtime = MockFactory.createJavaRuntime();
Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
Assert.assertNotNull(ctx);
runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
Assert.assertNotNull(testCtx);
testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.SESSION));
testCtx.publish(new ModuleStart(this));
// 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,id));
//second session
Object session2 = new Object();
Object id2 = new Object();
testCtx.publish(new RequestStart(this,id2));
testCtx.publish(new HttpSessionBound(this,session2));
GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
Assert.assertNotNull(target2);
Assert.assertTrue(!"foo".equals(target2.getString()));
Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
source.getGenericComponent().setString("bar");