summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-08-29 03:19:47 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-08-29 03:19:47 +0000
commit9d627fbdaa4ae300843644dfbae874457b3731e2 (patch)
tree59905e361362ed5d652302cfdb8352658556a923 /java
parent7eba053f89f8d5d368d3ea48e89b48ff9585288c (diff)
TUSCANY-2565 - Fixing issues when passing array parameter using json-rpc binding
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@690089 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java4
-rw-r--r--java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java6
-rw-r--r--java/sca/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java30
-rw-r--r--java/sca/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer1
4 files changed, 33 insertions, 8 deletions
diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java b/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
index 3017861b99..ba87f22cf6 100644
--- a/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
+++ b/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
@@ -53,7 +53,9 @@ public interface Echo {
List echoList(ArrayList list);
- String [] echoArray(String[] stringArray);
+ String [] echoArrayString(String[] stringArray);
+
+ int [] echoArrayInt(int[] intArray);
Set echoSet(HashSet set);
diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java b/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
index aead6e2959..3e7b848221 100644
--- a/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
+++ b/java/sca/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
@@ -81,10 +81,14 @@ public class EchoComponentImpl implements Echo {
return list;
}
- public String[] echoArray(String[] stringArray) {
+ public String[] echoArrayString(String[] stringArray) {
return stringArray;
}
+ public int[] echoArrayInt(int[] intArray) {
+ return intArray;
+ }
+
public Set echoSet(HashSet param){
Set set = new HashSet();
set = param;
diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/java/sca/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
index c4c3151739..6d156fcdf5 100644
--- a/java/sca/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
+++ b/java/sca/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
@@ -138,11 +138,10 @@ public class JSONRPCDataTypeTestCase {
Assert.assertEquals(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0));
}
- //@Test
- @Ignore("TUSCANY-2565")
- public void testArray() throws Exception {
+ @Test
+ public void testArrayString() throws Exception {
JSONObject jsonRequest = new JSONObject(
- "{\"params\":[\"1\",\"2\"],\"method\":\"echoArray\",\"id\":9}");
+ "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}");
WebConversation wc = new WebConversation();
WebRequest request = new PostMethodWebRequest(SERVICE_URL,
@@ -153,13 +152,32 @@ public class JSONRPCDataTypeTestCase {
JSONObject jsonResp = new JSONObject(response.getText());
- Assert.assertEquals(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0));
+ Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
+ }
+
+
+ @Test
+ public void testArrayInt() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}");
+
+ 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(1, jsonResp.getJSONArray("result").getInt(0));
}
+
@Test
public void testSet() throws Exception {
JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 10}");
+ "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}");
WebConversation wc = new WebConversation();
WebRequest request = new PostMethodWebRequest(SERVICE_URL,
diff --git a/java/sca/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/java/sca/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
index 43f41455f1..b122533f6e 100644
--- a/java/sca/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
+++ b/java/sca/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -28,3 +28,4 @@ org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=java:co
org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=java:simpleType,weight=80000,public=false
org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=commonj.sdo.DataObject,weight=80000,public=false
org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=javax.xml.bind.JAXBElement,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=java:array,weight=80000,public=false