diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-10-10 07:07:31 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-10-10 07:07:31 +0000 |
commit | cd0891e54e0e4e9123f029f3a4f9689c15598337 (patch) | |
tree | 48c7e5ee175c2cb47adf4aceb619ddf66072bd06 /sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache | |
parent | 5edad53664c23e540bea5ed336bbfa3948bb1035 (diff) |
Fix the invoker to serialize the objects to json
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1180795 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java | 42 |
1 files changed, 30 insertions, 12 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 a83adb4a1b..2c92e33f9a 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 @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.jsonrpc; +import java.util.Arrays; + import junit.framework.Assert; import org.apache.tuscany.sca.node.Contribution; @@ -28,6 +30,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import bean.TestBean; import echo.Echo; public class JSONRPCReferenceTestCase { @@ -38,13 +41,17 @@ public class JSONRPCReferenceTestCase { public static void setUp() throws Exception { try { String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCReferenceTestCase.class); - nodeServer = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("testServer", contribution)); + nodeServer = + NodeFactory.newInstance().createNode("JSONRPCBinding.composite", + new Contribution("testServer", contribution)); nodeServer.start(); - + contribution = ContributionLocationHelper.getContributionLocation(JSONRPCReferenceTestCase.class); - node = NodeFactory.newInstance().createNode("JSONRPCReference.composite", new Contribution("testClient", contribution)); + node = + NodeFactory.newInstance().createNode("JSONRPCReference.composite", + new Contribution("testClient", contribution)); node.start(); - + } catch (Exception e) { e.printStackTrace(); } @@ -55,20 +62,31 @@ public class JSONRPCReferenceTestCase { nodeServer.stop(); node.stop(); } - + @Test public void testInvokeReference() throws Exception { - Echo echoComponent = node.getService(Echo.class,"EchoComponentWithReference"); + Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference"); String result = echoComponent.echo("ABC"); Assert.assertEquals("echo: ABC", result); } @Test + public void testInvokeBeanReference() throws Exception { + Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference"); + TestBean bean = new TestBean(); + bean.setTestInt(1); + bean.setTestString("123"); + bean.setStringArray(Arrays.asList("A", "B")); + TestBean result = echoComponent.echoBean(bean); + Assert.assertEquals(bean, result); + } + + @Test public void testInvokeReferenceVoidOperation() throws Exception { - Echo echoComponent = node.getService(Echo.class,"EchoComponentWithReference"); + Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference"); echoComponent.echoVoid(); } - + @Test(expected = Exception.class) public void testInvokeReferenceException() throws Exception { Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference"); @@ -79,20 +97,20 @@ public class JSONRPCReferenceTestCase { throw e; } } - + @Test public void testInvokeReference20() throws Exception { - Echo echoComponent = node.getService(Echo.class,"EchoComponentWithReference20"); + Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference20"); String result = echoComponent.echo("ABC"); Assert.assertEquals("echo: ABC", result); } @Test public void testInvokeReferenceVoidOperation20() throws Exception { - Echo echoComponent = node.getService(Echo.class,"EchoComponentWithReference20"); + Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference20"); echoComponent.echoVoid(); } - + @Test(expected = Exception.class) public void testInvokeReferenceException20() throws Exception { Echo echoComponent = node.getService(Echo.class, "EchoComponentWithReference20"); |