From 4e3fa9e9e911427695cc432bc4ab5cb67da3abf3 Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 16 Jun 2009 21:23:22 +0000 Subject: Intial code for a jsonp binding runtime. Very basic butit does wokfor a simple helloworld type jsonp service git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@785412 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/helloworld/HelloWorldImpl.java | 28 ++++++++++++ .../test/java/helloworld/HelloWorldService.java | 28 ++++++++++++ .../src/test/java/test/BindingTestCase.java | 53 ++++++++++++++++++++++ .../src/test/java/test/Foo.java | 51 +++++++++++++++++++++ .../src/test/resources/helloworld.composite | 31 +++++++++++++ 5 files changed, 191 insertions(+) create mode 100644 java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 java/sca/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java create mode 100644 java/sca/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java create mode 100644 java/sca/modules/binding-jsonp-runtime/src/test/java/test/Foo.java create mode 100644 java/sca/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite (limited to 'java/sca/modules/binding-jsonp-runtime/src/test') 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 @@ + + + + + + + + + + + + -- cgit v1.2.3