use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testMessageContextProperties.
/*
* Check properties in MessageContext
*/
public void testMessageContextProperties() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
TestService testStub = getTestStub(getService());
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + "0", HA_CHECK_MC_PROPS);
tracker.setHandlerAction(CLIENT_PREFIX + "1", HA_CHECK_MC_PROPS);
tracker.setHandlerAction(CLIENT_PREFIX + "3", HA_CHECK_MC_PROPS);
tracker.setHandlerAction(CLIENT_PREFIX + "4", HA_CHECK_MC_PROPS);
tracker.setHandlerAction(CLIENT_PREFIX + "5", HA_CHECK_MC_PROPS);
tracker.setHandlerAction(CLIENT_PREFIX + "7", HA_CHECK_MC_PROPS);
testStub.testInt(2);
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testHandlerCloseOrder.
/*
* Test to make sure handlers have close() called properly.
*/
public void testHandlerCloseOrder() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
TestService testStub = getTestStub(getService());
int x = 1;
tracker.clearAll();
int y = testStub.testInt(x);
assertEquals("something wrong with testInt service", x, y);
List<String> closedHandlers = tracker.getClosedHandlers();
String[] expectedNames = new String[] { CLIENT_PREFIX + 7, CLIENT_PREFIX + 5, CLIENT_PREFIX + 4, CLIENT_PREFIX + 3, CLIENT_PREFIX + 1, CLIENT_PREFIX + 0 };
for (int i = 0; i < expectedNames.length; i++) {
assertEquals("closed handler names not matching", expectedNames[i], closedHandlers.get(i));
}
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class HandleFaultTest method testClientReturnFalse1.
/*
* Have one of the client handlers throw a protocol exception
* and another handler return false during the handleFault
* method. Handler 5 throws protocol, handler 1 returns
* false.
*/
public void testClientReturnFalse1() throws Exception {
TestService testStub = getTestStub(getService());
HandlerTracker tracker = HandlerTracker.getClientInstance();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandleFaultAction(CLIENT_PREFIX + 1, HF_RETURN_FALSE);
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_THROW_PROTOCOL_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive an exception");
} catch (ProtocolException pe) {
// ok
} catch (Exception oops) {
fail("did not receive WebServiceException. received: " + oops);
}
// check called handlers
String[] called = { "0", "1", "3", "4", "5", "4_FAULT", "3_FAULT", "1_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));
}
// 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
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertEquals("should be no handlers destroyed", 0, destroyedHandlers.size());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class HandleFaultTest method testServerException1.
/*
* Have one of the server handlers throw a protocol exception
* and another handler throw a different exception during the
* handleFault method. Handler 2 throws first exception, then
* handler 4. Should receive the new exception.
*/
public void testServerException1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
// tell the server handlers to register themselves
for (int i = 0; i < numTotalServerHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
// this handler will register being called before throwing PE
reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_PROTOCOL_EXCEPTION_INBOUND);
// the HF_ action does not override the HA_ action
reportStub.setInstruction(SERVER_PREFIX + 4, HF_THROW_RUNTIME_EXCEPTION);
tracker.clearAll();
try {
testStub.testInt(42);
fail("did not receive exception");
} catch (SOAPFaultException sfe) {
// check which exception came back
SOAPFault fault = sfe.getFault();
assertNotNull("did not receive fault in exception", fault);
String handlerMsg = fault.getFaultString();
assertNotNull("null message in exception", handlerMsg);
assertTrue("did not receive the expected exception, received: " + handlerMsg, handlerMsg.startsWith(SERVER_PREFIX + 4));
}
// check called handlers on server side
String[] called = { "4", "2", "4_FAULT" };
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));
}
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class HandleFaultTest method testClientFaultAndProtocolException1.
/*
* Have one of the client handlers insert a fault message
* with fault string msg1 and throw a protocol
* exception with message msg2. Another handler should
* get a message in the handleFault method containing
* a fault with the msg1 fault string.
*
* This tests that the runtime doesn't replace a fault if
* one is already there.
*
* Also checks exception received to make sure the right
* message is there. Check for bug 6232841.
*/
public void testClientFaultAndProtocolException1() throws Exception {
TestService testStub = getTestStub(getService());
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 + 7, HA_INSERT_FAULT_AND_THROW_PE_OUTBOUND);
tracker.setHandleFaultAction(CLIENT_PREFIX + 4, HF_CHECK_FAULT_MESSAGE_STRING);
try {
testStub.testInt(42);
fail("did not receive an exception");
} catch (ProtocolException e) {
assertTrue("did not get correct message", e.getMessage().contains(MESSAGE_IN_FAULT));
} catch (Exception oops) {
fail("did not receive WebServiceException. received: " + oops);
}
// check called handlers
String[] called = { "0", "1", "3", "4", "5", "7", "5_FAULT", "4_FAULT", "3_FAULT", "1_FAULT", "0_FAULT" };
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
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertEquals("should be no handlers destroyed", 0, destroyedHandlers.size());
}
Aggregations