summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-jsonp-runtime/src/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java28
-rw-r--r--java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java28
-rw-r--r--java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java53
-rw-r--r--java/sca/modules/binding-jsonp-runtime/src/test/java/test/Foo.java51
-rw-r--r--java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite31
5 files changed, 191 insertions, 0 deletions
diff --git a/java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java b/java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..16bf1db7ab
--- /dev/null
+++ b/java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java b/java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..064d615c45
--- /dev/null
+++ b/java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+}
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
new file mode 100644
index 0000000000..2b5676a4c9
--- /dev/null
+++ b/java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package test;
+
+import helloworld.HelloWorldService;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+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"));
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ node = NodeFactory.newInstance().createNode("helloworld.composite").start();
+ helloWorldService = node.getService(HelloWorldService.class, "HelloWorldComponent");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/java/sca/modules/binding-jsonp-runtime/src/test/java/test/Foo.java b/java/sca/modules/binding-jsonp-runtime/src/test/java/test/Foo.java
new file mode 100644
index 0000000000..b3bd70ff09
--- /dev/null
+++ b/java/sca/modules/binding-jsonp-runtime/src/test/java/test/Foo.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+
+public class Foo {
+
+ public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
+
+ String jsonRequest = "{}";
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ Object[] x = new Object[] { "ant" };
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ mapper.writeValue(os , x);
+ jsonRequest = os.toString();
+
+ System.out.println(jsonRequest);
+
+ Class c = new Object[0].getClass();
+ Object oo = mapper.readValue(jsonRequest, c);
+
+ System.out.println(oo);
+
+ }
+}
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
new file mode 100644
index 0000000000..8213d0e06f
--- /dev/null
+++ b/java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp />
+ </service>
+ </component>
+
+</composite>