cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r470269 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/interceptor/ rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/ rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/ rt/core/src/main/java/org/apach...
Date Thu, 02 Nov 2006 08:13:18 GMT
Author: tli
Date: Thu Nov  2 00:13:17 2006
New Revision: 470269

URL: http://svn.apache.org/viewvc?view=rev&rev=470269
Log:
CXF-196 fix lost message of runtime exception thrown by SEI impl method for both soap &
xml binding, add unit test on xml binding, also add soap systest to check it

Added:
    incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
  (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFault.java
    incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/TestBase.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java?view=diff&rev=470269&r1=470268&r2=470269
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java Thu Nov  2
00:13:17 2006
@@ -46,7 +46,11 @@
 
     public Fault(Throwable t) {
         super(t);
-        message = super.getMessage();
+        if (super.getMessage() != null) {
+            message = super.getMessage();
+        } else {
+            message = t == null ? null : t.getMessage();
+        }
     }
 
     public String getMessage() {

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFault.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFault.java?view=diff&rev=470269&r1=470268&r2=470269
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFault.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFault.java
Thu Nov  2 00:13:17 2006
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.binding.xml;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ResourceBundle;
 
 import org.apache.cxf.common.i18n.Message;
@@ -29,7 +28,6 @@
     public static final String XML_FAULT_PREFIX = "xfns";
 
     public static final String XML_FAULT_ROOT = "XMLFault";
-
     public static final String XML_FAULT_STRING = "faultstring";
 
     public static final String XML_FAULT_DETAIL = "detail";
@@ -58,9 +56,6 @@
             return (XMLFault) f;
         }
         Throwable th = f.getCause();
-        if (f.getCause() instanceof InvocationTargetException) {
-            th = th.getCause();
-        }
         XMLFault xmlFault = new XMLFault(new Message(f.getMessage(), (ResourceBundle) null),
th);
         xmlFault.setDetail(f.getDetail());
         return xmlFault;

Modified: incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/TestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/TestBase.java?view=diff&rev=470269&r1=470268&r2=470269
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/TestBase.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/TestBase.java
Thu Nov  2 00:13:17 2006
@@ -138,6 +138,7 @@
 
         control.reset();
         JAXBDataBinding db = new JAXBDataBinding();
+        db.initialize(serviceInfo);
         db.setContext(JAXBContext.newInstance(jaxbClasses));
         service.setDataBinding(db);
 

Added: incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java?view=auto&rev=470269
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
(added)
+++ incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
Thu Nov  2 00:13:17 2006
@@ -0,0 +1,88 @@
+/**
+ * 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.cxf.binding.xml.interceptor;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.cxf.binding.xml.XMLFault;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.interceptor.ClientFaultConverter;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.hello_world_xml_http.bare.types.MyComplexStructType;
+
+public class XMLFaultInterceptorsTest extends TestBase {
+
+    public void testRuntimeExceptionOfImpl() throws Exception {
+
+        String ns = "http://apache.org/hello_world_xml_http/wrapped";
+        common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(ns, "XMLPort"), MyComplexStructType.class);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        xmlMessage.setContent(OutputStream.class, baos);
+        xmlMessage.setContent(XMLStreamWriter.class, StaxUtils.createXMLStreamWriter(baos));
+        xmlMessage.setContent(Exception.class, new Fault(new RuntimeException("dummy exception")));
+        XMLFaultOutInterceptor xfo = new XMLFaultOutInterceptor();
+        xfo.setPhase("phase1");
+        chain.add(xfo);
+        InHelpInterceptor ih = new InHelpInterceptor();
+        ClientFaultConverter cfc = new ClientFaultConverter();
+        XMLFaultInInterceptor xfi = new XMLFaultInInterceptor();
+        ih.setPhase("phase2");
+        cfc.setPhase("phase3");
+        xfi.setPhase("phase3");
+        chain.add(ih);
+        chain.add(cfc);
+        chain.add(xfi);
+        chain.doIntercept(xmlMessage);
+        assertNotNull(xmlMessage.getContent(Exception.class));
+        assertTrue(xmlMessage.getContent(Exception.class) instanceof XMLFault);
+        XMLFault xfault = (XMLFault) xmlMessage.getContent(Exception.class);
+        assertTrue("check message expected - dummy exception",
+                xfault.getMessage().indexOf("dummy exception") >= 0);
+    }
+
+    private class InHelpInterceptor extends AbstractInDatabindingInterceptor {
+
+        public void handleMessage(Message message) {
+
+            try {
+                ByteArrayOutputStream baos = (ByteArrayOutputStream) message.getContent(OutputStream.class);
+                ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
+                message.setContent(InputStream.class, bis);
+                XMLStreamReader xsr = StaxUtils.createXMLStreamReader(bis);
+                xsr.nextTag();
+                message.setContent(XMLStreamReader.class, xsr);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+
+        }
+
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java?view=diff&rev=470269&r1=470268&r2=470269
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
Thu Nov  2 00:13:17 2006
@@ -57,14 +57,14 @@
 
         MessageImpl.copyContent(m, faultMessage);
         
-        Exception e = m.getContent(Exception.class);
-        Fault f;
-        if (e instanceof Fault) {
-            f = (Fault) e;
-        } else {
-            f = new Fault(e);
-        }
-        faultMessage.setContent(Exception.class, f);
+//        Exception e = m.getContent(Exception.class);
+//        Fault f;
+//        if (e instanceof Fault) {
+//            f = (Fault) e;
+//        } else {
+//            f = new Fault(e);
+//        }
+//        faultMessage.setContent(Exception.class, f);
         
         // setup chain
         PhaseInterceptorChain chain = new PhaseInterceptorChain(getPhases());

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=470269&r1=470268&r2=470269
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Thu Nov  2 00:13:17 2006
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.jaxws;
 
+
 import java.io.InputStream;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.HttpURLConnection;
@@ -472,7 +473,16 @@
                 assertNotNull(brlf.getFaultInfo());
                 assertEquals("BadRecordLitFault", brlf.getFaultInfo());
             }
+                        
         }
+
+        try {
+            // trigger runtime exception throw of implementor method
+            greeter.testDocLitFault("");
+            fail("Should have thrown Runtime exception");
+        } catch (Exception e) {
+            assertEquals("can't get back original message",  "Unknown source", e.getMessage());
+        } 
     }
     
     public void testGetSayHi() throws Exception {

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java?view=diff&rev=470269&r1=470268&r2=470269
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
Thu Nov  2 00:13:17 2006
@@ -20,6 +20,7 @@
 package org.apache.hello_world_soap_http;
 
 
+import java.io.IOException;
 import java.util.concurrent.Future;
 import java.util.logging.Logger;
 
@@ -81,6 +82,7 @@
             nscl.setCode(ec);
             throw new NoSuchCodeLitFault("TestNoSuchCodeLit", nscl);
         }
+        throw new RuntimeException("Unknown source", new IOException("dummy io exception"));
     }
 
     public void greetMeOneWay(String requestType) {



Mime
View raw message