private static Node serviceNode;
private static Node clientNode;
@Test
public void testCalculator() throws Exception {
NodeFactory factory = NodeFactory.newInstance();
serviceNode = factory.createNode(new Contribution("service", getJar("../helloworld-service/target")));
serviceNode.start();
clientNode = factory.createNode(new Contribution("client", getJar("../helloworld-client/target")));
clientNode.start();
Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
serviceNode.stop();
client = clientNode.getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
try {
client.sayHello("Petra");
fail();
} catch (Exception e) {
// expected
// TODO: better exception than NPE
}
serviceNode = factory.createNode(new Contribution("service", getJar("../helloworld-service/target")));
serviceNode.start();
client = clientNode.getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));