From 2782abb707ece271996d56577b010feef569e4c6 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 19 Jun 2009 15:07:06 +0000 Subject: 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 --- java/sca/modules/binding-jsonp-runtime/pom.xml | 5 +++++ .../src/test/java/test/BindingTestCase.java | 21 +++++++++++++++------ .../src/test/resources/helloworld.composite | 1 + 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 @@ -36,6 +36,11 @@ 2.0-SNAPSHOT + + org.apache.tuscany.sca + tuscany-host-http + 2.0-SNAPSHOT + org.codehaus.jackson jackson-core-asl 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 @@ --> -- cgit v1.2.3