diff options
Diffstat (limited to '')
30 files changed, 2118 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Client.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Client.java new file mode 100644 index 0000000000..1b7e11c786 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Client.java @@ -0,0 +1,35 @@ +/* + * 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 sample; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface Client { + + String jello(String s); + + String wello(String s); +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/ClientTest.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/ClientTest.java new file mode 100644 index 0000000000..92291c98a1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/ClientTest.java @@ -0,0 +1,65 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import static sample.Xutil.elem; +import static sample.Xutil.elems; +import static sample.Xutil.print; +import static sample.Xutil.select; +import static sample.Xutil.text; +import static sample.Xutil.xdom; +import static sample.Xutil.xfilter; +import static sample.Xutil.xreduce; + +import org.w3c.dom.Element; + +import sample.api.Java; +import sample.api.WSDL; +import sample.api.WSDLReference; + +/** + * Sample component implementation that uses a mix of Java and WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Client.class) +public class ClientTest { + + @Java(Hello.class) + Hello jello; + + @WSDL("http://sample/hello#Hello") + WSDLReference wello; + + public String jello(String s) { + out.println("ClientTest.jello(" + s + ")"); + return jello.hello(s); + } + + public String wello(String s) { + out.println("ClientTest.wello(" + s + ")"); + final Element hreq = xdom("http://sample/hello", "hello", elem("name", text(s))); + + final Element hres = wello.call("hello", hreq); + + return xreduce(print, "", xfilter(select("result"), elems(hres))); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Hello.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Hello.java new file mode 100644 index 0000000000..247fc8aa78 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Hello.java @@ -0,0 +1,33 @@ +/* + * 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 sample; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface Hello { + + String hello(String s); +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/JelloTest.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/JelloTest.java new file mode 100644 index 0000000000..5c999a6c80 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/JelloTest.java @@ -0,0 +1,40 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import sample.api.Java; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Hello.class) +public class JelloTest { + + @Java(Upper.class) + Upper upper; + + public String hello(String s) { + out.println("JelloTest.hello(" + s + ")"); + return upper.upper("Hello " + s); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Upper.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Upper.java new file mode 100644 index 0000000000..3a831a0ecf --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Upper.java @@ -0,0 +1,37 @@ +/* + * 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 sample; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Sample service interface. + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface Upper { + + String upper(String s); + + String upper2(String s); + + String upperVoid(String s); +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java new file mode 100644 index 0000000000..ff1da8f8bf --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java @@ -0,0 +1,77 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import static sample.Xutil.elem; +import static sample.Xutil.text; +import static sample.Xutil.xdom; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.w3c.dom.Element; + +import sample.Xutil.NodeBuilder; +import sample.api.Java; +import sample.api.WSDL; +import sample.api.WSDLReference; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Upper.class) +public class UpperSampleAsyncReferenceBareImpl { + + @WSDL("http://sample/upper-async-bare#UpperBare") + WSDLReference upper; + + Element response; + CountDownLatch latch = new CountDownLatch( 1 ); + + public String upper(String s) { + out.println("UpperSampleAsyncReferenceImpl.upper(" + s + ")"); + + // I'm passing in the non-wrapped version of the parameter + // here to test what happens with different WSDL styles + // at the implementation and binding + final Element arg0 = xdom("http://sample/upper-async", "arg0", text("arg0_" + s)); + final Element arg1 = xdom("http://sample/upper-async", "arg1", text("arg1_" + s)); + + // TODO - intended to do an async call here but using the the sync version + // while I look at databinding. + Element response = upper.callBare("upper", arg0, arg1); + + return response.getTextContent(); + } + + /** + * In this implementation the convention is that the + * async callback arrives at an operation named + * operationName + Callback + */ + public void upperCallback(Element response) { + out.println("UpperSampleAsyncReferenceImpl.upperCallback(" + response.getTextContent() + ")"); + this.response = response; + latch.countDown(); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java new file mode 100644 index 0000000000..e21ab5ac90 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java @@ -0,0 +1,140 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import static sample.Xutil.elem; +import static sample.Xutil.text; +import static sample.Xutil.xdom; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.w3c.dom.Element; + +import sample.Xutil.NodeBuilder; +import sample.api.Java; +import sample.api.WSDL; +import sample.api.WSDLReference; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Upper.class) +public class UpperSampleAsyncReferenceImpl { + + @WSDL("http://sample/upper-async#Upper") + WSDLReference upper; + + Element response; + Element response2; + public static String responseVoid; + CountDownLatch latch = new CountDownLatch( 1 ); + + public String upper(String s) { + out.println("UpperSampleAsyncReferenceImpl.upper(" + s + ")"); + + // TODO - I'm passing in the non-wrapped version of the parameter + // here which doesn't seem right. Need to test that databinding + // wraps it correctly + //final Element ureq = xdom("http://sample/upper-async", "s", text(s)); + NodeBuilder node1 = elem("s", text(s)); + final Element ureq = xdom("http://sample/upper-async", "upper", node1); + upper.callAsync("upper", ureq); + + try { + //Thread.sleep(500); + latch.await(5, TimeUnit.SECONDS); + } catch (Exception ex) { + // do nothing + } + + if( response != null ) { + return response.getTextContent(); + } else { + return "upper did not get called back"; + } + } + + /** + * In this implementation the convention is that the + * async callback arrives at an operation named + * operationName + Callback + */ + public void upperCallback(Element response) { + out.println("UpperSampleAsyncReferenceImpl.upperCallback(" + response.getTextContent() + ")"); + this.response = response; + latch.countDown(); + } + + public String upper2(String s) { + out.println("UpperSampleAsyncReferenceImpl.upper2(" + s + ")"); + + // TODO - I'm passing in the non-wrapped version of the parameter + // here which doesn't seem right. Need to test that databinding + // wraps it correctly + //final Element ureq = xdom("http://sample/upper-async", "s", text(s)); + NodeBuilder node1 = elem("s", text(s)); + final Element ureq = xdom("http://sample/upper-async", "upper", node1); + upper.callAsync("upper2", ureq); + + try { + //Thread.sleep(500); + latch.await(5, TimeUnit.SECONDS); + } catch (Exception ex) { + // do nothing + } + + // because we serialize the upper request and re-use it in upper2 + // the response to upper2 comes back to the upper callback + if( response != null ) { + return response.getTextContent(); + } else { + return "upper2 did not get called back"; + } + } + + /** + * In this implementation the convention is that the + * async callback arrives at an operation named + * operationName + Callback + */ + public void upper2Callback(Element response) { + out.println("UpperSampleAsyncReferenceImpl.upper2Callback(" + response.getTextContent() + ")"); + this.response2 = response; + latch.countDown(); + } + + public String upperVoid(String s) { + out.println("UpperSampleAsyncReferenceImpl.upperVoid(" + s + ")"); + + // TODO - I'm passing in the non-wrapped version of the parameter + // here which doesn't seem right. Need to test that databinding + // wraps it correctly + //final Element ureq = xdom("http://sample/upper-async", "s", text(s)); + NodeBuilder node1 = elem("s", text(s)); + final Element ureq = xdom("http://sample/upper-async", "upper", node1); + upper.callAsync("upperVoid", ureq); + return responseVoid; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceImpl.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceImpl.java new file mode 100644 index 0000000000..75fe271d7a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import static sample.Xutil.elem; +import static sample.Xutil.text; +import static sample.Xutil.xdom; + +import org.w3c.dom.Element; + +import sample.api.WSDL; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@WSDL("http://sample/upper-async#Upper") +public class UpperSampleAsyncServiceImpl { + + public Element call(String op, Element e) { + String input = e.getTextContent(); + out.println("UpperSampleAsyncServiceImpl." + op + "(" + input + ")"); + String output = input.toUpperCase(); + + if (!op.equals("upperVoid")){ + return xdom("http://sample/upper-async", "upperResponse", elem("result", text(output))); + } else { + out.println("No response as void return type"); + UpperSampleAsyncReferenceImpl.responseVoid = output; + return null; + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java new file mode 100644 index 0000000000..bd7dcd5eae --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java @@ -0,0 +1,45 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import static sample.Xutil.elem; +import static sample.Xutil.text; +import static sample.Xutil.xdom; + +import org.w3c.dom.Element; + +import sample.api.WSDL; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@WSDL("http://sample/upper-async-wrapped#UpperWrapped") +public class UpperSampleAsyncServiceWrappedImpl { + + public Element call(String op, Element e) { + String input = e.getTextContent(); + out.println("UpperSampleAsyncServiceImpl.upper(" + input + ")"); + String output = input.toUpperCase(); + return xdom("http://sample/upper-async", "upperResponse", elem("result", text(output))); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperTest.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperTest.java new file mode 100644 index 0000000000..f1daf8155e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperTest.java @@ -0,0 +1,46 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import sample.api.Java; + +/** + * Sample component implementation that uses Java interfaces. + * + * @version $Rev$ $Date$ + */ +@Java(Upper.class) +public class UpperTest { + + public String upper(String s) { + out.println("UpperTest.upper(" + s + ")"); + return s.toUpperCase(); + } + + public String upper2(String s) { + out.println("UpperTest.upper2(" + s + ")"); + return s.toUpperCase(); + } + + public void upperVoid(String s) { + out.println("UpperTest.upperVoid(" + s + ")"); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/WelloTest.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/WelloTest.java new file mode 100644 index 0000000000..1bb9fc11ce --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/WelloTest.java @@ -0,0 +1,59 @@ +/* + * 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 sample; + +import static java.lang.System.out; +import static sample.Xutil.elem; +import static sample.Xutil.elems; +import static sample.Xutil.print; +import static sample.Xutil.select; +import static sample.Xutil.text; +import static sample.Xutil.xdom; +import static sample.Xutil.xfilter; +import static sample.Xutil.xml; +import static sample.Xutil.xreduce; + +import org.w3c.dom.Element; + +import sample.api.WSDL; +import sample.api.WSDLReference; + +/** + * Sample component implementation that uses WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +@WSDL("http://sample/hello#Hello") +public class WelloTest { + + @WSDL("http://sample/upper#Upper") + WSDLReference upper; + + public Element call(String op, Element e) { + out.println("WelloTest." + op + "(" + xml(e) + ")"); + final String name = xreduce(print, "", xfilter(select("name"), elems(e))); + + final Element ureq = xdom("http://sample/upper", "upper", elem("s", text("Hello " + name))); + final Element ures = upper.call("upper", ureq); + + final String s = xreduce(print, "", xfilter(select("result"), elems(ures))); + return xdom("http://sample/hello", "helloResponse", elem("result", text(s))); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Xutil.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Xutil.java new file mode 100644 index 0000000000..ce89f9dd8c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/Xutil.java @@ -0,0 +1,225 @@ +/* + * 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 sample; + +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * Just for fun, a little bit of magic code and utility functions to help work with XML DOM. + */ +class Xutil { + interface NodeBuilder { + Node build(Document doc); + } + + /** + * Convert a name and a list of children to a document element. + */ + static Element xdom(String ns, String name, final NodeBuilder... nodes) { + return (Element)elem(ns, name, nodes).build(db.newDocument()); + } + + /** + * Convert a name and children to an element. + */ + static NodeBuilder elem(final String uri, final String n, final NodeBuilder... nodes) { + return new NodeBuilder() { + public Node build(Document doc) { + final Element e = doc.createElementNS(uri, n); + for(final NodeBuilder n: nodes) + e.appendChild(n.build(doc)); + return e; + } + }; + } + + static NodeBuilder elem(final String n, final NodeBuilder... nodes) { + return elem(null, n, nodes); + } + + /** + * Convert a string to a text element. + */ + static NodeBuilder text(final String t) { + return new NodeBuilder() { + public Node build(final Document doc) { + return doc.createTextNode(t); + } + }; + } + + private final static DocumentBuilder db = db(); + + private static DocumentBuilder db() { + try { + return DocumentBuilderFactory.newInstance().newDocumentBuilder(); + } catch(ParserConfigurationException e) { + throw new RuntimeException(e); + } + } + + /** + * Convert an element to XML. + */ + static TransformerFactory trf = TransformerFactory.newInstance(); + + static String xml(final Node node) { + try { + final StreamResult r = new StreamResult(new StringWriter()); + trf.newTransformer().transform(new DOMSource(node), r); + return r.getWriter().toString(); + } catch(TransformerException e) { + throw new RuntimeException(e); + } + } + + /** + * Evaluate an xpath expression. + */ + private static XPathFactory xpf = XPathFactory.newInstance(); + + static String xpath(final String expr, final Node node) { + final XPath xp = xpf.newXPath(); + try { + return (String)xp.evaluate(expr, node, XPathConstants.STRING); + } catch(XPathExpressionException e) { + throw new RuntimeException(e); + } + } + + /** + * A pure Java FP-style alternative to xpath for DOM. + */ + interface Mapper<T> { + T map(final Element e); + } + + static Mapper<Element> identity = new Mapper<Element>() { + public Element map(Element e) { + return e; + }; + }; + + interface Reducer<T> { + T reduce(final T accum, final Element e); + } + + static Reducer<String> print = new Reducer<String>() { + public String reduce(String accum, Element e) { + return accum + e.getTextContent(); + } + }; + + /** + * Apply a mapper to a list of elements. + */ + static <T> List<T> xmap(final Mapper<T> f, final Iterable<Element> l) { + final List<T> v = new ArrayList<T>(); + for(Element e: l) + v.add(f.map(e)); + return v; + } + + /** + * Apply a filter to a list of elements. + */ + static List<Element> xfilter(final Mapper<Boolean> f, final Iterable<Element> l) { + final List<Element> v = new ArrayList<Element>(); + for(Element e: l) + if(f.map(e)) + v.add(e); + return v; + } + + /** + * Perform a reduction over a list of elements. + */ + static <T> T xreduce(final Reducer<T> f, final T initial, final Iterable<Element> l) { + T accum = initial; + for(Element e: l) + accum = f.reduce(accum, e); + return accum; + } + + /** + * Return a filter that selects elements by name. + */ + static Mapper<Boolean> select(final String name) { + return new Mapper<Boolean>() { + public Boolean map(Element e) { + return name.equals(e.getLocalName()); + } + }; + } + + /** + * Return the child elements of a node. + */ + static Iterable<Element> elems(final Node parent) { + final List<Element> l = new ArrayList<Element>(); + for (Node n: children(parent)) + if (n instanceof Element) + l.add((Element)n); + return l; + } + + /** + * An iterable over the children of a node. + */ + private static Iterable<Node> children(Node parent) { + final NodeList l = parent.getChildNodes(); + final int n = l.getLength(); + return new Iterable<Node>() { + public Iterator<Node> iterator() { + return new Iterator<Node>() { + int i = 0; + public boolean hasNext() { + return i < n; + } + public Node next() { + return l.item(i++); + } + public void remove() { + } + }; + } + }; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/EmbedTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/EmbedTestCase.java new file mode 100644 index 0000000000..406dbabee0 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/EmbedTestCase.java @@ -0,0 +1,151 @@ +/* + * 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 sample.impl; + +import static java.lang.System.out; +import static org.junit.Assert.assertEquals; +import static sample.impl.EmbedUtil.build; +import static sample.impl.EmbedUtil.component; +import static sample.impl.EmbedUtil.composite; +import static sample.impl.EmbedUtil.contrib; +import static sample.impl.EmbedUtil.deploy; +import static sample.impl.EmbedUtil.embedContext; +import static sample.impl.EmbedUtil.extensionPoints; +import static sample.impl.EmbedUtil.implementation; +import static sample.impl.EmbedUtil.node; +import static sample.impl.EmbedUtil.providerFactories; +import static sample.impl.EmbedUtil.reference; +import static sample.impl.EmbedUtil.service; +import static sample.impl.EmbedUtil.wsdli; +import static sample.impl.TestUtil.here; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import sample.Client; +import sample.ClientTest; +import sample.Hello; +import sample.JelloTest; +import sample.Upper; +import sample.UpperTest; +import sample.WelloTest; + +/** + * Test how to assemble a contribution, a SCDL composite and run it on an embedded + * Tuscany runtime node. Also shows how pass in a ProviderFactory instead of having + * it loaded and constructed by the runtime node. + * + * @version $Rev$ $Date$ + */ +public class EmbedTestCase { + static NodeFactory nf; + static EmbedUtil.Context ec; + static Node node; + + @SuppressWarnings("unchecked") + @BeforeClass + public static void setUp() throws Exception { + nf = NodeFactory.newInstance(); + ec = embedContext(nf); + + // Load the test WSDL definitions (could also construct the WSDL + // and XSD models in code but that'd be quite painful, so just + // load them from XML for now) + final Contribution contrib = build(contrib("test", here()), ec); + WSDLInterface Hello_wsdl = build(wsdli("Hello.wsdl", "http://sample/hello", "Hello", contrib), ec); + WSDLInterface Upper_wsdl = build(wsdli("Upper.wsdl", "http://sample/upper", "Upper", contrib), ec); + + // Assemble a test composite model (see EmbedUtil + // for the little DSL used here, much more concise + // than using the assembly model interfaces) + final Composite comp = + build(composite("http://sample", "test", + component("client-test", + implementation(ClientTest.class, + service(Client.class), + reference("jello", Hello.class), + reference("wello", Hello_wsdl)), + reference("jello", "jello-test"), + reference("wello", "wello-test")), + component("wello-test", + implementation(WelloTest.class, + service(Hello_wsdl), + reference("upper", Upper_wsdl)), + reference("upper", "upper-test")), + component("jello-test", + implementation(JelloTest.class, + service(Hello.class), + reference("upper", Upper.class)), + reference("upper", "upper-test")), + component("upper-test", + implementation(UpperTest.class, + service(Upper.class)))), ec); + + // Register a test instance of our sample implementation ProviderFactory + providerFactories(ec).addProviderFactory(testProviderFactory()); + + // Run with it + node = node(nf, deploy(contrib, comp)); + node.start(); + } + + static ProviderFactory<SampleImplementation> testProviderFactory() { + // This shows how to get called when a provider is created + return new SampleProviderFactory(extensionPoints(ec)) { + public ImplementationProvider createImplementationProvider(RuntimeComponent comp, SampleImplementation impl) { + out.println("Creating a provider for component " + comp.getName()); + return super.createImplementationProvider(comp, impl); + }}; + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } + + @Test + public void jello() { + out.println("RunTestCase.jello"); + final String r = client().jello("Java"); + out.println(r); + assertEquals("HELLO JAVA", r); + } + + @Test + public void wello() { + out.println("RunTestCase.wello"); + final String r = client().wello("WSDL"); + out.println(r); + assertEquals("HELLO WSDL", r); + } + + static Client client() { + return node.getService(Client.class, "client-test/Client"); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/ReadWriteTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/ReadWriteTestCase.java new file mode 100644 index 0000000000..c165fcd94a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/ReadWriteTestCase.java @@ -0,0 +1,93 @@ +/* + * 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 sample.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static sample.impl.TestUtil.here; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.DefaultContributionFactory; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test read/write Sample SCDL implementation elements. + * + * @version $Rev$ $Date$ + */ +public class ReadWriteTestCase { + static XMLInputFactory xif; + static XMLOutputFactory xof; + static StAXArtifactProcessor<Object> xproc; + static ProcessorContext ctx; + + @BeforeClass + public static void setUp() throws Exception { + final DefaultExtensionPointRegistry ep = new DefaultExtensionPointRegistry(); + final Contribution contrib = new DefaultContributionFactory().createContribution(); + contrib.setLocation(here()); + ctx = new ProcessorContext(contrib, null); + xif = XMLInputFactory.newInstance(); + xof = XMLOutputFactory.newInstance(); + final StAXArtifactProcessorExtensionPoint xpep = new DefaultStAXArtifactProcessorExtensionPoint(ep); + xproc = new ExtensibleStAXArtifactProcessor(xpep, xif, xof); + } + + @Test + public void testRead() throws Exception { + final InputStream is = getClass().getClassLoader().getResourceAsStream("test.composite"); + final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx); + assertNotNull(c); + assertEquals("sample.ClientTest", ((SampleImplementation)c.getComponents().get(0).getImplementation()).name); + } + + @Test + public void testReadWrite() throws Exception { + final InputStream is = getClass().getClassLoader().getResourceAsStream("test.composite"); + final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx); + System.out.println("Composite : " + c.getURI()); + for (Component component : c.getComponents()){ + System.out.println(" Component : " + component.getName()); + } + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + XMLStreamWriter writer = xof.createXMLStreamWriter(bos); + xproc.write(c, writer, ctx); + writer.close(); + System.out.println("Written XML = " + bos.toString()); + assertTrue(bos.toString().contains("class=\"sample.WelloTest\"")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/RunTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/RunTestCase.java new file mode 100644 index 0000000000..1faa5b2ca6 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/RunTestCase.java @@ -0,0 +1,75 @@ +/* + * 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 sample.impl; + +import static java.lang.System.out; +import static org.junit.Assert.assertEquals; +import static sample.impl.TestUtil.here; + +import org.apache.tuscany.sca.node.Contribution; +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; + +import sample.Client; + +/** + * Test how to run an SCA contribution containing a test composite on a + * Tuscany runtime node. + * + * @version $Rev$ $Date$ + */ +public class RunTestCase { + static Node node; + + @BeforeClass + public static void setUp() throws Exception { + final NodeFactory nf = NodeFactory.newInstance(); + node = nf.createNode("test.composite", new Contribution("test", here())); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } + + @Test + public void jello() { + out.println("RunTestCase.jello"); + final String r = client().jello("Java"); + out.println(r); + assertEquals("HELLO JAVA", r); + } + + @Test + public void wello() { + out.println("RunTestCase.wello"); + final String r = client().wello("WSDL"); + out.println(r); + assertEquals("HELLO WSDL", r); + } + + static Client client() { + return node.getService(Client.class, "client-test/Client"); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/RunWSTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/RunWSTestCase.java new file mode 100644 index 0000000000..dcade6a818 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/RunWSTestCase.java @@ -0,0 +1,120 @@ +/* + * 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 sample.impl; + +import static java.lang.System.out; +import static org.junit.Assert.assertTrue; +import static sample.impl.TestUtil.here; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.Socket; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.http.jetty.JettyServer; +import org.apache.tuscany.sca.node.Contribution; +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; + +/** + * Test a component that provides and consumes SOAP Web services. + * + * @version $Rev$ $Date$ + */ +public class RunWSTestCase { + static Node node; + static JettyServer jetty; + + @BeforeClass + public static void setUp() throws Exception { + // Start test composite on a Tuscany node + final NodeFactory nf = NodeFactory.newInstance(); + node = nf.createNode("test.composite", new Contribution("test", here())); + node.start(); + + // Mock up a test Web service on http://localhost:8086/wsupper + jetty = new JettyServer((ExtensionPointRegistry)nf.getExtensionPointRegistry()); + jetty.start(); + jetty.addServletMapping("http://localhost:8086/wsupper", new HttpServlet() { + private static final long serialVersionUID = 1L; + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + assertTrue(read(req.getInputStream()).contains("Hello SOAP")); + final String soapresp = + "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" + + "<soapenv:Body><upperResponse xmlns=\"http://sample/upper\">" + + "<result xmlns=\"\">HELLO SOAP</result>" + + "</upperResponse></soapenv:Body></soapenv:Envelope>"; + + write(soapresp, resp.getOutputStream()); + } + }); + } + + @AfterClass + public static void tearDown() throws Exception { + jetty.stop(); + node.stop(); + } + + @Test + public void wsello() throws Exception { + out.println("RunWSTestCase.wsello"); + // Send a SOAP request to the Web service provided by SCA component wsello-test + // on http://localhost:8085/wsello + final Socket s = new Socket("localhost", 8085); + final String soapreq = + "POST /wsello HTTP/1.0\r\n" + + "Content-Type: text/xml; charset=UTF-8\r\n" + + "Content-length: 231\r\n\r\n" + + "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" + + "<soapenv:Body><hello xmlns=\"http://sample/hello\">" + + "<name xmlns=\"\">SOAP</name>" + + "</hello></soapenv:Body></soapenv:Envelope>"; + write(soapreq, s.getOutputStream()); + assertTrue(read(s.getInputStream()).contains("HELLO SOAP")); + } + + static void write(final String s, final OutputStream o) throws IOException { + final OutputStreamWriter w = new OutputStreamWriter(o); + w.write(s); + w.flush(); + } + + static String read(final InputStream i) throws IOException { + return read(new BufferedReader(new InputStreamReader(i))); + } + + static String read(final BufferedReader r) throws IOException { + final String s = r.readLine(); + return s == null? "" : s + read(r); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java new file mode 100644 index 0000000000..d40fdbf6b3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java @@ -0,0 +1,66 @@ +/* + * 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 sample.impl; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.node.Contribution; +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.Ignore; +import org.junit.Test; + +import sample.Upper; + +/** + * Test how to run an SCA contribution containing a test composite on a + * Tuscany runtime node. + * + * @version $Rev$ $Date$ + */ +public class SampleNativeAsyncBareTestCase { + static Node node; + + @BeforeClass + public static void setUp() throws Exception { + final NodeFactory nf = NodeFactory.newInstance(); + String here = SampleNativeAsyncBareTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString(); + // Create the node using the pattern "name of composite file to start" / Contribution to use + node = nf.createNode("testnativeasyncbare.composite", new Contribution("test", here)); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } + + @Test + @Ignore + public void testReference() { + System.out.println("SampleNaiveAsyncBareTestCase.testReference"); + Upper upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + final String r = upper.upper("async"); + System.out.println(r); + assertEquals("ASYNC", r); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncTestCase.java new file mode 100644 index 0000000000..9667150063 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncTestCase.java @@ -0,0 +1,143 @@ +/* + * 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 sample.impl; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import sample.Upper; + +/** + * Test how to run an SCA contribution containing a test composite on a + * Tuscany runtime node. + * + * @version $Rev$ $Date$ + */ +public class SampleNativeAsyncTestCase { + static Node node; + +/* + @BeforeClass + public static void setUp() throws Exception { + final NodeFactory nf = NodeFactory.getInstance(); + String here = SampleNativeAsyncTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString(); + // Create the node using the pattern "name of composite file to start" / Contribution to use + node = nf.createNode("testnativeasync.composite", new Contribution("test", here)); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } +*/ + + @Before + public void setUp() throws Exception { + final NodeFactory nf = NodeFactory.getInstance(); + String here = SampleNativeAsyncTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString(); + // Create the node using the pattern "name of composite file to start" / Contribution to use + node = nf.createNode("testnativeasync.composite", new Contribution("test", here)); + node.start(); + } + + @After + public void tearDown() throws Exception { + node.stop(); + } + + /** + * Show that we can make a basic call + */ + @Test + public void testUpper() { + System.out.println("SampleNaiveAsyncTestCase.testUpper"); + Upper upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + final String r = upper.upper("async"); + System.out.println(r); + assertEquals("ASYNC", r); + } + + /** + * Show that we can make a call that requires us to persist the + * AsyncResponseInvoker + */ + @Test + public void testPersistAsyncResponseInvoker() { + System.out.println("SampleNaiveAsyncTestCase.testUpper2"); + Upper upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + // call upper to write out the async response invoker + String r = upper.upper("async"); + // call upper2 to read it back in again + r = upper.upper2("async2"); + System.out.println(r); + assertEquals("ASYNC2", r); + } + + /** + * Show that we can make a call that works over service restarts + */ + @Test + public void testServiceRestart() { + System.out.println("SampleNaiveAsyncTestCase.testUpper2"); + System.out.println("Starting first node"); + Upper upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + String r = upper.upper("async"); + System.out.println(r); + assertEquals("ASYNC", r); + + System.out.println("Stopping first node"); + node.stop(); + + // now start another node and try call back in to get the + // async response to come back + + System.out.println("Starting second node"); + final NodeFactory nf = NodeFactory.getInstance(); + String here = SampleNativeAsyncTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString(); + // Create the node using the pattern "name of composite file to start" / Contribution to use + node = nf.createNode("testnativeasync.composite", new Contribution("test", here)); + node.start(); + upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + r = upper.upper2("async2"); + System.out.println(r); + assertEquals("ASYNC2", r); + } + + /** + * Show that one-way operations work in the async case + */ + @Test + public void testVoid() { + System.out.println("SampleNaiveAsyncTestCase.testUpperVoid"); + Upper upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + final String r = upper.upperVoid("asyncVoid"); + System.out.println(r); + assertEquals("ASYNCVOID", r); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeJMSAsyncTestCase.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeJMSAsyncTestCase.java new file mode 100644 index 0000000000..ea988981ce --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeJMSAsyncTestCase.java @@ -0,0 +1,64 @@ +/* + * 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 sample.impl; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.node.Contribution; +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; + +import sample.Upper; + +/** + * Test how to run an SCA contribution containing a test composite on a + * Tuscany runtime node. + * + * @version $Rev$ $Date$ + */ +public class SampleNativeJMSAsyncTestCase { + static Node node; + + @BeforeClass + public static void setUp() throws Exception { + final NodeFactory nf = NodeFactory.newInstance(); + String here = SampleNativeJMSAsyncTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString(); + // Create the node using the pattern "name of composite file to start" / Contribution to use + node = nf.createNode("testnativejmsasync.composite", new Contribution("test", here)); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } + + @Test + public void testReference() { + System.out.println("SampleNaiveAsyncTestCase.testReference"); + Upper upper = node.getService(Upper.class, "SampleNativeAsyncReference"); + final String r = upper.upper("async"); + System.out.println(r); + assertEquals("ASYNC", r); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/TestUtil.java b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/TestUtil.java new file mode 100644 index 0000000000..6dcfb33912 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/TestUtil.java @@ -0,0 +1,31 @@ +/* + * 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 sample.impl; + +/** + * A hack to determine the test contribution location. + */ +public class TestUtil { + + static String here() { + return TestUtil.class.getProtectionDomain().getCodeSource().getLocation().toString(); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Hello.wsdl b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Hello.wsdl new file mode 100644 index 0000000000..360cea5ff3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Hello.wsdl @@ -0,0 +1,62 @@ +<?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. +--> +<wsdl:definitions targetNamespace="http://sample/hello" xmlns:tns="http://sample/hello" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="Hello"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://sample/hello" + xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="hello"> + <complexType> + <sequence> + <element name="name" type="xsd:string" /> + </sequence> + </complexType> + </element> + + <element name="helloResponse"> + <complexType> + <sequence> + <element name="result" type="xsd:string" /> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="helloRequest"> + <wsdl:part element="tns:hello" name="parameters" /> + </wsdl:message> + + <wsdl:message name="helloResponse"> + <wsdl:part element="tns:helloResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="Hello"> + <wsdl:operation name="hello"> + <wsdl:input message="tns:helloRequest" name="helloRequest" /> + <wsdl:output message="tns:helloResponse" name="helloResponse" /> + </wsdl:operation> + </wsdl:portType> + +</wsdl:definitions> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl new file mode 100644 index 0000000000..54061067e5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl @@ -0,0 +1,54 @@ +<?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. +--> +<wsdl:definitions targetNamespace="http://sample/upper-async-bare" + xmlns:tns="http://sample/upper-async-bare" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + name="UpperAsyncBare"> + + <wsdl:types> + <schema elementFormDefault="qualified" + targetNamespace="http://sample/upper-async-bare" + xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="arg0" type="xsd:string" /> + <element name="arg1" type="xsd:string" /> + + <element name="result" type="xsd:string" /> + </schema> + </wsdl:types> + + <wsdl:message name="upperRequest"> + <wsdl:part element="tns:arg0" name="arg0" /> + <wsdl:part element="tns:arg1" name="arg1" /> + </wsdl:message> + + <wsdl:message name="upperResponse"> + <wsdl:part element="tns:result" name="result" /> + </wsdl:message> + + <wsdl:portType name="UpperBare" sca:requires="sca:asyncInvocation"> + <wsdl:operation name="upper"> + <wsdl:input message="tns:upperRequest" name="upperRequest" /> + <wsdl:output message="tns:upperResponse" name="upperResponse" /> + </wsdl:operation> + </wsdl:portType> + +</wsdl:definitions> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl new file mode 100644 index 0000000000..adce1542e6 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl @@ -0,0 +1,66 @@ +<?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. +--> +<wsdl:definitions targetNamespace="http://sample/upper-async-wrapped" + xmlns:tns="http://sample/upper-async-wrapped" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + name="UpperAsyncWrapped"> + + <wsdl:types> + <schema elementFormDefault="qualified" + targetNamespace="http://sample/upper-async-wrapped" + xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="upper"> + <complexType> + <sequence> + <element name="arg0" type="xsd:string" /> + <element name="arg1" type="xsd:string" /> + </sequence> + </complexType> + </element> + + <element name="upperResponse"> + <complexType> + <sequence> + <element name="result" type="xsd:string" /> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="upperRequest"> + <wsdl:part element="tns:upper" name="parameters" /> + </wsdl:message> + + <wsdl:message name="upperResponse"> + <wsdl:part element="tns:upperResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="UpperWrapped" sca:requires="sca:asyncInvocation"> + <wsdl:operation name="upper"> + <wsdl:input message="tns:upperRequest" name="upperRequest" /> + <wsdl:output message="tns:upperResponse" name="upperResponse" /> + </wsdl:operation> + </wsdl:portType> + +</wsdl:definitions> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl new file mode 100644 index 0000000000..9a6ab268fb --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl @@ -0,0 +1,72 @@ +<?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. +--> +<wsdl:definitions targetNamespace="http://sample/upper-async" + xmlns:tns="http://sample/upper-async" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + name="UpperAsync"> + + <wsdl:types> + <schema elementFormDefault="qualified" + targetNamespace="http://sample/upper-async" + xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="upper"> + <complexType> + <sequence> + <element name="s" type="xsd:string" /> + </sequence> + </complexType> + </element> + + <element name="upperResponse"> + <complexType> + <sequence> + <element name="result" type="xsd:string" /> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="upperRequest"> + <wsdl:part element="tns:upper" name="parameters" /> + </wsdl:message> + + <wsdl:message name="upperResponse"> + <wsdl:part element="tns:upperResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="Upper" sca:requires="sca:asyncInvocation"> + <wsdl:operation name="upper"> + <wsdl:input message="tns:upperRequest" name="upperRequest" /> + <wsdl:output message="tns:upperResponse" name="upperResponse" /> + </wsdl:operation> + <wsdl:operation name="upper2"> + <wsdl:input message="tns:upperRequest" name="upperRequest" /> + <wsdl:output message="tns:upperResponse" name="upperResponse" /> + </wsdl:operation> + <wsdl:operation name="upperVoid"> + <wsdl:input message="tns:upperRequest" name="upperRequest" /> + </wsdl:operation> + </wsdl:portType> + +</wsdl:definitions> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper.wsdl b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper.wsdl new file mode 100644 index 0000000000..8a148bb5e8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/Upper.wsdl @@ -0,0 +1,62 @@ +<?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. +--> +<wsdl:definitions targetNamespace="http://sample/upper" xmlns:tns="http://sample/upper" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="Upper"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://sample/upper" + xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="upper"> + <complexType> + <sequence> + <element name="s" type="xsd:string" /> + </sequence> + </complexType> + </element> + + <element name="upperResponse"> + <complexType> + <sequence> + <element name="result" type="xsd:string" /> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="upperRequest"> + <wsdl:part element="tns:upper" name="parameters" /> + </wsdl:message> + + <wsdl:message name="upperResponse"> + <wsdl:part element="tns:upperResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="Upper"> + <wsdl:operation name="upper"> + <wsdl:input message="tns:upperRequest" name="upperRequest" /> + <wsdl:output message="tns:upperResponse" name="upperResponse" /> + </wsdl:operation> + </wsdl:portType> + +</wsdl:definitions> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/jndi.properties b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/jndi.properties new file mode 100644 index 0000000000..a38e1778c6 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +#java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +#connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +#queue.HelloWorldService = HelloWorldService + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/test.composite b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/test.composite new file mode 100644 index 0000000000..43a75f50a7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/test.composite @@ -0,0 +1,60 @@ +<?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/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://test" + name="wstest"> + + <!-- Client test component used by the JUnit tests --> + <component name="client-test"> + <t:implementation.sample class="sample.ClientTest"/> + <reference name="wello" target="wello-test"/> + <reference name="jello" target="jello-test"/> + </component> + + <!-- HelloWorld test component that uses WSDL interfaces --> + <component name="wello-test"> + <t:implementation.sample class="sample.WelloTest"/> + <reference name="upper" target="upper-test"/> + </component> + + <!-- HelloWorld test component that uses Java interfaces --> + <component name="jello-test"> + <t:implementation.sample class="sample.JelloTest"/> + <reference name="upper" target="upper-test"/> + </component> + + <!-- HelloWorld test component that uses WSDL interfaces and SOAP Web Services --> + <component name="Wsello-test"> + <t:implementation.sample class="sample.WelloTest"/> + <service name="Hello"> + <binding.ws uri="http://localhost:8085/wsello"/> + </service> + <reference name="upper"> + <binding.ws uri="http://localhost:8086/wsupper"/> + </reference> + </component> + + <!-- Test component converts a string to uppercase --> + <component name="upper-test"> + <t:implementation.sample class="sample.UpperTest"/> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasync.composite b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasync.composite new file mode 100644 index 0000000000..6610b66815 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasync.composite @@ -0,0 +1,34 @@ +<?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/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://test" + name="testnativeasync"> + + <component name="SampleNativeAsyncReference"> + <t:implementation.sample class="sample.UpperSampleAsyncReferenceImpl"/> + <reference name="upper" target="SampleNativeAsyncService"/> + </component> + + <component name="SampleNativeAsyncService"> + <t:implementation.sample class="sample.UpperSampleAsyncServiceImpl"/> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite new file mode 100644 index 0000000000..004ef13559 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite @@ -0,0 +1,36 @@ +<?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/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://test" + name="testnativeasyncbare"> + + <component name="SampleNativeAsyncReference"> + <t:implementation.sample class="sample.UpperSampleAsyncReferenceBareImpl"/> + <reference name="upper" target="SampleNativeAsyncService"> + <interface.wsdl interface="http://sample/upper-async-wrapped#wsdl.interface(UpperWrapped)"/> + </reference> + </component> + + <component name="SampleNativeAsyncService"> + <t:implementation.sample class="sample.UpperSampleAsyncServiceWrappedImpl"/> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativejmsasync.composite b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativejmsasync.composite new file mode 100644 index 0000000000..6012cb25af --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/samples/extending-tuscany/implementation-sample/src/test/resources/testnativejmsasync.composite @@ -0,0 +1,37 @@ +<?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/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://test" + name="testnativejmsasync"> + + <component name="SampleNativeAsyncReference"> + <t:implementation.sample class="sample.UpperSampleAsyncReferenceImpl"/> + <reference name="upper" target="SampleNativeAsyncService"/> + </component> + + <component name="SampleNativeAsyncService"> + <t:implementation.sample class="sample.UpperSampleAsyncServiceImpl"/> + <service name="Upper"> + <binding.jms/> + </service> + </component> + +</composite> |