incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r530472 - in /incubator/yoko/trunk/bindings: ./ src/main/java/org/apache/yoko/bindings/corba/ src/main/java/org/apache/yoko/bindings/corba/interceptors/ src/main/java/org/apache/yoko/bindings/corba/types/ src/main/resources/META-INF/cxf/ sr...
Date Thu, 19 Apr 2007 16:18:56 GMT
Author: bravi
Date: Thu Apr 19 09:18:54 2007
New Revision: 530472

URL: http://svn.apache.org/viewvc?view=rev&rev=530472
Log:
Fixing test failures because of cxf-api changes & also added a UserException test case.

Added:
    incubator/yoko/trunk/bindings/src/main/resources/META-INF/cxf/cxf.extension
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaExceptionTest.java
  (with props)
Removed:
    incubator/yoko/trunk/bindings/src/main/resources/META-INF/cxf/cxf-extension.xml
Modified:
    incubator/yoko/trunk/bindings/pom.xml
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java

Modified: incubator/yoko/trunk/bindings/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/pom.xml?view=diff&rev=530472&r1=530471&r2=530472
==============================================================================
--- incubator/yoko/trunk/bindings/pom.xml (original)
+++ incubator/yoko/trunk/bindings/pom.xml Thu Apr 19 09:18:54 2007
@@ -355,7 +355,7 @@
                         </goals>
                     </execution>
                     <execution>
-                        <id>generate-corba-system-exception-test-java-sources</id>
+                        <id>generate-corba-exception-test-java-sources</id>
                         <phase>process-test-resources</phase>
                         <configuration>
                             <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
@@ -363,6 +363,14 @@
                                 <wsdlOption>
                                     <wsdl>
                                         ${basedir}/src/test/resources/wsdl/SystemEx.wsdl
+                                    </wsdl>
+                                    <extraargs>
+                                        <extraarg>-verbose</extraarg>
+                                    </extraargs>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>
+                                        ${basedir}/src/test/resources/wsdl/exceptions.wsdl
                                     </wsdl>
                                     <extraargs>
                                         <extraarg>-verbose</extraarg>

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java?view=diff&rev=530472&r1=530471&r2=530472
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
Thu Apr 19 09:18:54 2007
@@ -181,7 +181,6 @@
         try {
             request.invoke();
         } catch (SystemException ex) {
-            ex.printStackTrace();
             message.setContent(Exception.class, new Fault(ex));
             message.setSystemException(ex);
             return;
@@ -354,13 +353,16 @@
             CorbaMessage corbaMsg = (CorbaMessage) message;
             if (corbaMsg.getStreamableException() != null) {
                 exchange.setInFaultMessage(corbaMsg);
-                inCorbaMsg.setStreamableException(corbaMsg.getStreamableException());   
            
+                inCorbaMsg.setStreamableException(corbaMsg.getStreamableException());
+                inCorbaMsg.setContent(Exception.class, corbaMsg.getContent(Exception.class));
             } else if (corbaMsg.getSystemException() != null) {
                 exchange.setInFaultMessage(corbaMsg);
                 inCorbaMsg.setSystemException(corbaMsg.getSystemException());
+                inCorbaMsg.setContent(Exception.class, corbaMsg.getContent(Exception.class));
             }
             LOG.log(Level.FINE, "incoming observer is " + incomingObserver);
-            incomingObserver.onMessage((Message)inCorbaMsg);          
+            incomingObserver.onMessage((Message)inCorbaMsg);
+            message.setContent(Exception.class, inCorbaMsg.getContent(Exception.class));
         }
 
     }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java?view=diff&rev=530472&r1=530471&r2=530472
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java
Thu Apr 19 09:18:54 2007
@@ -109,7 +109,6 @@
                 }
                 corbaStaxObject.setOrb(orb);
                 QName elName = new QName("", exStreamable.getName());
-
                 XMLInputFactory inputFactory = getXMLInputFactory();
                 XMLOutputFactory outputFactory = getXMLOutputFactory();
                 

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java?view=diff&rev=530472&r1=530471&r2=530472
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
Thu Apr 19 09:18:54 2007
@@ -219,7 +219,6 @@
         writer.write(fault, faultPart, evtWriter);
         evtWriter.flush();
         LOG.log(Level.INFO, "Found exception in the raises list.  Marshalling.");
-       
         ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
         XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
         CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, exIdlType);

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java?view=diff&rev=530472&r1=530471&r2=530472
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
Thu Apr 19 09:18:54 2007
@@ -132,6 +132,7 @@
         XmlSchemaType schemaType = null;
         if (type != null) {
             schemaType = CorbaUtils.getXmlSchemaType(serviceInfo, type.getType());
+            name = new QName(type.getType().getNamespaceURI(), name.getLocalPart());
         }
         return initializeObjectHandler(orb, name, idlType, schemaType, typeMaps, serviceInfo);
     }
@@ -245,8 +246,9 @@
         boolean isOctets = baseType.getType().equals(W3CConstants.NT_SCHEMA_BASE64)
             || baseType.getType().equals(W3CConstants.NT_SCHEMA_HBIN);
         QName elementName = name;
