use of fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester method testClientOneWayReturnFalse3.
/*
* 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.
*/
public void testClientOneWayReturnFalse3() 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 + 4, HA_RETURN_FALSE);
testStub.testIntOneWay(0);
// handler 4 won't register
int[] calledNames = { 0, 1, 3 };
int[] closed = { 4, 3, 1, 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
List<String> closedHandlers = tracker.getClosedHandlers();
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", CLIENT_PREFIX + calledNames[i], calledHandlers.get(i));
}
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));
}
}
use of fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester method testAllRoles.
/*
* Test the allRoles boolean argument of getHeaders()
* method in SOAPMessageContext.
*/
public void testAllRoles() 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();
reportStub.setInstruction(SERVER_PREFIX + 4, HA_ADD_HEADER_OUTBOUND_CLIENT_ROLE1);
// so we clear out the client handlers afterwards
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + 7, HA_CHECK_SMC_ALL_ROLES);
// first check with the client1 role
int result = testStub.testInt(5);
// now check without the known role (should get no headers in handler)
SOAPBinding sBinding = (SOAPBinding) ((BindingProvider) testStub).getBinding();
sBinding.setRoles(new HashSet<String>());
result = testStub.testInt(5);
}
use of fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester method testClientHandlers1.
/*
* Make sure the right number of client side handlers are in place
*/
public void testClientHandlers1() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
TestService_Service service = getService();
TestService stub = getTestStub(service);
// check for the correct number
int x = 0;
for (int i = 0; i < numTotalHandlers; i++) {
// just set them all
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_ADD_ONE);
}
int y = stub.testInt(x);
// handlers times 2 messages (in/out)
int diff = 2 * numTestHandlers;
assertEquals("error in number of handlers working", x + diff, y);
// check for the correct order
tracker.clearCalledHandlers();
for (int i = 0; i < numTotalHandlers; i++) {
// just set them all
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
stub.testInt(-1);
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("did not get the right number of called handlers", 2 * numTestHandlers, calledHandlers.size());
int[] calledNames = { 0, 1, 3, 4, 5, 7, 7, 5, 4, 3, 1, 0 };
for (int i = 0; i < calledNames.length; i++) {
assertEquals("did not get expected handler name", CLIENT_PREFIX + calledNames[i], calledHandlers.get(i));
}
// check destroyed handlers (not really needed in jaxws 2.0)
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("should be 0 handlers destroyed", destroyedHandlers.isEmpty());
}
use of fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester 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 fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester 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));
}
}
Aggregations