summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-05-05 23:13:19 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-05-05 23:13:19 +0000
commit3e47841070daa13c07af89469f4dbecdd0686e2b (patch)
treefbaab47932875863f7d91fe9fcd900e1b0f88ca7
parentabba575231a2312e8d65d3de70d719b7319f8efd (diff)
Small clean up and formatting on tests
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@772008 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCDataTypeTestCase.java292
-rw-r--r--branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCExceptionTestCase.java10
-rw-r--r--branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java9
3 files changed, 141 insertions, 170 deletions
diff --git a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCDataTypeTestCase.java b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCDataTypeTestCase.java
index 867bfceac6..b842f9b1e5 100644
--- a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCDataTypeTestCase.java
+++ b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCDataTypeTestCase.java
@@ -26,7 +26,6 @@ import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import com.meterware.httpunit.PostMethodWebRequest;
@@ -39,169 +38,156 @@ import com.meterware.httpunit.WebResponse;
*/
public class JSONRPCDataTypeTestCase {
- private static final String SERVICE_PATH = "/EchoService";
- private static final String SERVICE_URL = "http://localhost:8085/" + SERVICE_PATH;
-
- private static SCADomain domain;
+ private static final String SERVICE_PATH = "/EchoService";
+ private static final String SERVICE_URL = "http://localhost:8085/" + SERVICE_PATH;
- @BeforeClass
- public static void setUp() throws Exception {
- domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCBinding.composite");
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- domain.close();
- }
-
- @Test
- //@Ignore("Work in progress")
- public void testInt() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}");
+ private static SCADomain domain;
- WebConversation wc = new WebConversation();
- WebRequest request = new PostMethodWebRequest(SERVICE_URL,
- new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
- WebResponse response = wc.getResource(request);
+ @BeforeClass
+ public static void setUp() throws Exception {
+ domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCBinding.composite");
+ }
- Assert.assertEquals(200, response.getResponseCode());
-
- JSONObject jsonResp = new JSONObject(response.getText());
+ @AfterClass
+ public static void tearDown() throws Exception {
+ domain.close();
+ }
- Assert.assertEquals(12345, jsonResp.getInt("result"));
- }
-
- @Test
- //@Ignore("Work in progress")
- 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 testInt() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}");
- 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(true, jsonResp.getBoolean("result"));
- }
-
- @Test
- //@Ignore("Work in progress")
- 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());
-
- JSONObject jsonResp = new JSONObject(response.getText());
-
- Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding"));
- }
-
- @Test
- //@Ignore("Work in progress")
- 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"));
- }
-
- @Test
- //@Ignore("Work in progress")
- 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
- //@Ignore("Work in progress")
- public void testArrayString() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"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(12345, jsonResp.getInt("result"));
+ }
- Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
- }
+ @Test
+ public void testBoolean() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}");
-
- @Test
- //@Ignore("Work in progress")
- 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());
+ 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(1, jsonResp.getJSONArray("result").getInt(0));
- }
+ Assert.assertEquals(200, response.getResponseCode());
-
- @Test
- //@Ignore("Work in progress")
- public void testSet() throws Exception {
- JSONObject jsonRequest = new JSONObject(
- "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}");
-
- 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());
- JSONObject jsonResp = new JSONObject(response.getText());
-
- Assert.assertEquals("red", jsonResp.getJSONObject("result").getJSONObject("set").getString("red"));
- }
-
- @Test
- public void testDummy() throws Exception {
-
- }
+ 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 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"));
+ }
+
+ @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 testArrayString() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"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(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\": 11}");
+
+ 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"));
+ }
} \ No newline at end of file
diff --git a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCExceptionTestCase.java b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCExceptionTestCase.java
index eb47e4a2e9..159ae0e65e 100644
--- a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCExceptionTestCase.java
+++ b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCExceptionTestCase.java
@@ -26,7 +26,6 @@ import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import com.meterware.httpunit.PostMethodWebRequest;
@@ -56,7 +55,6 @@ public class JSONRPCExceptionTestCase{
}
@Test
- //@Ignore("Work in progress")
public void testRuntimeException() throws Exception{
JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoRuntimeException\", \"params\": [], \"id\": 2}");
@@ -72,7 +70,6 @@ public class JSONRPCExceptionTestCase{
}
@Test
- //@Ignore("Work in progress")
public void testBusinessException() throws Exception{
JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBusinessException\", \"params\": [], \"id\": 3}");
@@ -85,10 +82,5 @@ public class JSONRPCExceptionTestCase{
JSONObject jsonErr = new JSONObject(response.getText()).getJSONObject("error");
Assert.assertEquals("Business Exception", jsonErr.getString("msg"));
- }
-
- @Test
- public void testDummy() throws Exception {
-
- }
+ }
} \ No newline at end of file
diff --git a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java
index ac03704db0..e04e210596 100644
--- a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java
+++ b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java
@@ -26,7 +26,6 @@ import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import com.meterware.httpunit.PostMethodWebRequest;
@@ -56,7 +55,6 @@ public class JSONRPCServiceTestCase {
}
@Test
- //@Ignore("Work in progress")
public void testJSONRPCBinding() throws Exception {
JSONObject jsonRequest = new JSONObject("{ \"method\": \"echo\", \"params\": [\"Hello JSON-RPC\"], \"id\": 1}");
@@ -68,10 +66,5 @@ public class JSONRPCServiceTestCase {
JSONObject jsonResp = new JSONObject(response.getText());
Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
- }
-
- @Test
- public void testDummy() throws Exception {
-
- }
+ }
} \ No newline at end of file