cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1157121 - in /cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/
Date Fri, 12 Aug 2011 14:24:47 GMT
Author: ningjiang
Date: Fri Aug 12 14:24:47 2011
New Revision: 1157121

URL: http://svn.apache.org/viewvc?rev=1157121&view=rev
Log:
CXF-3736 Send the cause of exception stack trace

Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java?rev=1157121&r1=1157120&r2=1157121&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
Fri Aug 12 14:24:47 2011
@@ -77,9 +77,16 @@ public abstract class AbstractSoapInterc
             .getContextualProperty(org.apache.cxf.message.Message.FAULT_STACKTRACE_ENABLED);
         if (config != null && Boolean.valueOf(config).booleanValue() && fault.getCause()
!= null) {
             StringBuilder sb = new StringBuilder();
-            for (StackTraceElement ste : fault.getCause().getStackTrace()) {
-                sb.append(ste.getClassName() + "!" + ste.getMethodName() + "!" + ste.getFileName()
+ "!"
+            Throwable throwable = fault.getCause();
+            while (throwable != null) {
+                for (StackTraceElement ste : fault.getCause().getStackTrace()) {
+                    sb.append(ste.getClassName() + "!" + ste.getMethodName() + "!" + ste.getFileName()
+ "!"
                           + ste.getLineNumber() + "\n");
+                }
+                throwable = throwable.getCause();
+                if (throwable != null) {
+                    sb.append("Caused by:" +  throwable.getClass() + ":" + throwable.getMessage()
+ " ");
+                }
             }
             Element detail = fault.getDetail();
             String soapNamespace = message.getVersion().getNamespace();

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java?rev=1157121&r1=1157120&r2=1157121&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
Fri Aug 12 14:24:47 2011
@@ -47,8 +47,10 @@ public class GreeterImpl11 {
     }
 
     public String sayHi() {
-        // throw the exception out
-        Exception cause = new IllegalArgumentException("Get a wrong name <sayHi>");
+        // throw the exception out with some cause
+        Exception cause = new IllegalArgumentException("Get a wrong name <sayHi>"
+                                                       , new NullPointerException("Test cause."));
+        cause.printStackTrace();
         throw new Fault("sayHiFault", LOG, cause);
     }
 

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java?rev=1157121&r1=1157120&r2=1157121&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
Fri Aug 12 14:24:47 2011
@@ -41,7 +41,7 @@ public class Soap11ClientServerTest exte
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly",
-                   launchServer(Server11.class));
+                   launchServer(Server11.class, true));
     }
     
     @Test
@@ -52,9 +52,19 @@ public class Soap11ClientServerTest exte
             fail("Should throw Exception!");
         } catch (SOAPFaultException ex) {
             assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>", ex.getMessage());
-            StackTraceElement[] element = ex.getCause().getStackTrace();
-            assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11", element[0].getClassName());
-        }
+            StackTraceElement[] elements = ex.getCause().getStackTrace();
+            assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11", 
+                         elements[0].getClassName());
+            ex.printStackTrace();
+            boolean findNPE = false;
+            for (StackTraceElement element : elements) {
+                if (element.getClassName().startsWith("Caused by:class java.lang.NullPointerException:
")) {
+                    findNPE = true;
+                    break;
+                }
+            }
+            assertTrue("Cannot find the Cause of NPE", findNPE);
+        } 
     }
     
 



Mime
View raw message