Search in sources :

Example 1 with HandlerResolver

use of jakarta.xml.ws.handler.HandlerResolver 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);
}
Also used : Binding(jakarta.xml.ws.Binding) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) ArrayList(java.util.ArrayList) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider) PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with HandlerResolver

use of jakarta.xml.ws.handler.HandlerResolver 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);
}
Also used : PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) TestHandler(fromwsdl.handler_dd.common.TestHandler) Handler(jakarta.xml.ws.handler.Handler) TestHandler(fromwsdl.handler_dd.common.TestHandler) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with HandlerResolver

use of jakarta.xml.ws.handler.HandlerResolver 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);
}
Also used : PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with HandlerResolver

use of jakarta.xml.ws.handler.HandlerResolver 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);
}
Also used : Binding(jakarta.xml.ws.Binding) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) ArrayList(java.util.ArrayList) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider) PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with HandlerResolver

use of jakarta.xml.ws.handler.HandlerResolver 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);
}
Also used : PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) TestHandler(fromjava.handler_simple.common.TestHandler) Handler(jakarta.xml.ws.handler.Handler) TestHandler(fromjava.handler_simple.common.TestHandler) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Handler (jakarta.xml.ws.handler.Handler)6 HandlerResolver (jakarta.xml.ws.handler.HandlerResolver)6 PortInfo (jakarta.xml.ws.handler.PortInfo)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)2 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)2 Binding (jakarta.xml.ws.Binding)2 BindingProvider (jakarta.xml.ws.BindingProvider)2 TestHandler (fromjava.handler_simple.common.TestHandler)1 TestHandler (fromwsdl.handler_dd.common.TestHandler)1