summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-05-27 15:13:50 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-05-27 15:13:50 +0000
commitfcc065b22a21e117c0a9636bea5292a4fb2d2822 (patch)
tree4e60281e34c0e8bbac6e208b4f39b6090852d896 /sca-java-2.x/trunk
parenta15f7d0991567a8b5e7dbee8f5d5fa82e92d247e (diff)
TUSCANY-3867 - Update the status reporting so that I can see what components the events are related to
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1128352 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java8
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java8
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java8
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java4
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java4
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite2
-rw-r--r--sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java151
7 files changed, 129 insertions, 56 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
index 5709de7747..5c2ca0bf77 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
@@ -22,6 +22,8 @@ package binding.lifecycle;
import helloworld.StatusImpl;
import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
+import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -41,11 +43,13 @@ public class LifecycleReferenceBindingProvider implements ReferenceBindingProvid
}
public void start() {
- StatusImpl.statusString += "Reference binding start ";
+ StatusImpl.appendStatus("Reference binding start",
+ ((EndpointReferenceImpl)endpoint).toStringWithoutHash());
}
public void stop() {
- StatusImpl.statusString += "Reference binding stop ";
+ StatusImpl.appendStatus("Reference binding stop",
+ ((EndpointReferenceImpl)endpoint).toStringWithoutHash());
}
public InterfaceContract getBindingInterfaceContract() {
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
index 0f62e13aed..158aa27201 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
@@ -20,6 +20,8 @@
package binding.lifecycle;
import helloworld.StatusImpl;
+
+import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
@@ -34,11 +36,13 @@ public class LifecycleServiceBindingProvider implements ServiceBindingProvider {
}
public void start() {
- StatusImpl.statusString += "Service binding start ";
+ StatusImpl.appendStatus("Service binding start",
+ ((EndpointImpl)endpoint).toStringWithoutHash());
}
public void stop() {
- StatusImpl.statusString += "Service binding stop ";
+ StatusImpl.appendStatus("Service binding stop",
+ ((EndpointImpl)endpoint).toStringWithoutHash());
}
public InterfaceContract getBindingInterfaceContract() {
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
index 9328b53bac..d8a56eacde 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
@@ -39,22 +39,22 @@ public class HelloworldClientImpl implements Helloworld {
@Init
public void initialize() throws Exception{
if (throwTestExceptionOnInit) {
- StatusImpl.statusString += "Exception on init ";
+ StatusImpl.appendStatus("Exception on init", "HelloworldClientImpl");
throw new Exception("Exception on init");
}
- StatusImpl.statusString += "HelloworldClientImpl init ";
+ StatusImpl.appendStatus("Init", "HelloworldClientImpl");
System.out.println(">>>>>> " + sayHello("init"));
}
@Destroy
public void destroy() throws Exception{
if (throwTestExceptionOnDestroy) {
- StatusImpl.statusString += "Exception on destroy ";
+ StatusImpl.appendStatus("Exception on destroy", "HelloworldClientImpl");
throw new Exception("Exception on destroy");
}
- StatusImpl.statusString += "HelloworldClientImpl destroy ";
+ StatusImpl.appendStatus("Destroy", "HelloworldClientImpl");
}
public String sayHello(String name) throws Exception {
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
index a18633ca74..2932da1554 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
@@ -22,5 +22,9 @@ package helloworld;
public class StatusImpl {
public static String statusString = "";
+
+ public static void appendStatus(String event, String location){
+ statusString += event + " - " + location + "\n";
+ }
}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
index c06346d8d3..f1e303882f 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
@@ -56,11 +56,11 @@ class LifecycleProvider implements ImplementationProvider {
}
public void start() {
- StatusImpl.statusString += "Implementation start ";
+ StatusImpl.appendStatus("Implementation start", comp.getName());
}
public void stop() {
- StatusImpl.statusString += "Implementation stop ";
+ StatusImpl.appendStatus("Implementation stop", comp.getName());
}
public boolean supportsOneWayInvocation() {
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
index 2c48cc4bf9..c959749c03 100644
--- a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
+++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
@@ -20,7 +20,7 @@
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://sample"
- name="domainview">
+ name="lifecycle">
<component name="HelloworldService1">
<implementation.java class="helloworld.HelloworldServiceImpl"/>
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 dbffc8ce8c..01180b86bb 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
@@ -39,7 +39,7 @@ public class LifecycleTestCase {
@Before
public void setUp() throws Exception {
-
+ StatusImpl.statusString = "";
}
@After
@@ -48,7 +48,9 @@ public class LifecycleTestCase {
}
@Test
- public void testNormalShutdown() throws Exception{
+ public void testNormalShutdownNoMessage() throws Exception{
+
+ StatusImpl.statusString = "";
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
@@ -75,20 +77,68 @@ 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 ",
+ Assert.assertEquals("Service binding start - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation start - HelloworldService2\n" +
+ "Service binding start - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Init - HelloworldClientImpl\n" +
+ "Reference binding start - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation stop - HelloworldService2\n" +
+ "Reference binding stop - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Destroy - HelloworldClientImpl\n",
StatusImpl.statusString);
}
@Test
+ public void testNormalShutdownAfterMessage() 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");
+
+ // send a message
+ Helloworld hw = node.getService(Helloworld.class, "HelloworldService1");
+ System.out.println(hw.sayHello("name"));
+
+ // 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 - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation start - HelloworldService2\n" +
+ "Service binding start - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Init - HelloworldClientImpl\n" +
+ "Reference binding start - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ /*extra ref start for getService reference*/
+ "Reference binding start - EndpointReference: URI = HelloworldService1#reference-binding($self$.Helloworld/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation stop - HelloworldService2\n" +
+ "Reference binding stop - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ /*$self$ reference is not stopped */
+ "Destroy - HelloworldClientImpl\n",
+ StatusImpl.statusString);
+ }
+
+ @Test
public void testInitExceptionShutdown() throws Exception{
HelloworldClientImpl.throwTestExceptionOnInit = true;
@@ -109,7 +159,11 @@ public class LifecycleTestCase {
}
// stop a composite
- node.stopComposite("HelloworldContrib", "lifecycle.composite");
+ try {
+ node.stopComposite("HelloworldContrib", "lifecycle.composite");
+ } catch (Exception exception) {
+ // it will complain about the composite not being started
+ }
// uninstall a constribution
node.uninstallContribution("HelloworldContrib");
@@ -122,16 +176,15 @@ 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 ",
+ Assert.assertEquals("Service binding start - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation start - HelloworldService2\n" +
+ "Service binding start - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Exception on init - HelloworldClientImpl\n" +
+ /* is it right that the destroy happens directly?*/
+ "Destroy - HelloworldClientImpl\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation stop - HelloworldService2\n",
StatusImpl.statusString);
HelloworldClientImpl.throwTestExceptionOnInit = false;
@@ -151,10 +204,18 @@ public class LifecycleTestCase {
node.installContribution("HelloworldContrib", "target/classes", null, null);
// start a composite
- node.startComposite("HelloworldContrib", "lifecycle.composite");
+ try {
+ node.startComposite("HelloworldContrib", "lifecycle.composite");
+ } catch (Exception exception) {
+ // it's thrown from the HelloworldClientImpl @Destroy method
+ }
// stop a composite
- node.stopComposite("HelloworldContrib", "lifecycle.composite");
+ try {
+ node.stopComposite("HelloworldContrib", "lifecycle.composite");
+ } catch (Exception exception) {
+ // it will complain about the composite not being started
+ }
// uninstall a constribution
node.uninstallContribution("HelloworldContrib");
@@ -167,16 +228,16 @@ 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 ",
+ Assert.assertEquals("Service binding start - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation start - HelloworldService2\n" +
+ "Service binding start - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Init - HelloworldClientImpl\n" +
+ "Reference binding start - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation stop - HelloworldService2\n" +
+ "Reference binding stop - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Exception on destroy - HelloworldClientImpl\n",
StatusImpl.statusString);
HelloworldClientImpl.throwTestExceptionOnDestroy = false;
@@ -217,16 +278,16 @@ 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 ",
+ Assert.assertEquals("Service binding start - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation start - HelloworldService2\n" +
+ "Service binding start - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Init - HelloworldClientImpl\n" +
+ "Reference binding start - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Service binding stop - Endpoint: URI = HelloworldService2#service-binding(Helloworld/lifecycle)\n" +
+ "Implementation stop - HelloworldService2\n" +
+ "Reference binding stop - EndpointReference: URI = HelloworldClient#reference-binding(service/lifecycle) WIRED_TARGET_FOUND_AND_MATCHED Target = Endpoint: URI = HelloworldService1#service-binding(Helloworld/lifecycle)\n" +
+ "Destroy - HelloworldClientImpl\n",
StatusImpl.statusString);
}