From 5f1015e82869bee32483c9cd95f933bdde513672 Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 6 Oct 2010 13:40:42 +0000 Subject: TUSCANY-3696 - add more checking for null response. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1005031 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/jsonp/runtime/JSONPServlet.java | 9 ++++++--- .../src/test/java/helloworld/HelloWorldClient.java | 6 +++++- .../src/test/java/helloworld/HelloWorldImpl.java | 4 ++++ .../src/test/java/helloworld/HelloWorldService.java | 2 ++ .../src/test/java/test/BindingTestCase.java | 19 +++++++++++++++++-- 5 files changed, 34 insertions(+), 6 deletions(-) (limited to 'sca-java-1.x/trunk') diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java index a86446c734..99879eb145 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java @@ -70,9 +70,12 @@ public class JSONPServlet extends GenericServlet { @Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { Object[] args = getJSONRequestStringArray(servletRequest); - Object response = invokeService(args); - String jsonResponse = getJSONResponseAsString(servletRequest, response); - servletResponse.getOutputStream().println(jsonResponse); + Object response = invokeService(args); + + if (response != null){ + String jsonResponse = getJSONResponseAsString(servletRequest, response); + servletResponse.getOutputStream().println(jsonResponse); + } } /** diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java index b1f81cb499..aca47c3d5f 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java @@ -53,5 +53,9 @@ public class HelloWorldClient implements HelloWorldService { public void sayHello7() { ref.sayHello7(); - } + } + + public void sayHello8(String name) { + ref.sayHello8(name); + } } diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java index e3159a0274..01d67757f9 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java @@ -68,4 +68,8 @@ public class HelloWorldImpl implements HelloWorldService { public void sayHello7() { System.out.println("Hello void Fred"); } + + public void sayHello8(String name) { + System.out.println("Hello void " + name); + } } diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java index 2b0208d143..79cc293b97 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java @@ -37,5 +37,7 @@ public interface HelloWorldService { String[] sayHello6(BeanA[] beans, String[] names, String anotherName); void sayHello7(); + + void sayHello8(String name); } diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java index cec8c05039..bafd6ecd21 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java @@ -144,8 +144,23 @@ public class BindingTestCase { public void testVoid() throws MalformedURLException, IOException { HelloWorldService client = ((SCAClient)node).getService(HelloWorldService.class, "HelloWorldClient"); - client.sayHello7(); - } + try { + client.sayHello7(); + } catch (Exception ex){ + Assert.fail(); + } + } + + @Test + public void testVoidOut() throws MalformedURLException, IOException { + HelloWorldService client = ((SCAClient)node).getService(HelloWorldService.class, "HelloWorldClient"); + + try { + client.sayHello8("Fred"); + } catch (Exception ex){ + Assert.fail(); + } + } @Test @Ignore -- cgit v1.2.3