diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-19 15:07:06 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-19 15:07:06 +0000 |
commit | 2782abb707ece271996d56577b010feef569e4c6 (patch) | |
tree | 5327b91f6fbf84557d3553c9dd6520b1d35668c6 /java/sca | |
parent | 249c2e55cef4ea2c13e7de0f8a4118a245cd7b99 (diff) |
Add a basic test for the jsonp binding
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@786534 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
3 files changed, 21 insertions, 6 deletions
diff --git a/java/sca/modules/binding-jsonp-runtime/pom.xml b/java/sca/modules/binding-jsonp-runtime/pom.xml index f7fd45aa84..503ebadd1a 100644 --- a/java/sca/modules/binding-jsonp-runtime/pom.xml +++ b/java/sca/modules/binding-jsonp-runtime/pom.xml @@ -37,6 +37,11 @@ </dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.0.1</version>
diff --git a/java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java b/java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java index 2b5676a4c9..5bd52db1dc 100644 --- a/java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java +++ b/java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java @@ -18,9 +18,15 @@ */
package test;
-import helloworld.HelloWorldService;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
import junit.framework.Assert;
+import org.apache.tuscany.sca.http.jetty.JettyServer;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
@@ -30,19 +36,22 @@ import org.junit.Test; public class BindingTestCase {
private static Node node;
- private static HelloWorldService helloWorldService;
@Test
- public void testService() {
-// Assert.assertEquals("Hello Petra", helloWorldService.sayHello("Petra"));
+ public void testService() throws MalformedURLException, IOException {
+ URL url = new URL("http://localhost:8085/HelloWorldService/sayHello?name=petra&callback=foo");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ String response = br.readLine();
+ Assert.assertEquals("foo(\"Hello petra\");", response);
+
}
@BeforeClass
public static void init() throws Exception {
+ JettyServer.portDefault = 8085;
node = NodeFactory.newInstance().createNode("helloworld.composite").start();
- helloWorldService = node.getService(HelloWorldService.class, "HelloWorldComponent");
}
-
+
@AfterClass
public static void destroy() throws Exception {
if (node != null) {
diff --git a/java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite b/java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite index 8213d0e06f..cbfa8a204d 100644 --- a/java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite +++ b/java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite @@ -19,6 +19,7 @@ -->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
name="HelloWorldComposite">
<component name="HelloWorldComponent">
|