You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by dm...@apache.org on 2007/04/20 17:15:12 UTC

svn commit: r530856 - in /incubator/yoko/trunk/bindings: pom.xml src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java src/test/resources/wsdl/OpNames.wsdl

Author: dmiddlem
Date: Fri Apr 20 10:15:11 2007
New Revision: 530856

URL: http://svn.apache.org/viewvc?view=rev&rev=530856
Log:
Commit for YOKO-351:
* Adding a binding runtime test for name mangling.

Added:
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java   (with props)
    incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl   (with props)
Modified:
    incubator/yoko/trunk/bindings/pom.xml

Modified: incubator/yoko/trunk/bindings/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/pom.xml?view=diff&rev=530856&r1=530855&r2=530856
==============================================================================
--- incubator/yoko/trunk/bindings/pom.xml (original)
+++ incubator/yoko/trunk/bindings/pom.xml Fri Apr 20 10:15:11 2007
@@ -382,6 +382,26 @@
                             <goal>wsdl2java</goal>
                         </goals>
                     </execution>
+                    <execution>
+                        <id>generate-duplicate-operation-name-test-java-sources</id>
+                        <phase>process-test-resources</phase>
+                        <configuration>
+                            <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
+                            <wsdlOptions>
+                                <wsdlOption>
+                                    <wsdl>
+                                        ${basedir}/src/test/resources/wsdl/OpNames.wsdl
+                                    </wsdl>
+                                    <extraargs>
+                                        <extraarg>-verbose</extraarg>
+                                    </extraargs>
+                                </wsdlOption>
+                            </wsdlOptions>
+                        </configuration>
+                        <goals>
+                            <goal>wsdl2java</goal>
+                        </goals>
+                    </execution>
                 </executions>
             </plugin>
 

Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java?view=auto&rev=530856
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java Fri Apr 20 10:15:11 2007
@@ -0,0 +1,269 @@
+/**
+ * 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 org.apache.yoko.bindings.corba;
+
+import java.io.File;
+import java.util.HashMap;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
+
+import org.apache.schemas.yoko.idl.opnames.M1M1Interface;
+import org.apache.schemas.yoko.idl.opnames.M1M1InterfaceCORBAService;
+import org.apache.schemas.yoko.idl.opnames.M2M2Interface;
+import org.apache.schemas.yoko.idl.opnames.M2M2InterfaceCORBAService;
+
+import junit.framework.TestCase;
+
+public class CorbaOperationNameManglingTest extends TestCase {
+
+    private final QName INTERFACE1_PORT_NAME = 
+        new QName("http://schemas.apache.org/yoko/idl/OpNames", "M1.M1InterfaceCORBAPort"); 
+    
+    private final QName INTERFACE1_SERVICE_NAME = 
+        new QName("http://schemas.apache.org/yoko/idl/OpNames", "M1.M1InterfaceCORBAService"); 
+    
+    private final QName INTERFACE2_PORT_NAME = 
+        new QName("http://schemas.apache.org/yoko/idl/OpNames", "M2.M2InterfaceCORBAPort"); 
+    
+    private final QName INTERFACE2_SERVICE_NAME = 
+        new QName("http://schemas.apache.org/yoko/idl/OpNames", "M2.M2InterfaceCORBAService"); 
+    
+    private final static String WSDL_LOCATION = "/wsdl/OpNames.wsdl";
+    private final static int MAX_WAIT_COUNT = 15;
+    
+    private static TestInterface1Server server1;
+    private static TestInterface2Server server2;
+    private static boolean testServerReady;
+    private M1M1Interface client1;
+    private M2M2Interface client2;
+    private URL wsdlUrl;
+
+    public CorbaOperationNameManglingTest(String arg0) {
+        super(arg0);
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CorbaOperationNameManglingTest.class);
+    }
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+       
+        if (server1 == null) {
+            server1 = new TestInterface1Server();
+            server1.start();
+        }
+
+        int waitCount = 0;
+        // Wait for the server to start if it hasn't already
+        while (waitCount < MAX_WAIT_COUNT && !server1.isReady()) {
+            try {
+                Thread.sleep(1000);
+                waitCount++;
+            } catch (Exception ex) {
+                // Consume
+            }
+        }
+
+        if (!server1.isReady()) {
+            throw new Exception("Server1 failed to start in a timely fashion");
+        }
+        
+        if (server2 == null) {
+            server2 = new TestInterface2Server();
+            server2.start();
+        }
+
+        waitCount = 0;
+        // Wait for the server to start if it hasn't already
+        while (waitCount < MAX_WAIT_COUNT && !server2.isReady()) {
+            try {
+                Thread.sleep(1000);
+                waitCount++;
+            } catch (Exception ex) {
+                // Consume
+            }
+        }
+
+        if (!server2.isReady()) {
+            throw new Exception("Server2 failed to start in a timely fashion");
+        }
+
+        // Now initialize the client-side
+        try {
+            wsdlUrl = M1M1Interface.class.getResource(WSDL_LOCATION);
+        } catch (Exception ex) {
+            throw new Exception("Unable to resolve WSDL location");
+        }
+        
+        M1M1InterfaceCORBAService service1 = 
+            new M1M1InterfaceCORBAService(wsdlUrl, INTERFACE1_SERVICE_NAME);
+        client1 = service1.getPort(INTERFACE1_PORT_NAME, M1M1Interface.class);
+
+        if (client1 == null) {
+            throw new Exception("Unable to create client1");
+        }
+        
+        M2M2InterfaceCORBAService service2 = 
+            new M2M2InterfaceCORBAService(wsdlUrl, INTERFACE2_SERVICE_NAME);
+        client2 = service2.getPort(INTERFACE2_PORT_NAME, M2M2Interface.class);
+
+        if (client2 == null) {
+            throw new Exception("Unable to create client2");
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        server1.interrupt();
+
+        try {
+            // Sleep for 3 seconds waiting for the server to shut down
+            Thread.sleep(3000);
+        } catch (Exception ex) {
+            // Move on to check if the server is down
+        }
+
+        if (server1.isAlive()) {
+            throw new Exception("Did not terminate test server!");
+        }
+        
+        server2.interrupt();
+
+        try {
+            // Sleep for 3 seconds waiting for the server to shut down
+            Thread.sleep(3000);
+        } catch (Exception ex) {
+            // Move on to check if the server is down
+        }
+
+        if (server2.isAlive()) {
+            throw new Exception("Did not terminate test server!");
+        }
+    }
+
+    public void testM1M1InterfaceTestOp() {
+        String result = null;
+        try {
+            result = client1.testOp();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            assertTrue(false);
+        }
+        assertNotNull(result);
+        assertTrue(result.equals("M1Interface"));
+    }
+    
+    public void testM2M2InterfaceTestOp() {
+        String result = null;
+        try {
+            result = client2.m2M2InterfaceTestOp();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            assertTrue(false);
+        }
+        assertNotNull(result);
+        assertTrue(result.equals("M2Interface"));
+    }
+
+    
+    // A small test server for the test case to interact with
+    public class TestInterface1Server extends Thread {
+        private boolean serverReady;
+
+        public TestInterface1Server() {
+            serverReady = false;
+        }
+
+        public void run() {
+            Object implementor = new M1InterfaceImpl();
+            String address = "corbaloc::localhost:11111/M1Interface";
+            Endpoint ep = Endpoint.create("http://schemas.apache.org/yoko/bindings/corba", implementor);
+            String wsdlLocation = getClass().getResource("/wsdl/OpNames.wsdl").toString();
+            Map<String, Object> props = new HashMap<String, Object>();
+            props.put("javax.xml.ws.wsdl.description", wsdlLocation);
+            ep.setProperties(props);
+            ep.publish(address);
+            serverReady = true;
+        }
+
+        public boolean isReady() {
+            return serverReady;
+        }
+    }
+
+    // A small test server for the test case to interact with
+    public class TestInterface2Server extends Thread {
+        private boolean serverReady;
+
+        public TestInterface2Server() {
+            serverReady = false;
+        }
+
+        public void run() {
+            Object implementor = new M2InterfaceImpl();
+            String address = "corbaloc::localhost:22222/M2Interface";
+            Endpoint ep = Endpoint.create("http://schemas.apache.org/yoko/bindings/corba", implementor);
+            String wsdlLocation = getClass().getResource("/wsdl/OpNames.wsdl").toString();
+            Map<String, Object> props = new HashMap<String, Object>();
+            props.put("javax.xml.ws.wsdl.description", wsdlLocation);
+            ep.setProperties(props);
+            ep.publish(address);
+            serverReady = true;
+        }
+
+        public boolean isReady() {
+            return serverReady;
+        }
+    }
+
+    @WebService(portName = "M1.M1InterfaceCORBAPort",
+                          serviceName = "M1.M1InterfaceCORBAService",
+                          targetNamespace = "http://schemas.apache.org/yoko/idl/OpNames",
+                          endpointInterface = "org.apache.schemas.yoko.idl.opnames.M1M1Interface")
+    public class M1InterfaceImpl implements M1M1Interface {
+       public String testOp() {
+           return "M1Interface";
+       }
+    }
+
+    @WebService(portName = "M2.M2InterfaceCORBAPort",
+                          serviceName = "M2.M2InterfaceCORBAService",
+                          targetNamespace = "http://schemas.apache.org/yoko/idl/OpNames",
+                          endpointInterface = "org.apache.schemas.yoko.idl.opnames.M2M2Interface")
+    public class M2InterfaceImpl implements M2M2Interface {
+       public String m2M2InterfaceTestOp() {
+           return "M2Interface";
+       }
+    }
+}

Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaOperationNameManglingTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl?view=auto&rev=530856
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl (added)
+++ incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl Fri Apr 20 10:15:11 2007
@@ -0,0 +1,120 @@
+<?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://schemas.apache.org/yoko/idl/OpNames" xmlns:tns="http://schemas.apache.org/yoko/idl/OpNames" xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <corba:typeMapping targetNamespace="http://schemas.apache.org/yoko/idl/OpNames/typemap" />
+  <wsdl:types>
+    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/OpNames" xmlns="http://schemas.apache.org/yoko/idl/OpNames" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+      <xs:element name="testOp">
+        <xs:complexType>
+          <xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="testOpResponse">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="return" type="xs:string">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="M2_M2Interface_testOp">
+        <xs:complexType>
+          <xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="M2_M2Interface_testOpResponse">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="return" type="xs:string">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </wsdl:types>
+  <wsdl:message name="M2_M2Interface_testOpResponse">
+    <wsdl:part name="outparameter" element="tns:M2_M2Interface_testOpResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="testOp">
+    <wsdl:part name="inparameter" element="tns:testOp">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="testOpResponse">
+    <wsdl:part name="outparameter" element="tns:testOpResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="M2_M2Interface_testOp">
+    <wsdl:part name="inparameter" element="tns:M2_M2Interface_testOp">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="M1.M1Interface">
+    <wsdl:operation name="testOp">
+      <wsdl:input name="testOpRequest" message="tns:testOp">
+    </wsdl:input>
+      <wsdl:output name="testOpResponse" message="tns:testOpResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:portType name="M2.M2Interface">
+    <wsdl:operation name="M2_M2Interface_testOp">
+      <wsdl:input name="M2_M2Interface_testOpRequest" message="tns:M2_M2Interface_testOp">
+    </wsdl:input>
+      <wsdl:output name="M2_M2Interface_testOpResponse" message="tns:M2_M2Interface_testOpResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="M1.M1InterfaceCORBABinding" type="tns:M1.M1Interface">
+    <corba:binding repositoryID="IDL:M1/M1Interface:1.0" />
+    <wsdl:operation name="testOp">
+      <corba:operation name="testOp">
+        <corba:return name="return" idltype="corba:string" />
+      </corba:operation>
+      <wsdl:input name="testOpRequest">
+      </wsdl:input>
+      <wsdl:output name="testOpResponse">
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:binding name="M2.M2InterfaceCORBABinding" type="tns:M2.M2Interface">
+    <corba:binding repositoryID="IDL:M2/M2Interface:1.0" />
+    <wsdl:operation name="M2_M2Interface_testOp">
+      <corba:operation name="testOp">
+        <corba:return name="return" idltype="corba:string" />
+      </corba:operation>
+      <wsdl:input name="M2_M2Interface_testOpRequest">
+      </wsdl:input>
+      <wsdl:output name="M2_M2Interface_testOpResponse">
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="M2.M2InterfaceCORBAService">
+    <wsdl:port name="M2.M2InterfaceCORBAPort" binding="tns:M2.M2InterfaceCORBABinding">
+      <corba:address location="corbaloc::localhost:22222/M2Interface" />
+    </wsdl:port>
+  </wsdl:service>
+  <wsdl:service name="M1.M1InterfaceCORBAService">
+    <wsdl:port name="M1.M1InterfaceCORBAPort" binding="tns:M1.M1InterfaceCORBABinding">
+      <corba:address location="corbaloc::localhost:11111/M1Interface" />
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Propchange: incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/yoko/trunk/bindings/src/test/resources/wsdl/OpNames.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml