tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1128352 - in /tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src: main/java/binding/lifecycle/ main/java/helloworld/ main/java/implementation/lifecycle/ main/resources/ test/java/org/apache/tuscany/sca/itest/lifecycle/
Date Fri, 27 May 2011 15:13:50 GMT
Author: slaws
Date: Fri May 27 15:13:50 2011
New Revision: 1128352

URL: http://svn.apache.org/viewvc?rev=1128352&view=rev
Log:
TUSCANY-3867 - Update the status reporting so that I can see what components the events are
related to

Modified:
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
    tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java
Fri May 27 15:13:50 2011
@@ -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 LifecycleReferenceBindingPr
     }
 
     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() {

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java
Fri May 27 15:13:50 2011
@@ -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 LifecycleServiceBindingProv
     }
 
     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() {

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java
Fri May 27 15:13:50 2011
@@ -39,22 +39,22 @@ public class HelloworldClientImpl implem
     @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 {

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java
Fri May 27 15:13:50 2011
@@ -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";
+    }
 
 }

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/implementation/lifecycle/LifecycleProvider.java
Fri May 27 15:13:50 2011
@@ -56,11 +56,11 @@ class LifecycleProvider implements Imple
     }
 
     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() {

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite
Fri May 27 15:13:50 2011
@@ -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"/>

Modified: tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java?rev=1128352&r1=1128351&r2=1128352&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java
Fri May 27 15:13:50 2011
@@ -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);
     }    
     



Mime
View raw message