use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest 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 handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientOutboundProtocolException2.
/*
* Same as testClientOutboundProtocolException1 except that
* it uses the first soap handler in the chain to make sure
* it skips to the logical handlers without an array index error.
*/
public void testClientOutboundProtocolException2() 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_THROW_PROTOCOL_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive an exception");
} catch (SOAPFaultException e) {
assertTrue(true);
}
// check result
String[] called = { "0", "1", "3", "4", "3_FAULT", "1_FAULT", "0_FAULT" };
int[] closed = { 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));
}
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));
}
// should be no destroyed handlers
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("Should be 0 destroyed handlers", destroyedHandlers.isEmpty());
}
use of handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientMustUnderstand2.
/*
* Test to make sure mustUnderstand headers that are not understood
* cause a fault. This test uses the "client2" role.
*/
public void testClientMustUnderstand2() 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_BAD_MU_HEADER_CLIENT2_OUTBOUND);
// so we clear out the client handlers afterwards
tracker.clearAll();
// should get fault
try {
int result = testStub.testInt(5);
fail("did not receive soap exception");
} catch (WebServiceException e) {
// ok
}
// check called and closed handlers
List<String> closedHandlers = tracker.getClosedHandlers();
// check client handlers
int[] closed = { 7, 5, 4, 3, 1, 0 };
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 EndToEndErrorTest 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 handler.handler_processing.common.HandlerTracker in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testValidMustUnderstand.
/*
* Test to make sure mustUnderstand headers of the right type get
* through with no fault.
*/
public void testValidMustUnderstand() 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();
for (int i = 0; i < numTotalHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_ADD_GOOD_MU_HEADER_OUTBOUND);
// so we clear out the client handlers afterwards
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_GOOD_MU_HEADER_OUTBOUND);
// should get no fault
int result = testStub.testInt(5);
assertEquals("did not get int echoed back from server", 5, result);
}
Aggregations