diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-04 19:21:37 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-04 19:21:37 +0000 |
commit | 9214aad2a30d89a5f7422eda58f074ddc7ba165c (patch) | |
tree | 9c77536c8248585dda7611b05f5ab9f4b89c26e6 | |
parent | 4b6980bc70a11fe4e47fff13b08ea479afb2d169 (diff) |
TUSCANY-2487 - Making interfaces remotable and other small fixes.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682472 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 121 insertions, 110 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 a83f439e3e..920626ab8f 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 @@ -25,6 +25,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.osoa.sca.annotations.Remotable; + import bean.TestBean; /** @@ -32,6 +34,7 @@ import bean.TestBean; * * @version $Rev$ $Date$ */ +@Remotable public interface Echo { String echo(String msg); 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 45337bb485..ca56ac9519 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 @@ -26,7 +26,6 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; import org.json.JSONObject; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import com.meterware.httpunit.PostMethodWebRequest; @@ -37,113 +36,122 @@ import com.meterware.httpunit.WebResponse; /** * @version $Rev$ $Date$ */ -public class JSONRPCDataTypeTestCase{ - - private static final String SERVICE_PATH = "/EchoService"; - - private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH; - - private SCADomain domain; - - @Before - public void setUp() throws Exception { - domain = SCADomain.newInstance("JSONRPCBinding.composite"); - } - - @After - public void tearDown() throws Exception { - domain.close(); - } - - @Test - public void testInt() throws Exception { - JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoInt\", \"params\": [12345], \"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, jsonResp.getInt("result")); - } - - @Test - public void testBoolean() throws Exception { - JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}"); - 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(true, jsonResp.getBoolean("result")); - } - - @Ignore("TUSCANY-2488") - public void testMap() throws Exception { - JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}"); - - 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("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("name")); - } - - @Ignore("TUSCANY-2488") - public void testList() throws Exception { - JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoList\", \"params\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [0,1,2,3,4]}], \"id\": 8}"); - - 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.getJSONObject("result").getJSONArray("list").get(0)); - } - - @Ignore("TUSCANY-2488") - public void testSet() throws Exception { - JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 9}"); - - 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.getJSONObject("result").getJSONObject("set").getString("red")); - } - - @Ignore("TUSCANY-2488") - public void testBean() throws Exception { - JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"org.apache.tuscany.sca.binding.jsonrpc.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}"); - - 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("JSON-RPC", jsonResp.getJSONObject("result").getString("testString")); - } - - - +public class JSONRPCDataTypeTestCase { + + private static final String SERVICE_PATH = "/EchoService"; + private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH; + private SCADomain domain; + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance("JSONRPCBinding.composite"); + } + + @After + public void tearDown() throws Exception { + domain.close(); + } + + @Test + public void testInt() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoInt\", \"params\": [12345], \"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, jsonResp.getInt("result")); + } + + @Test + public void testBoolean() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}"); + + 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(true, jsonResp.getBoolean("result")); + } + + @Test + public void testMap() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}"); + + 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("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding")); + } + + @Test + public void testList() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoList\", \"params\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [0,1,2,3,4]}], \"id\": 8}"); + + 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.getJSONObject("result").getJSONArray("list").get(0)); + } + + @Test + public void testSet() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 9}"); + + 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("red", jsonResp.getJSONObject("result").getJSONObject("set").getString("red")); + } + + @Test + public void testBean() throws Exception { + JSONObject jsonRequest = new JSONObject( + "{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}"); + + 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("JSON-RPC", jsonResp.getJSONObject("result").getString("testString")); + } + }
\ No newline at end of file |