use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class HandlerChainTester method testHandlersOnReportPort.
public void testHandlersOnReportPort() {
TestService_Service service = getService();
ReportService testStub = service.getReportServicePort();
Binding testBinding = ((BindingProvider) testStub).getBinding();
List<Handler> chain = testBinding.getHandlerChain();
// System.out.println(chain.size());
assertEquals(2, chain.size());
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class BindingTester method testSoapBinding1.
/*
* tests for SOAPBinding.
*
*/
public void testSoapBinding1() throws Exception {
TestService_Service service = getService();
TestService stub = getTestStub(service);
Binding binding = ((BindingProvider) stub).getBinding();
if (binding instanceof SOAPBinding) {
SOAPBinding sb = (SOAPBinding) binding;
assertNotNull("did not get SOAPBinding", sb);
Set<String> roles = sb.getRoles();
assertNotNull("roles cannot be null", roles);
assertFalse("found zero roles in SOAPBinding", roles.isEmpty());
assertTrue("soap 1.1 \"next\" role is not included in roles", roles.contains(NEXT_1_1));
assertFalse("soap 1.2 \"none\" role cannot be included in roles", roles.contains(NONE));
// try setting new roles
Set<String> newSet = new HashSet<String>();
String testURI = "http://java.sun.com/justanexample";
newSet.add(testURI);
sb.setRoles(newSet);
try {
newSet.add(NONE);
sb.setRoles(newSet);
throw new RuntimeException("did not get jaxrpc exception for setting \"none\" role");
} catch (WebServiceException e) {
// pass
}
newSet.addAll(roles);
newSet.remove(NONE);
sb.setRoles(newSet);
// add empty set and check for next/ultimate
newSet = new HashSet<String>();
sb.setRoles(newSet);
Set<String> newSet2 = sb.getRoles();
assertTrue("soap 1.1 \"next\" role is not included in roles", newSet2.contains(NEXT_1_1));
assertFalse("soap 1.2 \"none\" role cannot be included in roles", newSet2.contains(NONE));
} else {
throw new Exception("binding is not a SOAPBinding");
}
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class BindingTester 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 EndToEndErrorTester 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());
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class ClientFeatureTest method validateFeatureList.
private void validateFeatureList(Object bindingProvider, String expectedEncoding) throws Exception {
Binding binding = ((BindingProvider) bindingProvider).getBinding();
WSFeatureList list = (((WSBinding) binding).getFeatures());
// System.out.println(list);
SerializationFeature encoding = list.get(SerializationFeature.class);
if (expectedEncoding == null) {
assertNull("There should not be a SerializationFeature", encoding);
} else {
assertEquals("Mismatched encoding in SerializationFeature", expectedEncoding, encoding.getEncoding());
}
}
Aggregations