JavaServiceContract inter = factory.createJavaServiceContract();
inter.setInterface(ModuleScopeSystemComponentImpl.class);
service.setServiceContract(inter);
ep.getConfiguredReference().getTargetConfiguredServices().get(0).setPort(service);
system.registerModelObject(ep);
system.publish(new ModuleStart(this));
Assert.assertNotNull(system.getContext("TestService1").getInstance(null));
Assert.assertNotNull(system.getContext("TestService2EP").getInstance(null));
Assert.assertNotNull(((AutowireContext) system).resolveInstance(ModuleScopeSystemComponent.class));
// create a test module
Component moduleComponent = MockFactory.createCompositeComponent("test.module");
runtime.registerModelObject(moduleComponent);
CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("test.module");
Assert.assertNotNull(moduleContext);
ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
moduleContext.registerModelObject(es);
moduleContext.publish(new ModuleStart(this));
Assert.assertNotNull(moduleContext.getContext("TestService2ES").getInstance(null));
moduleContext.publish(new ModuleStop(this));
system.publish(new ModuleStop(this));
runtime.stop();