diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java')
2 files changed, 31 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java index 5a7aaecaf1..a96f8ebb03 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java @@ -73,7 +73,7 @@ public class EchoServiceTestCase { } @Test - public void testJSONRPCGetOperation() throws Exception { + public void testJSONRPCGetOperationWithString() throws Exception { String queryString = "?method=echo&msg=Hello RPC"; WebConversation wc = new WebConversation(); @@ -86,7 +86,20 @@ public class EchoServiceTestCase { } @Test - public void testRPCGetArrayOperation() throws Exception { + public void testJSONRPCGetOperationWithInt() throws Exception { + String queryString = "?method=echoInt¶m=1000"; + + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest(SERVICE_URL_JSON + queryString); + request.setHeaderField("Content-Type", "application/json"); + WebResponse response = wc.getResource(request); + + Assert.assertEquals(200, response.getResponseCode()); + Assert.assertEquals("1000", response.getText()); + } + + @Test + public void testRPCGetArrayOperationWithString() throws Exception { String queryString = "?method=echoArrayString&msgArray=Hello RPC1&msgArray=Hello RPC2"; WebConversation wc = new WebConversation(); @@ -98,6 +111,19 @@ public class EchoServiceTestCase { Assert.assertEquals("[\"Hello RPC1\",\"Hello RPC2\"]", response.getText()); } + @Test + public void testRPCGetArrayOperationWithInt() throws Exception { + String queryString = "?method=echoArrayInt&intArray=1000&intArray=2000"; + + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest(SERVICE_URL_JSON + queryString); + request.setHeaderField("Content-Type", "application/json"); + WebResponse response = wc.getResource(request); + + Assert.assertEquals(200, response.getResponseCode()); + Assert.assertEquals("[1000,2000]", response.getText()); + } + @Test public void testXMLRPCGetOperation() throws Exception { @@ -108,8 +134,8 @@ public class EchoServiceTestCase { request.setHeaderField("Content-Type", "application/xml"); WebResponse response = wc.getResource(request); - System.out.println("Expected>>" + XML_RESPONSE); - System.out.println("Received>>" + response.getText()); + //System.out.println("Expected>>" + XML_RESPONSE); + //System.out.println("Received>>" + response.getText()); Assert.assertEquals(200, response.getResponseCode()); Assert.assertEquals(XML_RESPONSE, response.getText()); diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java index 8664162ffb..b93ff0838b 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java @@ -36,6 +36,6 @@ public interface Echo { String [] echoArrayString(@QueryParam("msgArray") String[] stringArray); - int [] echoArrayInt(int[] intArray); + int [] echoArrayInt(@QueryParam("intArray") int[] intArray); } |