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/03/27 12:17:22 UTC

svn commit: r522884 - in /incubator/yoko/trunk/bindings: pom.xml src/test/java/org/apache/yoko/bindings/corba/CorbaSystemExceptionTest.java src/test/resources/wsdl/SystemEx.wsdl

Author: dmiddlem
Date: Tue Mar 27 05:17:21 2007
New Revision: 522884

URL: http://svn.apache.org/viewvc?view=rev&rev=522884
Log:
Commit for YOKO-270:
* Adding test for CORBA system exception support.

Added:
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaSystemExceptionTest.java   (with props)
    incubator/yoko/trunk/bindings/src/test/resources/wsdl/SystemEx.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=522884&r1=522883&r2=522884
==============================================================================
--- incubator/yoko/trunk/bindings/pom.xml (original)
+++ incubator/yoko/trunk/bindings/pom.xml Tue Mar 27 05:17:21 2007
@@ -354,7 +354,6 @@
                             <goal>wsdl2java</goal>
                         </goals>
                     </execution>
-                    <!--
                     <execution>
                         <id>generate-corba-system-exception-test-java-sources</id>
                         <phase>process-test-resources</phase>
@@ -375,7 +374,6 @@
                             <goal>wsdl2java</goal>
                         </goals>
                     </execution>
