use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testClientOneWayReturnFalse1.
/*
* Have one of the client handlers return false during a
* one-way request. The handler chain caller should stop
* calling handlers and dispatch the message to the endpoint.
*
* Also check the server handlers to make sure the message
* went through to the endpoint.
*/
public void testClientOneWayReturnFalse1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
tracker.clearAll();
// tell server handlers to register
for (int i = 0; i < numTotalServerHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + 0, HA_RETURN_FALSE);
// make one-way call
testStub.testIntOneWay(0);
// handler 0 won't register
int[] closed = { 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("did not get the right number of called handlers", 0, calledHandlers.size());
assertEquals("did not get the right number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not get expected handler name", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// check server handlers
tracker.clearAll();
int[] serverExpected = { 4, 2, 1, 0 };
List<String> serverCalled = reportStub.getReport(REPORT_CALLED_HANDLERS);
assertEquals("did not get the right number of called handlers", serverExpected.length, serverCalled.size());
for (int i = 0; i < serverExpected.length; i++) {
assertEquals("did not get expected handler name", SERVER_PREFIX + serverExpected[i], serverCalled.get(i));
}
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testServerOneWayReturnFalse2.
/*
*
* Have one of the server handlers return false during a
* one-way request. The handler chain caller should stop
* calling handlers and dispatch the message to the endpoint.
*
* Same as testServerInboundReturnFalse2 but with a different
* handler returning false.
*/
public void testServerOneWayReturnFalse2() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalServerHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 1, HA_RETURN_FALSE);
tracker.clearAll();
testStub.testIntOneWay(0);
// handler 1 will not register
int[] calledNames = { 4, 2 };
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
assertEquals("did not get the right number of called handlers", calledNames.length, calledHandlers.size());
for (int i = 0; i < calledNames.length; i++) {
assertEquals("did not get expected handler name", SERVER_PREFIX + calledNames[i], calledHandlers.get(i));
}
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testClientOutboundReturnFalse1.
/*
* Have one of the client handlers return false.
*/
public void testClientOutboundReturnFalse1() 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 + 5, HA_RETURN_FALSE);
try {
// This should throw some client-side exception since
// the handler does not replace the message with a response.
testStub.testInt(42);
fail("did not get exception as expected");
} catch (WebServiceException e) {
System.out.println(e.getMessage());
// make sure the message says what the problem is
// In this case should be, unexpected XML tag. expected: {urn:test:types}TestIntResponse
// but found: {urn:test:types}TestInt
assertTrue(e.getMessage().contains("TestIntResponse"));
}
// check called handlers
// client 5 will not register
int[] called = { 0, 1, 3, 4, 4, 3, 1, 0 };
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));
}
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testClientOutboundReturnFalse2.
/*
* Have one of the client handlers return false and change
* the message contents to look like a reply. Should get 0
* back as result and proper handlers were called and closed.
*/
public void testClientOutboundReturnFalse2() 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_RETURN_FALSE_CHANGE_MESSAGE);
int result = testStub.testInt(0);
assertEquals("did not get expected value back", 0, result);
// check called handlers
// 5 only called once
int[] called = { 0, 1, 3, 4, 5, 4, 3, 1, 0 };
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));
}
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testServerOneWayReturnFalse1.
/*
* Have one of the server handlers return false during a
* one-way request. The handler chain caller should stop
* calling handlers and dispatch the message to the endpoint.
*/
public void testServerOneWayReturnFalse1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalServerHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_RETURN_FALSE);
tracker.clearAll();
testStub.testIntOneWay(0);
// handler 2 will not register
int[] calledNames = { 4 };
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
assertEquals("did not get the right number of called handlers", calledNames.length, calledHandlers.size());
for (int i = 0; i < calledNames.length; i++) {
assertEquals("did not get expected handler name", SERVER_PREFIX + calledNames[i], calledHandlers.get(i));
}
}
Aggregations