summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/trunk/modules/binding-jsonp-runtime
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-09-29 15:31:54 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-09-29 15:31:54 +0000
commit52344358758d76f783ad2fcd21adbe702a2efb24 (patch)
tree48cc66f8853fdb10a79394ed71811c7daebdef4f /sca-java-1.x/trunk/modules/binding-jsonp-runtime
parentdac68c265156f6d8608d55d8e00df987dae9e635 (diff)
TUSCANY-3696 - and make the array changes work with void input and output parameters
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1002679 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/trunk/modules/binding-jsonp-runtime')
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java4
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java10
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java19
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java6
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java4
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java3
-rw-r--r--sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java11
7 files changed, 42 insertions, 15 deletions
diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
index 579ad7bee1..543967c867 100644
--- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
+++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
@@ -142,6 +142,10 @@ public class JSONPInvoker implements Invoker {
}
protected String[] objectsToJSONStrings(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
+ if (msgArgs == null){
+ return new String[0];
+ }
+
String[] jsonArgs = new String[msgArgs.length];
for (int i=0; i<msgArgs.length; i++) {
jsonArgs[i] = msgArgs[i].toString();
diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
index 3fe293cb8d..cb1f97fbee 100644
--- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
+++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
@@ -58,10 +58,12 @@ public class JSONPReferenceBindingProvider implements ReferenceBindingProvider {
inputType.setDataBinding("JSON2x");
}
}
- DataType outputType = operation.getOutputType();
- if ("java:array".equals(outputType.getDataBinding())){
- outputType.setDataBinding("JSON2x");
- }
+ DataType outputType = operation.getOutputType();
+ if (outputType != null){
+ if ("java:array".equals(outputType.getDataBinding())){
+ outputType.setDataBinding("JSON2x");
+ }
+ }
}
}
public Invoker createInvoker(Operation operation) {
diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java
index a76df37522..108e7fb4ae 100644
--- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java
+++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java
@@ -60,15 +60,18 @@ public class JSONPServiceBindingProvider implements ServiceBindingProvider {
// force array types to map to JSON also
for (Operation operation : contract.getInterface().getOperations()){
DataType<List<DataType>> inputTypes = operation.getInputType();
- for (DataType inputType : inputTypes.getLogical()){
- if ("java:array".equals(inputType.getDataBinding())){
- inputType.setDataBinding("JSON2x");
- }
- }
+ for (DataType inputType : inputTypes.getLogical()){
+ if ("java:array".equals(inputType.getDataBinding())){
+ inputType.setDataBinding("JSON2x");
+ }
+ }
+
DataType outputType = operation.getOutputType();
- if ("java:array".equals(outputType.getDataBinding())){
- outputType.setDataBinding("JSON2x");
- }
+ if (outputType != null){
+ if ("java:array".equals(outputType.getDataBinding())){
+ outputType.setDataBinding("JSON2x");
+ }
+ }
}
}
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 a08dba6708..b1f81cb499 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
@@ -49,5 +49,9 @@ public class HelloWorldClient implements HelloWorldService {
public String[] sayHello6(BeanA[] beans, String[] names, String anotherName){
return ref.sayHello6(beans, names, anotherName);
- }
+ }
+
+ public void sayHello7() {
+ ref.sayHello7();
+ }
}
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 2334c48cac..e3159a0274 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
@@ -64,4 +64,8 @@ public class HelloWorldImpl implements HelloWorldService {
String [] response = {returnString};
return response;
}
+
+ public void sayHello7() {
+ System.out.println("Hello void Fred");
+ }
}
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 1eda6de915..2b0208d143 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
@@ -35,4 +35,7 @@ public interface HelloWorldService {
BeanA[] sayHello5(BeanA[] beans);
String[] sayHello6(BeanA[] beans, String[] names, String anotherName);
+
+ void sayHello7();
+
}
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 16d962911c..cec8c05039 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
@@ -106,7 +106,7 @@ public class BindingTestCase {
BeanA[] response = client.sayHello5(beans);
Assert.assertEquals("Hello Fred", response[0].getS());
- }
+ }
/* HTTP Request for testMixedArray
GET /HelloWorldComponent/HelloWorldService/sayHello6?arg0=%5B%7B%22b%22%3Atrue%2C%22s%22%3A%22Fred%22%2C%22y%22%3Anull%2C%22x%22%3A5%7D%5D&arg1=%5B%22Fred%22%2C%22Bloggs%22%5D&arg2=%22Bloggs%22 HTTP/1.1
@@ -138,7 +138,14 @@ public class BindingTestCase {
String[] response = client.sayHello6(beans, names, "Bloggs");
Assert.assertEquals("Hello Fred Fred Bloggs Bloggs", response[0]);
- }
+ }
+
+ @Test
+ public void testVoid() throws MalformedURLException, IOException {
+ HelloWorldService client = ((SCAClient)node).getService(HelloWorldService.class, "HelloWorldClient");
+
+ client.sayHello7();
+ }
@Test
@Ignore