summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/binding-jsonrpc-runtime
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml5
-rw-r--r--branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java217
-rw-r--r--branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java14
-rw-r--r--branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java14
4 files changed, 124 insertions, 126 deletions
diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml b/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml
index 8ec5e52a0f..ee73b43bd5 100644
--- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml
+++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml
@@ -103,14 +103,13 @@
</dependency>
- <!-- Test Dependencies -->
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-embedded</artifactId>
+ <artifactId>tuscany-node-impl</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
index 6d156fcdf5..47ce8f4433 100644
--- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
+++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
@@ -22,11 +22,13 @@ import java.io.ByteArrayInputStream;
import junit.framework.Assert;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
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;
@@ -39,155 +41,140 @@ import com.meterware.httpunit.WebResponse;
*/
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;
+ private static final String SERVICE_PATH = "/EchoService";
+ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
+ private Node node;
- @Before
- public void setUp() throws Exception {
- domain = SCADomain.newInstance("JSONRPCBinding.composite");
- }
+ @Before
+ public void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
+ }
- @After
- public void tearDown() throws Exception {
- domain.close();
- }
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
- @Test
- public void testInt() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}");
+ @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);
+ 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());
+ Assert.assertEquals(200, response.getResponseCode());
- JSONObject jsonResp = new JSONObject(response.getText());
+ JSONObject jsonResp = new JSONObject(response.getText());
- Assert.assertEquals(12345, jsonResp.getInt("result"));
- }
+ 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);
+ @Test
+ public void testBoolean() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}");
- Assert.assertEquals(200, response.getResponseCode());
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
- JSONObject jsonResp = new JSONObject(response.getText());
+ Assert.assertEquals(200, response.getResponseCode());
- Assert.assertEquals(true, jsonResp.getBoolean("result"));
- }
+ JSONObject jsonResp = new JSONObject(response.getText());
- @Test
- public void testMap() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}");
+ Assert.assertEquals(true, jsonResp.getBoolean("result"));
+ }
- WebConversation wc = new WebConversation();
- WebRequest request = new PostMethodWebRequest(SERVICE_URL,
- new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
- WebResponse response = wc.getResource(request);
+ @Test
+ public void testMap() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}");
- Assert.assertEquals(200, response.getResponseCode());
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
- JSONObject jsonResp = new JSONObject(response.getText());
+ Assert.assertEquals(200, response.getResponseCode());
- Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding"));
- }
-
- @Test
- public void testBean() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}");
+ JSONObject jsonResp = new JSONObject(response.getText());
- 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("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding"));
+ }
- Assert.assertEquals(200, response.getResponseCode());
+ @Test
+ public void testBean() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}");
- JSONObject jsonResp = new JSONObject(response.getText());
+ 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("JSON-RPC", jsonResp.getJSONObject("result").getString("testString"));
- }
+ Assert.assertEquals(200, response.getResponseCode());
- @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}");
+ JSONObject jsonResp = new JSONObject(response.getText());
- 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("JSON-RPC", jsonResp.getJSONObject("result").getString("testString"));
+ }
- Assert.assertEquals(200, response.getResponseCode());
+ @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}");
- JSONObject jsonResp = new JSONObject(response.getText());
+ 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(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0));
- }
-
- @Test
- public void testArrayString() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}");
+ Assert.assertEquals(200, response.getResponseCode());
- WebConversation wc = new WebConversation();
- WebRequest request = new PostMethodWebRequest(SERVICE_URL,
- new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
- WebResponse response = wc.getResource(request);
+ JSONObject jsonResp = new JSONObject(response.getText());
- Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0));
+ }
- JSONObject jsonResp = new JSONObject(response.getText());
+ @Test
+ public void testArrayString() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}");
- Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
- }
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
-
- @Test
- public void testArrayInt() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}");
+ Assert.assertEquals(200, response.getResponseCode());
- WebConversation wc = new WebConversation();
- WebRequest request = new PostMethodWebRequest(SERVICE_URL,
- new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
- WebResponse response = wc.getResource(request);
+ JSONObject jsonResp = new JSONObject(response.getText());
- Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
+ }
- JSONObject jsonResp = new JSONObject(response.getText());
+ @Test
+ public void testArrayInt() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}");
- Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
- }
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
-
- @Test
- public void testSet() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}");
+ Assert.assertEquals(200, response.getResponseCode());
- WebConversation wc = new WebConversation();
- WebRequest request = new PostMethodWebRequest(SERVICE_URL,
- new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
- WebResponse response = wc.getResource(request);
+ JSONObject jsonResp = new JSONObject(response.getText());
- Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
+ }
- JSONObject jsonResp = new JSONObject(response.getText());
+ @Test
+ public void testSet() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}");
- Assert.assertEquals("red", jsonResp.getJSONObject("result").getJSONObject("set").getString("red"));
- }
-} \ No newline at end of file
+ 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"));
+ }
+}
diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java
index 52518e1bbc..0619831c06 100644
--- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java
+++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java
@@ -22,7 +22,10 @@ import java.io.ByteArrayInputStream;
import junit.framework.Assert;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
@@ -42,16 +45,19 @@ public class JSONRPCExceptionTestCase{
private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
- private SCADomain domain;
+ private Node node;
@Before
public void setUp() throws Exception {
- domain = SCADomain.newInstance("JSONRPCBinding.composite");
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
}
@After
public void tearDown() throws Exception {
- domain.close();
+ node.stop();
+ node.destroy();
}
@Test
diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
index 67d3eda6b2..ed73766202 100644
--- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
+++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
@@ -22,7 +22,10 @@ import java.io.ByteArrayInputStream;
import junit.framework.Assert;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
@@ -42,16 +45,19 @@ public class JSONRPCServiceTestCase{
private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
- private SCADomain domain;
+ private Node node;
@Before
public void setUp() throws Exception {
- domain = SCADomain.newInstance("JSONRPCBinding.composite");
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
}
@After
public void tearDown() throws Exception {
- domain.close();
+ node.stop();
+ node.destroy();
}
@Test