use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testDynamic1.
/*
* Test tries to add a handler programmatically after clearing
* handlers out of the service. Adds handler to binding. Uses
* an empty handler resolver for clearing the service.
*/
public void testDynamic1() throws Exception {
Hello_Service service = createService();
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
return new ArrayList<Handler>();
}
});
Hello stub = createStub(service);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertTrue(y == x + diff);
// now add client handler
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new SOAPTestHandler());
Binding binding = ((BindingProvider) stub).getBinding();
binding.setHandlerChain(handlerList);
// test again
diff = 4;
y = stub.hello(x);
assertTrue(y == x + diff);
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testSOAP12Binding1.
/*
* The normal tests in this file are for soap 1.1. This is a soap 1.2
* test to make sure that the port is created with the proper binding
* so that the proper handlers are called. See bug 6353179.
*
* Not working right now -- can't get endpoint to work.
*/
public void testSOAP12Binding1() throws Exception {
Hello_Service service = createService();
Hello12 stub = create12Stub(service);
// make sure port is working
int x = 1;
// server handler only
int diff = 2;
int y = stub.hello12(x);
assertEquals(x + diff, y);
Binding binding = ((BindingProvider) stub).getBinding();
List<Handler> handlers = binding.getHandlerChain();
assertEquals("should be 1 handler in chain", 1, handlers.size());
Handler handler = handlers.get(0);
assertTrue("handler should be type Port12Handler, not " + handler.getClass().toString(), handler instanceof Port12Handler);
Port12Handler p12h = (Port12Handler) handler;
p12h.resetCalled();
stub.hello12(2);
assertEquals("handler should have been called two times", 2, p12h.getCalled());
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class ClientServerTestUtil method clearHandlers.
/**
* Method used to clear any handlers from a stub or dispatch object.
*/
public static void clearHandlers(BindingProvider provider) {
Binding binding = provider.getBinding();
binding.setHandlerChain(new ArrayList<Handler>());
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class ClientServerTestUtil method addHandlerToBinding.
/**
* Method used to add a Handler to a stub or dispatch object.
*/
public static void addHandlerToBinding(Handler handler, BindingProvider bindingProvider) {
Binding binding = bindingProvider.getBinding();
List<Handler> handlers = binding.getHandlerChain();
handlers.add(handler);
binding.setHandlerChain(handlers);
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class Util method addHandler.
// utility methods to be made available to the test clients
/**
* Method used to add a Handler to a stub or dispatch object.
*/
public static void addHandler(Handler handler, Object provider) {
BindingProvider bindingProvider = (BindingProvider) provider;
Binding binding = bindingProvider.getBinding();
List<Handler> handlers = binding.getHandlerChain();
handlers.add(handler);
binding.setHandlerChain(handlers);
}
Aggregations