diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-08 11:30:41 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-08 11:30:41 +0000 |
commit | 86f8397dbc7f8c5da94ef4f06019420953100c5c (patch) | |
tree | 4a0f5a5aeca89fd768cbd1f70939d0606e510d96 /sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java | |
parent | 5a7306e0e7873abb952cf38ef4f6bb93d5e6409a (diff) |
TUSCANY-3668 - support BigDecimal in JSON format and JSONRPC binding. BigDecimal is detected in an interface as a Java simple type but you have to manage it explicitly when converting from primitive types.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@994995 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java')
4 files changed, 29 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java index 322008de1f..91efccc4e5 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java @@ -18,6 +18,7 @@ */ package echo; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -61,4 +62,5 @@ public interface Echo { void get\u03a9\u03bb\u03c0(); + BigDecimal echoBigDecimal(BigDecimal param); } diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java index f76ec74b16..4163f86313 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java @@ -19,6 +19,7 @@ package echo; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -81,5 +82,9 @@ public class EchoClientImpl implements Echo { public void get\u03a9\u03bb\u03c0() { throw new UnsupportedOperationException("UNsupported !"); } + + public BigDecimal echoBigDecimal(BigDecimal param) { + throw new UnsupportedOperationException("UNsupported !"); + } } diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java index 08ccb6e6d5..0a34404281 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java @@ -18,6 +18,7 @@ */ package echo; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -96,8 +97,11 @@ public class EchoComponentImpl implements Echo { } - public void get\u03a9\u03bb\u03c0() { } + + public BigDecimal echoBigDecimal(BigDecimal param) { + return param; + } } diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java index 0fd622d29b..d09bce6365 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java @@ -199,4 +199,21 @@ public class JSONRPCDataTypeTestCase { Assert.assertEquals("red", jsonResp.getJSONArray("result").get(0)); } + + @Test + public void testBigDecimal() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoBigDecimal\", \"params\": [\"12345.67\"], \"id\": 4}"); + + 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("12345.67", jsonResp.get("result")); + } }
\ No newline at end of file |