You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by fm...@apache.org on 2011/07/08 04:23:34 UTC

svn commit: r1144128 - in /tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test: java/helloworld/ java/sample/ java/test/ resources/

Author: fmoga
Date: Fri Jul  8 02:23:33 2011
New Revision: 1144128

URL: http://svn.apache.org/viewvc?rev=1144128&view=rev
Log:
Update sample to demonstrate that runtime uses the same server for services with the same uri.

Added:
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/
      - copied from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java
      - copied, changed from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java
      - copied, changed from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java
      - copied, changed from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite
      - copied, changed from r1144121, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite
Removed:
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloWorldClient.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloWorldImpl.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloWorldService.java
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite
Modified:
    tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java

Added: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java?rev=1144128&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java Fri Jul  8 02:23:33 2011
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package sample;
+
+public class CiaoImpl implements CiaoService {
+
+    public String sayCiao(String name) {
+        return "Ciao " + name;
+    }
+
+}

Added: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java?rev=1144128&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java Fri Jul  8 02:23:33 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CiaoService {
+
+    String sayCiao(String name);
+
+}

Copied: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java (from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java?p2=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java&p1=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java&r1=1143410&r2=1144128&rev=1144128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java (original)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java Fri Jul  8 02:23:33 2011
@@ -17,17 +17,32 @@
  * under the License.    
  */
 
-package helloworld;
+package sample;
 
 import org.oasisopen.sca.annotation.Reference;
 
-public class HelloWorldClient implements HelloWorldService {
+public class Client implements HelloService, SalutService, CiaoService {
 
     @Reference
-    public HelloWorldService  ref;
-    
+    public HelloService hello;
+    @Reference
+    public SalutService salut;
+    @Reference
+    public CiaoService ciao;
+
+    @Override
     public String sayHello(String name) {
-        return ref.sayHello(name);
+        return hello.sayHello(name);
+    }
+
+    @Override
+    public String saySalut(String name) {
+        return salut.saySalut(name);
+    }
+
+    @Override
+    public String sayCiao(String name) {
+        return ciao.sayCiao(name);
     }
 
 }

Copied: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java (from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java?p2=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java&p1=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java&r1=1143410&r2=1144128&rev=1144128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java (original)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java Fri Jul  8 02:23:33 2011
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.    
  */
-package helloworld;
+package sample;
 
 
-public class HelloWorldImpl implements HelloWorldService {
+public class HelloImpl implements HelloService {
 
     public String sayHello(String name) {
         return "Hello " + name;

Copied: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java (from r1143410, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java?p2=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java&p1=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java&r1=1143410&r2=1144128&rev=1144128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java (original)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java Fri Jul  8 02:23:33 2011
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.    
  */
-package helloworld;
+package sample;
 
 import org.oasisopen.sca.annotation.Remotable;
 
 @Remotable
-public interface HelloWorldService {
+public interface HelloService {
 
     String sayHello(String name);
 

Added: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java?rev=1144128&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java Fri Jul  8 02:23:33 2011
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package sample;
+
+public class SalutImpl implements SalutService {
+
+    public String saySalut(String name) {
+        return "Salut " + name;
+    }
+
+}

Added: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java?rev=1144128&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java Fri Jul  8 02:23:33 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface SalutService {
+
+    String saySalut(String name);
+
+}

Modified: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java?rev=1144128&r1=1144127&r2=1144128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java (original)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java Fri Jul  8 02:23:33 2011
@@ -18,7 +18,6 @@
  */
 package test;
 
-import helloworld.HelloWorldService;
 import junit.framework.Assert;
 
 import org.apache.tuscany.sca.node.Node;
@@ -27,21 +26,37 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import sample.CiaoService;
+import sample.HelloService;
+import sample.SalutService;
+
 public class WebsocketBindingTestCase {
 
     private static Node node;
-    
+
+    @Test
+    public void testHello() {
+        HelloService helloClient = node.getService(HelloService.class, "ClientComponent/HelloService");
+        Assert.assertEquals("Hello Tuscany", helloClient.sayHello("Tuscany"));
+    }
+
     @Test
-    public void testSayHello() {
-        HelloWorldService service = node.getService(HelloWorldService.class, "HelloWorldClient/HelloWorldService");
-        Assert.assertEquals("Hello boo", service.sayHello("boo"));
+    public void testSalut() {
+        SalutService salutClient = node.getService(SalutService.class, "ClientComponent/SalutService");
+        Assert.assertEquals("Salut Tuscany", salutClient.saySalut("Tuscany"));
+    }
+
+    @Test
+    public void testCiao() {
+        CiaoService ciaoClient = node.getService(CiaoService.class, "ClientComponent/CiaoService");
+        Assert.assertEquals("Ciao Tuscany", ciaoClient.sayCiao("Tuscany"));
     }
 
     @BeforeClass
     public static void init() throws Exception {
-        node = NodeFactory.newInstance().createNode("helloworld.composite").start();
+        node = NodeFactory.newInstance().createNode("test.composite").start();
     }
-    
+
     @AfterClass
     public static void destroy() throws Exception {
         if (node != null) {

Copied: tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite (from r1144121, tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite?p2=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite&p1=tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite&r1=1144121&r2=1144128&rev=1144128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite (original)
+++ tuscany/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite Fri Jul  8 02:23:33 2011
@@ -22,16 +22,32 @@
            targetNamespace="http://itest"
            name="HelloWorldComposite">
            
-    <component name="HelloWorldComponent">
-        <implementation.java class="helloworld.HelloWorldImpl"/>
-        <service name="HelloWorldService" >
+    <component name="HelloComponent">
+        <implementation.java class="sample.HelloImpl"/>
+        <service name="HelloService" >
             <tuscany:binding.websocket uri="ws://127.0.0.1:5555" />
         </service>
     </component>   
   
-    <component name="HelloWorldClient">
-        <implementation.java class="helloworld.HelloWorldClient"/>
-        <reference name="ref" target="HelloWorldComponent/HelloWorldService" />
+  	<component name="SalutComponent">
+        <implementation.java class="sample.SalutImpl"/>
+        <service name="SalutService" >
+            <tuscany:binding.websocket uri="ws://127.0.0.1:5555" />
+        </service>
+    </component>
+  
+	<component name="CiaoComponent">
+        <implementation.java class="sample.CiaoImpl"/>
+        <service name="CiaoService" >
+            <tuscany:binding.websocket uri="ws://127.0.0.1:6666" />
+        </service>
+    </component>
+  
+    <component name="ClientComponent">
+        <implementation.java class="sample.Client"/>
+        <reference name="hello" target="HelloComponent/HelloService" />
+        <reference name="salut" target="SalutComponent/SalutService" />
+        <reference name="ciao" target="CiaoComponent/CiaoService" />
     </component>   
 
 </composite>