use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientOutboundProtocolException4.
/*
* Have the first handler throw a protocol exception.
* Regression test for bug 6225892. Same test as
* testClientOutboundProtocolException2 except with
* first logical handler in chain.
*/
public void testClientOutboundProtocolException4() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + 0, HA_THROW_PROTOCOL_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive an exception");
} catch (SOAPFaultException e) {
// ok
int breakPointDummyLine = 0;
}
// check result
String[] called = { "0" };
int[] closed = { 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + called[i], calledHandlers.get(i));
}
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("Should be 0 destroyed handlers", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientOutboundProtocolException3.
/*
* Have one of the client handlers throw a SOAPFault exception
* and check that the proper methods are called.
*/
public void testClientOutboundProtocolException3() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_THROW_SOAP_FAULT_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
} catch (SOAPFaultException e) {
// ok
} catch (Exception oops) {
fail("did not receive WebServiceException. received: " + oops);
}
// check result
String[] called = { "0", "1", "3", "4", "5", "4_FAULT", "3_FAULT", "1_FAULT", "0_FAULT" };
int[] closed = { 5, 4, 3, 1, 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + called[i], calledHandlers.get(i));
}
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("Should be 0 destroyed handlers", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientOutboundRuntimeException1.
/*
* Have one of the client handlers throw a runtime exception
* and check that the proper methods are called. This test
* is on outbound message with 2.0 handler (so handleFault
* should not be called on the handler that throws the
* exception).
*/
public void testClientOutboundRuntimeException1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_THROW_RUNTIME_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive any exception.");
} catch (WebServiceException e) {
Throwable cause = e.getCause();
assertNotNull("cause of exception is null", cause);
assertTrue("cause should be runtime exception, instead is " + cause.getClass().toString(), cause instanceof RuntimeException);
}
// check called handlers
// one direction only
int[] called = { 0, 1, 3, 4, 5 };
int[] closed = { 5, 4, 3, 1, 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + called[i], calledHandlers.get(i));
}
// check closed handlers
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// check destroyed handlers -- none in jaxws 2.0
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("destroyed handler list should be empty", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientInboundProtocolException1.
/*
* Have one of the client handlers throw a proper exception
* and check that the proper methods are called. This test
* is on inbound message. Testing with soap handler.
*/
public void testClientInboundProtocolException1() throws Exception {
int badHandler = 5;
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + badHandler, HA_THROW_PROTOCOL_EXCEPTION_INBOUND);
try {
testStub.testInt(42);
fail("should have received a web service exception");
} catch (ProtocolException e) {
assertTrue("ProtocolException message not as expected, but got:" + e.getMessage(), e.getMessage().contains(CLIENT_PREFIX + badHandler));
}
// check called handlers
int[] called = { 0, 1, 3, 4, 5, 7, 7, 5 };
int[] closed = { 7, 5, 4, 3, 1, 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + called[i], calledHandlers.get(i));
}
// check closed handlers
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// check destroyed handlers -- none in jaxws 2.0
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("destroyed handler list should be empty", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientOutboundProtocolException1.
/*
* Have one of the client handlers throw a protocol exception
* and check that the proper methods are called. This test
* is on outbound message with 2.0 handler (so handleFault
* should not be called on the handler that throws the
* exception). Testing with soap handler.
*
* Exception should result in a fault in the message, which
* is dispatched to and wrapped by the client.
*
* This test checks the fault code as well -- test for
* bug 6350633.
*/
public void testClientOutboundProtocolException1() throws Exception {
// the expected fault code local part
String client = "Client";
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_THROW_PROTOCOL_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive an exception");
} catch (SOAPFaultException e) {
SOAPFault fault = e.getFault();
String faultCode = fault.getFaultCode();
assertTrue("fault code should end with \"" + client + "\": " + faultCode, faultCode.endsWith(client));
}
// check result
String[] called = { "0", "1", "3", "4", "5", "4_FAULT", "3_FAULT", "1_FAULT", "0_FAULT" };
int[] closed = { 5, 4, 3, 1, 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + called[i], calledHandlers.get(i));
}
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("Should be 0 destroyed handlers", destroyedHandlers.isEmpty());
}
Aggregations