use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testServerInboundRuntimeException2.
/*
* Have one of the server handlers throw a runtime
* exception and check that the proper methods are called.
* This test uses a protocol handler.
*/
public void testServerInboundRuntimeException2() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
// these lines make calls to the server
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_RUNTIME_EXCEPTION_INBOUND);
// so we clear out the client handlers afterwards
tracker.clearAll();
try {
testStub.testInt(3);
fail("did not receive exception");
} catch (ProtocolException e) {
// ok
}
// check result
String[] called = { "4", "2" };
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
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", SERVER_PREFIX + called[i], calledHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
assertTrue("Should be no destroyed handlers", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testServerInboundRuntimeException1.
/*
* Have one of the server handlers throw a runtime
* exception and check that the proper methods are called.
* This test uses a logical handler.
*/
public void testServerInboundRuntimeException1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
// these lines make calls to the server
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 1, HA_THROW_RUNTIME_EXCEPTION_INBOUND);
// so we clear out the client handlers afterwards
tracker.clearAll();
try {
testStub.testInt(3);
fail("did not receive exception");
} catch (ProtocolException e) {
// pass
}
// check result
String[] called = { "4", "2", "1" };
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
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", SERVER_PREFIX + called[i], calledHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
assertTrue("Should be no destroyed handlers", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testServerOutboundSOAPFault1.
/*
* Have one of the server handlers throw a soap protocol
* exception and check that the proper methods are called.
*/
public void testServerOutboundSOAPFault1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
// these lines make calls to the server
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_SOAP_FAULT_EXCEPTION_OUTBOUND);
// clear out the client handlers afterwards and set instructions
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
try {
testStub.testInt(3);
fail("did not receive exception");
} catch (ProtocolException e) {
// ok
}
// check result
List<String> clientCalledHandlers = tracker.getCalledHandlers();
List<String> clientClosedHandlers = tracker.getClosedHandlers();
// check client handlers
String[] clientCalled = { "0", "1", "3", "4", "5", "7", "7_FAULT", "5_FAULT", "4_FAULT", "3_FAULT", "1_FAULT", "0_FAULT" };
int[] clientClosed = { 7, 5, 4, 3, 1, 0 };
assertEquals("Did not get proper number of called handlers", clientCalled.length, clientCalledHandlers.size());
for (int i = 0; i < clientCalled.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + clientCalled[i], clientCalledHandlers.get(i));
}
assertEquals("Did not get proper number of closed handlers", clientClosed.length, clientClosedHandlers.size());
for (int i = 0; i < clientClosed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + clientClosed[i], clientClosedHandlers.get(i));
}
// check server after client because it makes calls through the handlers
String[] serverCalled = { "4", "2", "1", "0", "0", "1", "2" };
List<String> serverCalledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
assertEquals("Did not get proper number of called handlers", serverCalled.length, serverCalledHandlers.size());
for (int i = 0; i < serverCalled.length; i++) {
assertEquals("did not find expected handler", SERVER_PREFIX + serverCalled[i], serverCalledHandlers.get(i));
}
// too many closes on server to check them all
// should be no destroyed handlers
List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
assertEquals("Should be 0 destroyed handlers", 0, destroyedHandlers.size());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientInboundRuntimeException1.
/*
* Have one of the client handlers throw a runtime exception
* and check that the proper methods are called. This test
* is on inbound message. Testing with soap handler.
*/
public void testClientInboundRuntimeException1() 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_RUNTIME_EXCEPTION_INBOUND);
try {
testStub.testInt(42);
fail("should have received a runtime 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
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 testServiceSpecificException1.
/*
* Have the endpoint throw a service specific exception and make
* sure that the client gets it back. Test case for bug 6232002.
*/
public void testServiceSpecificException1() throws Exception {
TestService_Service service = getService();
HandlerTracker tracker = HandlerTracker.getClientInstance();
// get stubs and clear the trackers
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
reportStub.clearHandlerTracker();
tracker.clearAll();
try {
testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
fail("did not receive exception (1)");
} catch (MyFaultException mfe) {
// passed
} catch (Exception e) {
fail("did not receive MyFaultException (1), received " + e);
}
// check closed handlers to be sure
List<String> actualClosed = tracker.getClosedHandlers();
int[] closed = { 7, 5, 4, 3, 1, 0 };
assertEquals("Did not get proper number of closed handlers", closed.length, actualClosed.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], actualClosed.get(i));
}
// remove all client handlers and try again
Binding binding = ((BindingProvider) testStub).getBinding();
binding.setHandlerChain(new ArrayList<Handler>());
tracker.clearAll();
try {
testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
fail("did not receive exception (2)");
} catch (MyFaultException mfe) {
// passed
} catch (Exception e) {
fail("did not receive MyFaultException (2), received " + e);
}
// this just makes sure there really were no handlers
actualClosed = tracker.getClosedHandlers();
assertTrue("should not have been closed handlers", actualClosed.isEmpty());
}
Aggregations