@Test
public void testConstructorExceptionShutdownCE() throws Exception{
HelloworldClientImplCE.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.testConstructorExceptionShutdownCE");
}
// don't need to send a message as eager init ensures that
// the component instance is created at start time
// stop a composite
try {
// not required in this test as the exception during EagerInit will cause the stop
//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.testConstructorExceptionShutdownCE");
}
// uninstall a constribution
node.uninstallContribution("HelloworldContrib");
// stop a Tuscany node
node.stop();
// stop the runtime
tuscanyRuntime.stop();
HelloworldClientImplCE.throwTestExceptionOnConstruction = false;
// see what happened
System.out.println(StatusImpl.statusString);