diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org')
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 |