+        XmlSchemaElement el = null;
         if (!isOctets) {
-            XmlSchemaElement el = CorbaHandlerUtils.getXmlSchemaSequenceElement(schemaType,
serviceInfo);
+            el = CorbaHandlerUtils.getXmlSchemaSequenceElement(schemaType, serviceInfo);
             elementName = el.getQName();
             if (!CorbaUtils.isElementFormQualified(serviceInfo, name.getNamespaceURI()))
{
                 elementName = new QName("", elementName.getLocalPart());
@@ -265,12 +267,12 @@
             // This is an unbounded sequence.  Store a 'template' object that we can use
to create
             // new objects as needed
             CorbaObjectHandler elementObj = 
-                initializeObjectHandler(orb, elementName, seqElementType, typeMaps, serviceInfo);
+                initializeObjectHandler(orb, elementName, seqElementType, el, typeMaps, serviceInfo);
             ((CorbaSequenceHandler)obj).setTemplateElement(elementObj);
         }
         for (int i = 0; i < seqBound; ++i) {
             CorbaObjectHandler elementObj = 
-                initializeObjectHandler(orb, elementName, seqElementType, typeMaps, serviceInfo);
+                initializeObjectHandler(orb, elementName, seqElementType, el, typeMaps, serviceInfo);
             ((CorbaSequenceHandler)obj).addElement(elementObj);
         }
     }
@@ -345,6 +347,7 @@
         CorbaObjectHandler discObj = initializeObjectHandler(orb, 
                                                              new QName("discriminator"),
                                                              unionType.getDiscriminator(),
+                                                             null,
                                                              typeMaps,
                                                              serviceInfo);
         ((CorbaUnionHandler)obj).setDiscriminator(discObj);

Added: incubator/yoko/trunk/bindings/src/main/resources/META-INF/cxf/cxf.extension
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/resources/META-INF/cxf/cxf.extension?view=auto&rev=530472
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/resources/META-INF/cxf/cxf.extension (added)
+++ incubator/yoko/trunk/bindings/src/main/resources/META-INF/cxf/cxf.extension Thu Apr 19
09:18:54 2007
@@ -0,0 +1 @@
+META-INF/cxf/cxf-extension-corba.xml
\ No newline at end of file

Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaExceptionTest.java?view=auto&rev=530472
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaExceptionTest.java
(added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaExceptionTest.java
Thu Apr 19 09:18:54 2007
@@ -0,0 +1,182 @@
+/**
+ * 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.idl.except.ExceptionTest;
+import org.apache.schemas.idl.except.ExceptionTestCORBAService;
+import org.apache.schemas.idltypes.except.ExceptionTestReviewData;
+import org.apache.schemas.idltypes.except.ExceptionTestReviewDataResult;
+
+import junit.framework.TestCase;
+
+public class CorbaExceptionTest extends TestCase {
+
+    private final QName PORT_NAME = 
+        new QName("http://schemas.apache.org/idl/except", "ExceptionTestCORBAPort"); 
+    
+    private final QName SERVICE_NAME = 
+        new QName("http://schemas.apache.org/idl/except", "ExceptionTestCORBAService"); 
+        
+
+    private final static String WSDL_LOCATION = "/wsdl/exceptions.wsdl";
+    private final static int MAX_WAIT_COUNT = 15;
+    
+    private static TestServer server;
+    private static boolean testServerReady;
+    private ExceptionTest client;
+    private URL wsdlUrl;
+
+    public CorbaExceptionTest(String arg0) {
+        super(arg0);
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CorbaExceptionTest.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 = ExceptionTest.class.getResource(WSDL_LOCATION);
+        } catch (Exception ex) {
+            throw new Exception("Unable to resolve WSDL location");
+        }
+        
+        ExceptionTestCORBAService service = 
+            new ExceptionTestCORBAService(wsdlUrl, SERVICE_NAME);
+        client = service.getPort(PORT_NAME, ExceptionTest.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 testBadRecordException() throws Exception {
+        try {
+            ExceptionTestReviewData data = new ExceptionTestReviewData();
+            data.setData("testbadrecord");
+            client.reviewData(data);
+        } catch (org.apache.schemas.idl.except.BadRecord ex) {
+            assertTrue(true);
+            return;
+        } catch (Exception ex) {
+            Throwable t = ex.getCause();
+            if ((t != null) && (t instanceof org.apache.schemas.idl.except.BadRecord))
{
+                assertTrue(true);
+                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 ExceptionTestImpl();
+            String address = "corbaloc::localhost:40000/except";
+            Endpoint ep = Endpoint.create("http://schemas.apache.org/yoko/bindings/corba",
implementor);
+            String wsdlLocation = getClass().getResource("/wsdl/exceptions.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 minimal bank implementation to test object references
+    @WebService(portName = "ExceptionTestCORBAPort",
+                          serviceName = "ExceptionTestCORBAService",
+                          targetNamespace = "http://schemas.apache.org/idl/except",
+                          endpointInterface = "org.apache.schemas.idl.except.ExceptionTest")
+    public class ExceptionTestImpl implements ExceptionTest {
+        public ExceptionTestReviewDataResult reviewData(ExceptionTestReviewData exId)
+            throws org.apache.schemas.idl.except.BadRecord {           
+            throw new org.apache.schemas.idl.except.BadRecord("test",
+                                                              new org.apache.schemas.idltypes.except.BadRecord());
+        }
+    }
+}

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

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



Mime
View raw message