summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-10-05 18:03:45 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-10-05 18:03:45 +0000
commit22239489fe6807120c4a7073bd8b6b72712138c2 (patch)
treeb6e990fc301d24bcb373acf2787f24a1c8683b15 /sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding
parent4ca27050351a4ac333738843fe39f6a286ed7dc6 (diff)
TUSCANY-3705 - Adding testcase to validate support for JSON-RPC Notifications when using JSON-RPC binding in reference
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1004744 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding')
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java16
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java22
2 files changed, 32 insertions, 6 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
index efdb0a23db..c639d3eef7 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
@@ -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();
+ }
+ }
}
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
index 7c6ba6a99f..8b8d689b0e 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
@@ -42,7 +42,7 @@ import com.meterware.httpunit.WebResponse;
/**
* @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