public class ServiceInvocationTestCase extends TestCase {
public void testInvocation() throws InvalidServiceContractException {
AbstractApplicationContext springContext = createSpringContext();
SpringCompositeComponent composite = new SpringCompositeComponent("parent", springContext, null, null, null);
InboundWire inboundWire = ArtifactFactory.createInboundWire("fooService", TestBean.class);
OutboundWire outboundWire = ArtifactFactory.createOutboundWire("fooService", TestBean.class);
outboundWire.setTargetName(new QualifiedName("foo"));
ArtifactFactory.terminateWire(outboundWire);
Service service =
new ServiceExtension("fooService", TestBean.class, composite, createWireService());
service.setInboundWire(inboundWire);
service.setOutboundWire(outboundWire);
Connector connector = ArtifactFactory.createConnector();
connector.connect(inboundWire, outboundWire, true);
for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
chain.setTargetInvoker(composite.createTargetInvoker("foo", chain.getOperation()));
}
composite.register(service);
TestBean serviceInstance = (TestBean) composite.getService("fooService").getServiceInstance();
assertEquals("bar", serviceInstance.echo("bar"));