You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2010/10/05 20:03:46 UTC

svn commit: r1004744 - in /tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java: echo/ org/apache/tuscany/sca/binding/jsonrpc/

Author: lresende
Date: Tue Oct  5 18:03:45 2010
New Revision: 1004744

URL: http://svn.apache.org/viewvc?rev=1004744&view=rev
Log:
TUSCANY-3705 - Adding testcase to validate support for JSON-RPC Notifications when using JSON-RPC binding in reference

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java?rev=1004744&r1=1004743&r2=1004744&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java Tue Oct  5 18:03:45 2010
@@ -39,7 +39,9 @@ import bean.TestBean;
 public interface Echo {
 
     String echo(String msg);
-
+    
+    void echoVoid();
+    
     void echoRuntimeException() throws RuntimeException;
 
     void echoBusinessException() throws EchoBusinessException;

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java?rev=1004744&r1=1004743&r2=1004744&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java Tue Oct  5 18:03:45 2010
@@ -38,6 +38,10 @@ public class EchoClientImpl implements E
     public String echo(String msg) {
         return echoReference.echo(msg);
     }
+    
+    public void echoVoid() {
+        echoReference.echoVoid();
+    }
 
     public int[] echoArrayInt(int[] intArray) {
         throw new UnsupportedOperationException("UNsupported !");
@@ -90,5 +94,4 @@ public class EchoClientImpl implements E
     public BigDecimal echoBigDecimal(BigDecimal param) {
         throw new UnsupportedOperationException("UNsupported !");
     }
-
 }

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java?rev=1004744&r1=1004743&r2=1004744&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java Tue Oct  5 18:03:45 2010
@@ -41,6 +41,11 @@ public class EchoComponentImpl implement
         return "echo: " + msg;
     }
 
+    
+    public void echoVoid() {
+        System.out.println("Echo: VOID");
+    }
+
     public void echoBusinessException() throws EchoBusinessException {
         throw new EchoBusinessException("Business Exception");
 

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java?rev=1004744&r1=1004743&r2=1004744&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java Tue Oct  5 18:03:45 2010
@@ -67,4 +67,20 @@ public class JSONRPCReferenceTestCase {
             node.stop();
         }
     }
+
+    @Test
+    public void testInvokeReferenceVoidOperation() throws Exception {
+        Node node = null;
+
+        String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCReferenceTestCase.class);
+        node = NodeFactory.newInstance().createNode("JSONRPCReference.composite", new Contribution("testClient", contribution));
+        node.start();
+
+        Echo echoComponent = node.getService(Echo.class,"EchoComponentWithReference");
+        echoComponent.echoVoid();
+
+        if (node != null) {
+            node.stop();
+        }
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java?rev=1004744&r1=1004743&r2=1004744&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java Tue Oct  5 18:03:45 2010
@@ -42,7 +42,7 @@ import com.meterware.httpunit.WebRespons
 /**
  * @version $Rev$ $Date$
  */
-public class JSONRPCServiceTestCase{
+public class JSONRPCServiceTestCase {
 
     private static final String SERVICE_PATH = "/EchoService";
 
@@ -67,7 +67,7 @@ public class JSONRPCServiceTestCase{
     }
 
     @Test
-    public void testJSONRPCBinding() throws Exception {
+    public void testEchoWithJSONRPCBinding() throws Exception {
         JSONObject jsonRequest = new JSONObject("{ \"method\": \"echo\", \"params\": [\"Hello JSON-RPC\"], \"id\": 1}");
 
         WebConversation wc = new WebConversation();
@@ -79,7 +79,7 @@ public class JSONRPCServiceTestCase{
         JSONObject jsonResp = new JSONObject(response.getText());
         Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
     }
-    
+
     @Test
     public void testJSONRPCBindingGET() throws Exception {
         String params = Base64.encode("[\"Hello JSON-RPC\"]".getBytes());
@@ -95,7 +95,17 @@ public class JSONRPCServiceTestCase{
         Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
     }
     
-    
-    
-    
+    @Test
+    public void testEchoVoidWithJSONRPCBinding() throws Exception {
+        JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoVoid\", \"params\": [], \"id\": 1}");
+
+        WebConversation wc = new WebConversation();
+        WebRequest request   = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
+        WebResponse response = wc.getResource(request);
+
+        Assert.assertEquals(200, response.getResponseCode());
+        
+        JSONObject jsonResp = new JSONObject(response.getText());
+        Assert.assertEquals(0, jsonResp.getString("result").length());
+    }
 }
\ No newline at end of file