Author: scheu
Date: Tue Oct 19 15:13:25 2010
New Revision: 1024266
URL: http://svn.apache.org/viewvc?rev=1024266&view=rev
Log:
AXIS2-4857
Contributor:Rich Scheuerle
Summary:
The "caused by exception" is now captured and set during inbound handler
processing.
Validation tests are added to verify the new code.
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersProtocolHandler2.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?rev=1024266&r1=1024265&r2=1024266&view=diff
==
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Tue Oct 19 15:13:25 2010
@@ -63,6 +63,7 @@ import org.apache.axis2.jaxws.sample.add
import
org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerFault_Exception;
import
org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerPortType;
import
org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerService;
+import
org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersProtocolHandler2;
import org.test.addnumbershandler.AddNumbersHandlerResponse;
public class AddNumbersHandlerTests extends AbstractTestCase {
@@ -236,6 +237,8 @@ public class AddNumbersHandlerTests exte
}
+
+
/**
* Client app sends MAXVALUE, MAXVALUE as params to add.
* No client-side handlers are configured for this scenario.
@@ -279,6 +282,7 @@ public class AddNumbersHandlerTests exte
if (t == null) {
fail("Expected AddNumbersHandlerFault_Exception to be thrown");
}
+
if (t instanceof SOAPFaultException) {
expectedException = (SOAPFaultException) t;
} else {
@@ -312,7 +316,7 @@ public class AddNumbersHandlerTests exte
+ "AddNumbersProtocolHandler CLOSE\n"
+ "AddNumbersProtocolHandler PRE_DESTROY\n";
-assertEquals(expected_calls, log);
+assertTrue("Expected : " + expected_calls + " but received " + log,
expected_calls.equals(log));
// The outbound service handler adds the stack trace to the
// message. Make sure the stack trace contains the
AddNumbersHandlerPortTypeImpl
@@ -330,6 +334,66 @@ public class AddNumbersHandlerTests exte
}
+/**
+ * Client app sends MAXVALUE, MAXVALUE as params to add.
+ * No client-side handlers are configured for this scenario.
+ * The endpoint method (addNumbersHandler) will detect the possible
overflow and
+ * throw an unchecked exception, NullPointerException.
+ *
+ * The server-side AddNumbersProtocolHandler will
+ * access the thrown exception using the "jaxws.webmethod.exception"
+ * property and add the stack trace string to fault string.
+ *
+ * The client should receive a SOAPFaultException that has a stack
+ * trace as part of the message.
+ * This test verifies the following:
+ *
+ * 1) Proper exception/fault processing when handlers are installed.
+ * 2) Access to the special "jaxws.webmethod.exception"
+ * 3) Proper exception call flow when an unchecked exception is thrown.
+ */
+public void testAddNumbersHandler_WithHandlerException() throws Exception {
+
+TestLogger.logger.debug("--");
+TestLogger.logger.debug("test: " + getName());
+
+AddNumbersHandlerService service = new AddNumbersHandlerService();
+AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+BindingProvider p = (BindingProvider)proxy;
+p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
+SOAPFaultException expectedException = null;
+Throwable t = null;
+try {
+// Trigger protocol 2 to throw an exception
+AddNumbersProtocolHandler2.throwException = true;
+proxy.addNumbersHandler(-1000, Integer.MIN_VALUE);
+
+} catch (Throwable e) {
+// An exception is expected
+t = e;
+
+} finally {
+AddNumbersProtocolHandler2.throwException = false;
+}
+
+// Make sure the proper exception is thrown
+if (t == null) {
+fail("Expected AddNumbersHandlerFault_Exception to be thrown");
+