use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class BindingTest method testBindingInstances.
/*
* Used for testing of handlers shared between bindings.
*/
public void testBindingInstances() throws Exception {
TestService_Service service = getService();
TestService stub1 = getTestStub(service);
TestService stub2 = getTestStub(service);
// make some calls
stub1.testInt(0);
stub2.testInt(0);
Binding b1 = ((BindingProvider) stub1).getBinding();
Binding b2 = ((BindingProvider) stub2).getBinding();
List<Handler> chain = b1.getHandlerChain();
// get a soap handler from the chain. doesn't matter which one
BaseSOAPHandler handler = null;
for (Handler h : chain) {
if (h instanceof BaseSOAPHandler) {
handler = (BaseSOAPHandler) h;
break;
}
}
assertTrue("handler should be in 'ready' state", handler.isAvailable());
b2.setHandlerChain(new ArrayList<Handler>());
assertTrue("handler should be in 'ready' state", handler.isAvailable());
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method test2.
// public void testDispatch1() throws Exception {
// int x = 1; // what we send
// int diff = 2; // 4 handler invocations
//
// JAXBContext jxbContext = JAXBContext.newInstance(ObjectFactory.class);
// Dispatch dispatch = createDispatchForJAXB(
// new QName("urn:test", "HelloPort"), jxbContext);
//
// Hello_Type request = objectFactory.createHello_Type();
// request.setValue(1);
//
// // make first call with no client side handlers
// HelloResponse response = (HelloResponse) dispatch.invoke(request);
// assertNotNull("response cannot be null", response);
//
// int y = response.getValue();
// System.out.println("sent: " + x + ", expect " + (x+diff) +
// " back. received: " + y);
// assertTrue(y == x+diff);
//
// System.out.println("now adding handler to dispatch");
// Binding binding = dispatch.getBinding();
// assertNotNull("binding cannot be null", binding);
// int handlerChainLength = binding.getHandlerChain().size();
// assertEquals("the handler list is not empty", 0, handlerChainLength);
//
// // add handler
// HandlerInfo hInfo = new HandlerInfo(
// handler_tests.simple_handler_test.client.handlers.ClientHandler.class,
// null, null);
// List<HandlerInfo> newHandlers = new ArrayList<HandlerInfo>();
// newHandlers.add(hInfo);
// binding.setHandlerChain(newHandlers);
//
// // now try again
// diff = 4;
// response = (HelloResponse) dispatch.invoke(request);
// assertNotNull("response cannot be null", response);
//
// y = response.getValue();
// System.out.println("sent: " + x + ", expect " + (x+diff) +
// " back. received: " + y);
// assertTrue(y == x+diff);
// }
/*
* Test tries to add a handler programmatically after clearing
* handlers out of registry in the service.
*/
public void test2() 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 = 6;
int y = stub.hello(x);
System.out.println("sent: " + x + ", expect " + (x + diff) + " back. received: " + y);
assertEquals("handlers not invoked correctly", x + diff, y);
// now add client handler
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
List handlers = new ArrayList<Handler>();
handlers.add(new TestHandler());
return handlers;
}
});
stub = createStub(service);
// test again
diff = 8;
y = stub.hello(x);
System.out.println("sent: " + x + ", expect " + (x + diff) + " back. received: " + y);
assertEquals("handlers not invoked correctly", x + diff, y);
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testLogicalJAXB.
/*
* Test removes the static handler and adds a logical
* handler that uses JAXB to change the message.
*/
public void testLogicalJAXB() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.JAXB);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 4;
int y = stub.hello(x);
// x+4 with all handlers
assertEquals(x + diff, y);
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testDynamic2.
/*
* Test tries to add a handler programmatically after clearing
* handlers out of the service. Adds handler using HandlerResolver.
* Uses a null HandlerResolver to clear the service.
*/
public void testDynamic2() throws Exception {
Hello_Service service = createService();
service.setHandlerResolver(null);
Hello stub = createStub(service);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertEquals(x + diff, y);
// now add client handler
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
List list = new ArrayList<Handler>();
list.add(new SOAPTestHandler());
return list;
}
});
stub = createStub(service);
// 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 testLogicalGetSourceOnly.
/*
* Test removes the static handler and adds a logical
* handler that gets the source but does not change it.
*/
public void testLogicalGetSourceOnly() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE_NO_CHANGE);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertEquals(x + diff, y);
}
Aggregations