summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/testing/itest/lifecycle/src/test
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-05-26 11:09:54 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-05-26 11:09:54 +0000
commit77be27896a4e45c3e1eb3c6e94231327b39eb5e8 (patch)
tree69582723f2387d036bea35ce07696285e46e25b4 /sca-java-2.x/trunk/testing/itest/lifecycle/src/test
parentff3f060f0668d9eb49a5525cac5fc439449eca77 (diff)
Add a test implementation provider and extend the test case to cover init and destroy exceptions
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127870 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest/lifecycle/src/test')
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java151
1 files changed, 149 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java
index 4342dd63bd..dbffc8ce8c 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java
@@ -20,6 +20,8 @@
package org.apache.tuscany.sca.itest.lifecycle;
+import helloworld.Helloworld;
+import helloworld.HelloworldClientImpl;
import helloworld.StatusImpl;
import junit.framework.Assert;
@@ -46,7 +48,7 @@ public class LifecycleTestCase {
}
@Test
- public void test1() throws Exception{
+ public void testNormalShutdown() throws Exception{
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
@@ -74,13 +76,158 @@ public class LifecycleTestCase {
// see what happened
System.out.println(StatusImpl.statusString);
Assert.assertEquals("Service binding start " +
+ "Implementation start " +
+ "Service binding start " +
"HelloworldClientImpl init " +
"Reference binding start " +
"Service binding stop " +
+ "Service binding stop " +
+ "Implementation stop " +
"Reference binding stop " +
"HelloworldClientImpl destroy ",
StatusImpl.statusString);
-
}
+ @Test
+ public void testInitExceptionShutdown() throws Exception{
+
+ HelloworldClientImpl.throwTestExceptionOnInit = 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
+ }
+
+ // stop a composite
+ node.stopComposite("HelloworldContrib", "lifecycle.composite");
+
+ // uninstall a constribution
+ node.uninstallContribution("HelloworldContrib");
+
+ // stop a Tuscany node
+ node.stop();
+
+ // stop the runtime
+ tuscanyRuntime.stop();
+
+ // see what happened
+ System.out.println(StatusImpl.statusString);
+ Assert.assertEquals("Service binding start " +
+ "Implementation start " +
+ "Service binding start " +
+ "HelloworldClientImpl init " +
+ "Reference binding start " +
+ "Service binding stop " +
+ "Service binding stop " +
+ "Implementation stop " +
+ "Reference binding stop " +
+ "HelloworldClientImpl destroy ",
+ StatusImpl.statusString);
+
+ HelloworldClientImpl.throwTestExceptionOnInit = false;
+ }
+
+ @Test
+ public void testDestroyExceptionShutdown() throws Exception{
+
+ HelloworldClientImpl.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
+ node.startComposite("HelloworldContrib", "lifecycle.composite");
+
+ // stop a composite
+ node.stopComposite("HelloworldContrib", "lifecycle.composite");
+
+ // uninstall a constribution
+ node.uninstallContribution("HelloworldContrib");
+
+ // stop a Tuscany node
+ node.stop();
+
+ // stop the runtime
+ tuscanyRuntime.stop();
+
+ // see what happened
+ System.out.println(StatusImpl.statusString);
+ Assert.assertEquals("Service binding start " +
+ "Implementation start " +
+ "Service binding start " +
+ "HelloworldClientImpl init " +
+ "Reference binding start " +
+ "Service binding stop " +
+ "Service binding stop " +
+ "Implementation stop " +
+ "Reference binding stop " +
+ "HelloworldClientImpl destroy ",
+ StatusImpl.statusString);
+
+ HelloworldClientImpl.throwTestExceptionOnDestroy = false;
+ }
+
+ @Test
+ public void testAppExceptionShutdown() throws Exception{
+
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+
+ // create a Tuscany node
+ node = tuscanyRuntime.createNode();
+
+ // install a contribution
+ node.installContribution("HelloworldContrib", "target/classes", null, null);
+
+ // start a composite
+ node.startComposite("HelloworldContrib", "lifecycle.composite");
+
+ try {
+ Helloworld hw = node.getService(Helloworld.class, "Helloworld1");
+ hw.throwException("name");
+ } catch (Exception ex) {
+ // do nothing
+ }
+
+ // stop a composite
+ node.stopComposite("HelloworldContrib", "lifecycle.composite");
+
+ // uninstall a constribution
+ node.uninstallContribution("HelloworldContrib");
+
+ // stop a Tuscany node
+ node.stop();
+
+ // stop the runtime
+ tuscanyRuntime.stop();
+
+ // see what happened
+ System.out.println(StatusImpl.statusString);
+ Assert.assertEquals("Service binding start " +
+ "Implementation start " +
+ "Service binding start " +
+ "HelloworldClientImpl init " +
+ "Reference binding start " +
+ "Service binding stop " +
+ "Service binding stop " +
+ "Implementation stop " +
+ "Reference binding stop " +
+ "HelloworldClientImpl destroy ",
+ StatusImpl.statusString);
+ }
+
}