use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class BindingTest method testBinding1.
/*
* test the binding objects for the right number of handlers
*/
public void testBinding1() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
// get the bindings
Binding testBinding = ((BindingProvider) testStub).getBinding();
Binding reportBinding = ((BindingProvider) reportStub).getBinding();
assertNotNull("Binding object should not be null", testBinding);
assertNotNull("Binding object should not be null", reportBinding);
// check the handlers
List<Handler> testHandlers = testBinding.getHandlerChain();
List<Handler> reportHandlers = reportBinding.getHandlerChain();
assertNotNull("Handler list should not be null", testHandlers);
assertNotNull("Handler list should not be null", reportHandlers);
// check number of handlers
assertEquals("got wrong number of handlers in test binding", SERVICE_HANDLERS + TEST_PORT_HANDLERS + PROTOCOL_HANDLERS, testHandlers.size());
assertEquals("got wrong number of handlers in report binding", SERVICE_HANDLERS + REPORT_PORT_HANDLERS + PROTOCOL_HANDLERS, reportHandlers.size());
// check handler names -- see config file for order
int[] testNames = { 4, 0, 5, 1, 7, 3 };
int[] reportNames = { 4, 0, 2, 6, 7, 3 };
String foundName = null;
for (int i = 0; i < testNames.length; i++) {
foundName = ((HasName) testHandlers.get(i)).getName();
assertEquals("found unexpected handler in chain", CLIENT_PREFIX + testNames[i], foundName);
}
for (int i = 0; i < reportNames.length; i++) {
foundName = ((HasName) reportHandlers.get(i)).getName();
assertEquals("found unexpected handler in chain", CLIENT_PREFIX + reportNames[i], foundName);
}
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testServiceSpecificException1.
/*
* Have the endpoint throw a service specific exception and make
* sure that the client gets it back. Test case for bug 6232002.
*/
public void testServiceSpecificException1() throws Exception {
TestService_Service service = getService();
HandlerTracker tracker = HandlerTracker.getClientInstance();
// get stubs and clear the trackers
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
reportStub.clearHandlerTracker();
tracker.clearAll();
try {
testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
fail("did not receive exception (1)");
} catch (MyFaultException mfe) {
// passed
} catch (Exception e) {
fail("did not receive MyFaultException (1), received " + e);
}
// check closed handlers to be sure
List<String> actualClosed = tracker.getClosedHandlers();
int[] closed = { 7, 5, 4, 3, 1, 0 };
assertEquals("Did not get proper number of closed handlers", closed.length, actualClosed.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], actualClosed.get(i));
}
// remove all client handlers and try again
Binding binding = ((BindingProvider) testStub).getBinding();
binding.setHandlerChain(new ArrayList<Handler>());
tracker.clearAll();
try {
testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
fail("did not receive exception (2)");
} catch (MyFaultException mfe) {
// passed
} catch (Exception e) {
fail("did not receive MyFaultException (2), received " + e);
}
// this just makes sure there really were no handlers
actualClosed = tracker.getClosedHandlers();
assertTrue("should not have been closed handlers", actualClosed.isEmpty());
}
Aggregations