@Test
public void testConstructorExceptionShutdownC() throws Exception{
HelloworldClientImplC.throwTestExceptionOnConstruction = true;
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
// create a Tuscany node
node = tuscanyRuntime.createNode();
// install a contribution
node.installContribution("HelloworldContrib", "target/classes", null, null);
// start a composite
try {
node.startComposite("HelloworldContrib", "lifecycle.composite");
} catch (Exception exception) {
// it's thrown from the HelloworldClientImpl @Init method
StatusImpl.appendStatus("Exception caught on node.startComposite", "LifecycleTestCase.testConstructorExceptionShutdownC");
}
// send a message to the appropriate client
try {
Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientC");
System.out.println(hwCE.sayHello("name"));
} catch (Exception exception) {
// the component throws an error on construction
StatusImpl.appendStatus("Exception caught on sayHello()", "LifecycleTestCase.testConstructorExceptionShutdownC");
}
// stop a composite
try {
node.stopComposite("HelloworldContrib", "lifecycle.composite");
} catch (Exception exception) {
// it will complain about the composite not being started
StatusImpl.appendStatus("Exception caught on node.stopComposite", "LifecycleTestCase.testConstructorExceptionShutdownC");
}
// uninstall a constribution
node.uninstallContribution("HelloworldContrib");
// stop a Tuscany node
node.stop();
// stop the runtime
tuscanyRuntime.stop();
HelloworldClientImplC.throwTestExceptionOnConstruction = false;
// see what happened
System.out.println(StatusImpl.statusString);