summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-04-28 03:57:08 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-04-28 03:57:08 +0000
commitd61bdeb8230194c005ef29f29b3cf87067e6deab (patch)
tree2c25588f4460f36d5725d8e0aec817d270af6aba
parentdde6ebce6e647cd857e7fd39ab914ce513de6b7e (diff)
Update testcase to simulate a browser GET call and verify the right JSON is produced
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@938772 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java
index 27c2ce669d..ad72a5a74f 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java
@@ -20,21 +20,33 @@
package org.apache.tuscany.sca.binding.rest.wireformat.json;
import java.net.Socket;
+import java.net.URLEncoder;
+import org.apache.axiom.om.util.Base64;
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.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
import services.Catalog;
import services.Item;
public class CatalogServiceTestCase {
+ private static final String SERVICE_URL = "http://localhost:8085/Catalog";
+
+ private static final String GET_RESPONSE = "[{\"price\":\"$2.99\",\"name\":\"Apple\",\"javaClass\":\"services.Item\"},{\"price\":\"$3.55\",\"name\":\"Orange\",\"javaClass\":\"services.Item\"},{\"price\":\"$1.55\",\"name\":\"Pear\",\"javaClass\":\"services.Item\"}]";
+
private static Node node;
private static Catalog catalogService;
@@ -65,15 +77,13 @@ public class CatalogServiceTestCase {
//System.in.read();
}
- @Ignore
- public void testNewsService() throws Exception {
- Item[] items = catalogService.get();
-
- Assert.assertNotNull(items);
- Assert.assertTrue(items.length > 0);
-
- for(int pos = 0; pos < items.length; pos++) {
- System.out.println(">>> Item[" + pos + "] - " + items[pos].getName() + " - " + items[pos].getPrice());
- }
+ @Test
+ public void testGetInvocation() throws Exception {
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL);
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(GET_RESPONSE, response.getText());
}
}