You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2011/01/10 16:08:33 UTC

svn commit: r1057230 - in /tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src: main/java/sample/api/ main/java/sample/impl/ test/java/sample/ test/java/sample/impl/ test/resources/

Author: slaws
Date: Mon Jan 10 15:08:32 2011
New Revision: 1057230

URL: http://svn.apache.org/viewvc?rev=1057230&view=rev
Log:
Add a simple test case to look a implementations that use doc/lit (bare) interfaces. There was a conversation on the ML about whether databinding is clever enough to translate between bare and wrapped as the data passes from implementation to binding as it's send through a reference. At the moment the test gives me index out of bounds. 

Added:
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite
Modified:
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java
    tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl

Modified: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java?rev=1057230&r1=1057229&r2=1057230&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/api/WSDLReference.java Mon Jan 10 15:08:32 2011
@@ -24,6 +24,7 @@ import org.w3c.dom.Element;
 public interface WSDLReference {
 
     Element call(String op, Element e);
+    public Element callBare(String op, Element... e);
     void callAsync(String op, Element e);
     
 }

Modified: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java?rev=1057230&r1=1057229&r2=1057230&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java Mon Jan 10 15:08:32 2011
@@ -68,6 +68,16 @@ class SampleWSDLProxy implements WSDLRef
     }
     
     @Override
+    public Element callBare(String op, Element... e) {
+        try {
+            // Invoke the named operation on the endpoint reference
+            return (Element)repr.invoke(ops.get(op), e);
+        } catch(InvocationTargetException ex) {
+            throw new RuntimeException(ex);
+        }
+    }    
+    
+    @Override
     public void callAsync(String op, Element e) {
         // Asynchronously invoke the named operation on the endpoint reference
         Message message = mf.createMessage();

Added: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java?rev=1057230&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceBareImpl.java Mon Jan 10 15:08:32 2011
@@ -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();
+    }
+}

Added: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java?rev=1057230&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncServiceWrappedImpl.java Mon Jan 10 15:08:32 2011
@@ -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)));
+    }
+}

Added: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java?rev=1057230&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java (added)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/impl/SampleNativeAsyncBareTestCase.java Mon Jan 10 15:08:32 2011
@@ -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);
+    }
+}

Added: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl?rev=1057230&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl (added)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-bare.wsdl Mon Jan 10 15:08:32 2011
@@ -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>

Added: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl?rev=1057230&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl (added)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async-wrapped.wsdl Mon Jan 10 15:08:32 2011
@@ -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>

Modified: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl?rev=1057230&r1=1057229&r2=1057230&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl (original)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/Upper-async.wsdl Mon Jan 10 15:08:32 2011
@@ -22,7 +22,7 @@
                   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="Upper">
+	              name="UpperAsync">
 
     <wsdl:types>
         <schema elementFormDefault="qualified" 

Added: tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite?rev=1057230&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite (added)
+++ tuscany/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/resources/testnativeasyncbare.composite Mon Jan 10 15:08:32 2011
@@ -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>