// Force the remote default binding to be web services
System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
"{http://docs.oasis-open.org/ns/opencsa/sca/200912}binding.ws");
String [] contributions = {"./target/classes"};
Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
"org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedClient.composite",
contributions);
node1.start();
Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
"org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite",
contributions);
// force default binding on node2 to use a different port from node 1(which will default to 8080
((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");
node2.start();
ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
ParameterObject po = new ParameterObject();
try {
String response = local.foo1(po);
Assert.assertEquals("AComponent", response);
} catch (ServiceRuntimeException ex){
Assert.fail("Unexpected exception with foo " + ex.toString());
}
try {
local.callback("Callback");
String response = local.getCallbackValue();
Assert.assertEquals("Callback", response);
} catch (ServiceRuntimeException ex){
Assert.fail("Unexpected exception with callback" + ex.toString());
}
node1.stop();
node2.stop();
}