use of fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTester method testClientOutboundRuntimeException1.
/*
* Have one of the client handlers throw a runtime exception
* and check that the proper methods are called. This test
* is on outbound message with 2.0 handler (so handleFault
* should not be called on the handler that throws the
* exception).
*/
public void testClientOutboundRuntimeException1() 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_THROW_RUNTIME_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive any 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
// one direction only
int[] called = { 0, 1, 3, 4, 5 };
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 -- none in jaxws 2.0
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("destroyed handler list should be empty", destroyedHandlers.isEmpty());
}
use of fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTester method testClientInboundProtocolException2.
/*
* Have one of the client handlers throw a proper exception
* and check that the proper methods are called. This test
* is on inbound message. Testing with logical handler.
*
* Is this a valid test case?
*/
public void testClientInboundProtocolException2() throws Exception {
int badHandler = 1;
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_PROTOCOL_EXCEPTION_INBOUND);
try {
testStub.testInt(42);
fail("should have received a web service exception");
} catch (ProtocolException e) {
assertTrue("ProtocolException message not as expected, but got:" + e.getMessage(), e.getMessage().contains(CLIENT_PREFIX + badHandler));
}
// check called handlers
int[] called = { 0, 1, 3, 4, 5, 7, 7, 5, 4, 3, 1 };
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 fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTester method testClientInboundRuntimeException2.
/*
* 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 logical handler.
*/
public void testClientInboundRuntimeException2() throws Exception {
int badHandler = 3;
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, 4, 3 };
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 fromwsdl.handler.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester method testClientOneWayReturnFalse2.
/*
* 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 testClientOneWayReturnFalse2() 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 + 3, HA_RETURN_FALSE);
testStub.testIntOneWay(0);
// handler 3 won't register
int[] calledNames = { 0, 1 };
int[] closed = { 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 testServerOutboundReturnFalse2.
/*
* Have one of the server handlers return false and check
* that the proper handlers were called.
*/
public void testServerOutboundReturnFalse2() 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_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 };
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));
}
}
Aggregations