use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testResponsePropertyAsyncHandler.
/*
* Sets a property on the (client side) response handler context
* and verifies that the client sees it in the response context.
* This test uses an async client with an async handler.
*/
public void testResponsePropertyAsyncHandler() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
TestService stub = getTestStub(getService());
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_USER_PROPERTY_INBOUND);
int x = 1;
final IntHolder intHolder = new IntHolder();
intHolder.setValue(x);
Future<?> response = stub.testIntAsync(x, new AsyncHandler<TestIntResponse>() {
public void handleResponse(Response<TestIntResponse> resp) {
try {
Map context = resp.getContext();
if (context == null) {
intHolder.setValue(-10);
return;
}
Object testValue = context.get(USER_HANDLER_PROPERTY_NAME);
if (testValue == null) {
intHolder.setValue(-20);
return;
}
String testValueString = (String) testValue;
if (!testValueString.equals(USER_PROPERTY_HANDLER_SET)) {
intHolder.setValue(-30);
return;
}
// add 10 to make sure this was called
intHolder.setValue(resp.get().getIntout() + 10);
} catch (Exception e) {
e.printStackTrace();
// will cause failure
intHolder.setValue(-40);
}
}
});
while (!response.isDone()) {
/* wait */
}
int y = intHolder.getValue();
assertFalse("response context in Response<?> object is null", y == -10);
assertFalse("did not receive property in response context", y == -20);
assertFalse("property value incorrect. expected", y == -30);
assertFalse("some error occurred in AsyncHandler. see output", y == -40);
assertEquals("did not get expected value back in response", x + 10, y);
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest 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 handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testServerOutboundReturnFalse3.
/*
* Have one of the server handlers return false and check
* that the proper handlers were called.
*/
public void testServerOutboundReturnFalse3() 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 + "4", HA_RETURN_FALSE_OUTBOUND);
tracker.clearAll();
int result = testStub.testInt(0);
assertEquals("did not get expected value back", 0, result);
// check called handlers on server side
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
// server0 called twice, the rest are skipped
int[] called = { 4, 2, 1, 0, 0, 1, 2, 4 };
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 EndToEndTest method testSOAPHeader2.
/*
* Test soap header. This test has a handler add header elements
* and another handler check for them. Test2 starts on the server
* side.
*/
public void testSOAPHeader2() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
// these lines make calls to the server
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalServerHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_ADD_HEADER_OUTBOUND);
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + 7, HA_CHECK_FOR_ADDED_HEADER_INBOUND);
testStub.testInt(123);
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testClientOutInReturnFalse1.
/*
* Have one of the client handlers return false and change
* the message contents to look like a reply. Then have
* another handler return false during the now incoming
* message. Further handler processing should stop.
*
* First handler 5 returns false. Message should then be
* inbound. Handler 3 should see that the message is
* inbound and will return false. Then handlers 1 and 0
* should be skipped.
*
* Test for bug 6381858.
*/
public void testClientOutInReturnFalse1() 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);
tracker.setHandlerAction(CLIENT_PREFIX + 3, HA_RETURN_FALSE_INBOUND);
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 };
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));
}
}
Aggregations