use of jakarta.xml.ws.handler.PortInfo 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.PortInfo 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.PortInfo 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.PortInfo 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.PortInfo 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 {
HelloService service = createService();
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
return new ArrayList<Handler>();
}
});
HelloPortType stub = createStub(service);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
System.out.println("sent: " + x + ", expect " + (x + diff) + " back. received: " + y);
assertTrue(y == x + diff);
// now add client handler
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
List<Handler> handlers = new ArrayList<Handler>();
handlers.add(new TestHandler());
return handlers;
}
});
stub = createStub(service);
// test again
diff = 4;
y = stub.hello(x);
System.out.println("sent: " + x + ", expect " + (x + diff) + " back. received: " + y);
assertTrue(y == x + diff);
}
Aggregations