@Test
public void testDestroyExceptionShutdownC() throws Exception{
HelloworldClientImplC.throwTestExceptionOnDestroy = 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 @Destroy method
StatusImpl.appendStatus("Exception caught on node.startComposite", "LifecycleTestCase.testDestroyExceptionShutdownC");
}
// send a message to the appropriate client
Helloworld hwCE = node.getService(Helloworld.class, "HelloworldClientC");
System.out.println(hwCE.sayHello("name"));
// don't need to catch exception here as the component instance won't
// be destroyed until shutdown
// 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.testDestroyExceptionShutdownC");
}
// uninstall a constribution
node.uninstallContribution("HelloworldContrib");
// stop a Tuscany node
node.stop();
// stop the runtime
tuscanyRuntime.stop();
HelloworldClientImplC.throwTestExceptionOnDestroy = false;
// see what happened
System.out.println(StatusImpl.statusString);