-                    -->
                 </executions>
             </plugin>
 

Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaSystemExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaSystemExceptionTest.java?view=auto&rev=522884
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaSystemExceptionTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaSystemExceptionTest.java Tue Mar 27 05:17:21 2007
@@ -0,0 +1,206 @@
+/**
+ * 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.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.systemex.SystemExceptionTester;
+import org.apache.schemas.yoko.idl.systemex.SystemExceptionTesterCORBAService;
+
+import junit.framework.TestCase;
+
+public class CorbaSystemExceptionTest extends TestCase {
+
+    public final static int COMM_FAILURE = 1;
+    public final static int TRANSIENT = 2;
+    public final static int NO_PERMISSION = 3;
+   
+    private final QName PORT_NAME = 
+        new QName("http://schemas.apache.org/yoko/idl/SystemEx", "SystemExceptionTesterCORBAPort"); 
+    
+    private final QName SERVICE_NAME = 
+        new QName("http://schemas.apache.org/yoko/idl/SystemEx", "SystemExceptionTesterCORBAService"); 
+    
+    private final static String WSDL_LOCATION = "/wsdl/SystemEx.wsdl";
+    private final static int MAX_WAIT_COUNT = 15;
+    
+    private static TestServer server;
+    private static boolean testServerReady;
+    private SystemExceptionTester client;
+    private URL wsdlUrl;
+
+    public CorbaSystemExceptionTest(String arg0) {
+        super(arg0);
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CorbaSystemExceptionTest.class);
+    }
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+       
+        if (server == null) {
+            server = new TestServer();
+            server.start();
+        }
+
+        int waitCount = 0;
+        // Wait for the server to start if it hasn't already
+        while (waitCount < MAX_WAIT_COUNT && !server.isReady()) {
+            try {
+                Thread.sleep(1000);
+                waitCount++;
+            } catch (Exception ex) {
+                // Consume
+            }
+        }
+
+        if (!server.isReady()) {
+            throw new Exception("Server failed to start in a timely fashion");
+        }
+
+        // Now initialize the client-side
+        try {
+            wsdlUrl = SystemExceptionTester.class.getResource(WSDL_LOCATION);
+        } catch (Exception ex) {
+            throw new Exception("Unable to resolve WSDL location");
+        }
+        
+        SystemExceptionTesterCORBAService service = 
+            new SystemExceptionTesterCORBAService(wsdlUrl, SERVICE_NAME);
+        client = service.getPort(PORT_NAME, SystemExceptionTester.class);
+
+        if (client == null) {
+            throw new Exception("Unable to create client");
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        server.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 (server.isAlive()) {
+            throw new Exception("Did not terminate test server!");
+        }
+    }
+
+    public void testCommFailureException() throws Exception {
+        try {
+            client.testSystemException(COMM_FAILURE);
+        } catch (org.omg.CORBA.COMM_FAILURE ex) {
+            assertTrue(true);
+            return;
+        } catch (Exception ex) {
+            assertTrue(false);
+            return;
+        }
+        assertTrue(false);
+    }
+
+    public void testTransientException() throws Exception {
+        try {
+            client.testSystemException(TRANSIENT);
+        } catch (org.omg.CORBA.TRANSIENT ex) {
+            assertTrue(true);
+            return;
+        } catch (Exception ex) {
+            assertTrue(false);
+            return;
+        }
+        assertTrue(false);
+    }
+
+    public void testNoPermissionException() throws Exception {
+        try {
+            client.testSystemException(NO_PERMISSION);
+        } catch (org.omg.CORBA.NO_PERMISSION ex) {
+            assertTrue(true);
+            return;
+        } catch (Exception ex) {
+            assertTrue(false);
+            return;
+        }
+        assertTrue(false);
+    }
+
+    // A small test server for the test case to interact with
+    public class TestServer extends Thread {
+        private boolean serverReady;
+
+        public TestServer() {
+            serverReady = false;
+        }
+
+        public void run() {
+            Object implementor = new SystemExceptionTesterImpl();
+            String address = "corbaloc::localhost:43210/SystemExTest";
+            Endpoint.publish(address, implementor);
+
+            serverReady = true;
+        }
+
+        public boolean isReady() {
+            return serverReady;
+        }
+    }
+
+    // A minimal bank implementation to test object references
+    @WebService(portName = "SystemExceptionTesterCORBAPort",
+                          serviceName = "SystemExceptionTesterCORBAService",
+                          targetNamespace = "http://schemas.apache.org/yoko/idl/SystemEx",
+                          endpointInterface = "org.apache.schemas.yoko.idl.systemex.SystemExceptionTester")
+    public class SystemExceptionTesterImpl implements SystemExceptionTester {
+        public void testSystemException(int exId) {
+            switch(exId) {
+                case COMM_FAILURE:
+                    throw new org.omg.CORBA.COMM_FAILURE();
+                case TRANSIENT:
+                    throw new org.omg.CORBA.TRANSIENT();
+                case NO_PERMISSION:
+                    throw new org.omg.CORBA.NO_PERMISSION();
+            }
+            // simply return if we don't match the exception id.  The client will flag this as a
+            // failure.
+        }
+    }
+}

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

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

Added: incubator/yoko/trunk/bindings/src/test/resources/wsdl/SystemEx.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/resources/wsdl/SystemEx.wsdl?view=auto&rev=522884
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/resources/wsdl/SystemEx.wsdl (added)
+++ incubator/yoko/trunk/bindings/src/test/resources/wsdl/SystemEx.wsdl Tue Mar 27 05:17:21 2007
@@ -0,0 +1,73 @@
+<?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/SystemEx" xmlns:tns="http://schemas.apache.org/yoko/idl/SystemEx" 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/SystemEx/typemap" />
+  <wsdl:types>
+    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/SystemEx" xmlns="http://schemas.apache.org/yoko/idl/SystemEx" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+      <xs:element name="testSystemException">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="exId" type="xs:int">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="testSystemExceptionResponse">
+        <xs:complexType>
+          <xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </wsdl:types>
+  <wsdl:message name="testSystemException">
+    <wsdl:part name="inparameter" element="tns:testSystemException">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="testSystemExceptionResponse">
+    <wsdl:part name="outparameter" element="tns:testSystemExceptionResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="SystemExceptionTester">
+    <wsdl:operation name="testSystemException">
+      <wsdl:input name="testSystemExceptionRequest" message="tns:testSystemException">
+    </wsdl:input>
+      <wsdl:output name="testSystemExceptionResponse" message="tns:testSystemExceptionResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="SystemExceptionTesterCORBABinding" type="tns:SystemExceptionTester">
+    <corba:binding repositoryID="IDL:SystemExceptionTester:1.0" />
+    <wsdl:operation name="testSystemException">
+      <corba:operation name="testSystemException">
+        <corba:param mode="in" name="exId" idltype="corba:long" />
+      </corba:operation>
+      <wsdl:input name="testSystemExceptionRequest">
+      </wsdl:input>
+      <wsdl:output name="testSystemExceptionResponse">
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="SystemExceptionTesterCORBAService">
+    <wsdl:port name="SystemExceptionTesterCORBAPort" binding="tns:SystemExceptionTesterCORBABinding">
+      <corba:address location="corbaloc::localhost:43210/SystemExTest" />
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

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

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

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