Search in sources :

Example 1 with BaseSOAPHandler

use of fromwsdl.handler.common.BaseSOAPHandler in project metro-jax-ws by eclipse-ee4j.

the class BindingTester method testBindingInstances.

/*
     * get the binding object on dispatch object
     */
// public void testDispatch1() throws Exception {
// Dispatch dispatch = createDispatchForSource(
// new QName("urn:test", "TestServicePort"));
// assertNotNull("dispatch object is null", dispatch);
// Binding binding = dispatch.getBinding();
// assertNotNull("binding object should not be null", binding);
// List handlers = binding.getHandlerChain();
// assertNotNull("handler list should not be null", handlers);
// assertTrue("There should be no handlers in list", handlers.size() == 0);
// }
/*
     * 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());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 2 with BaseSOAPHandler

use of fromwsdl.handler.common.BaseSOAPHandler in project metro-jax-ws by eclipse-ee4j.

the class EndToEndTester method testResponsePropertyDispatch.

/*
     * Sets a property on the (client side) response handler context
     * and verifies that the client sees it in the response context.
     * This version uses a dispatch client rather than proxy.
     */
public void testResponsePropertyDispatch() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    Dispatch<Object> dispatch = getDispatchJAXB(testPortQName);
    // tell the server handlers not to do anything
    ReportService reportStub = getReportStub(getService());
    reportStub.clearHandlerTracker();
    // add handler
    String myHandlerName = "MyDispatchHandler";
    BaseSOAPHandler propAddingHandler = new BaseSOAPHandler();
    propAddingHandler.setName(CLIENT_PREFIX + myHandlerName);
    propAddingHandler.initTheHandler();
    List<Handler> newHandlers = new ArrayList<Handler>();
    newHandlers.add(propAddingHandler);
    dispatch.getBinding().setHandlerChain(newHandlers);
    // tell the client handlers what to do
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + myHandlerName, HA_ADD_USER_PROPERTY_INBOUND);
    int x = 1;
    TestInt request = new TestInt();
    request.setIntin(x);
    TestIntResponse response = (TestIntResponse) dispatch.invoke(request);
    assertEquals("did not get proper response", x, response.getIntout());
    Map context = dispatch.getResponseContext();
    Object testValue = context.get(USER_HANDLER_PROPERTY_NAME);
    assertNotNull("did not receive property in response context", testValue);
    String testValueString = (String) testValue;
    assertTrue("property value incorrect. expected ", testValueString.equals(USER_PROPERTY_HANDLER_SET));
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker) ArrayList(java.util.ArrayList) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) AsyncHandler(jakarta.xml.ws.AsyncHandler) Handler(jakarta.xml.ws.handler.Handler) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with BaseSOAPHandler

use of fromwsdl.handler.common.BaseSOAPHandler in project metro-jax-ws by eclipse-ee4j.

the class EndToEndTester method testRequestPropertyDispatch.

/*
     * Sets a property on the request context with dispatch
     * and verifies that the property exists in the handler.
     * Also adds a handler to add 1 to the messages just to
     * make sure handlers are being invoked.
     */
public void testRequestPropertyDispatch() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    Dispatch<Object> dispatch = getDispatchJAXB(testPortQName);
    // tell the server handlers not to do anything
    ReportService reportStub = getReportStub(getService());
    reportStub.clearHandlerTracker();
    // add handlers
    String myHandlerName = "MyDispatchHandler";
    BaseSOAPHandler propCheckingHandler = new BaseSOAPHandler();
    propCheckingHandler.setName(CLIENT_PREFIX + myHandlerName);
    propCheckingHandler.initTheHandler();
    String otherHandlerName = "MyOtherHandler";
    BaseSOAPHandler numberAddingHandler = new BaseSOAPHandler();
    numberAddingHandler.setName(CLIENT_PREFIX + otherHandlerName);
    numberAddingHandler.initTheHandler();
    List<Handler> newHandlers = new ArrayList<Handler>();
    newHandlers.add(propCheckingHandler);
    newHandlers.add(numberAddingHandler);
    dispatch.getBinding().setHandlerChain(newHandlers);
    // add the property
    dispatch.getRequestContext().put(USER_CLIENT_PROPERTY_NAME, USER_PROPERTY_CLIENT_SET);
    // tell the client handlers what to do
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + myHandlerName, HA_CHECK_FOR_USER_PROPERTY_OUTBOUND);
    tracker.setHandlerAction(CLIENT_PREFIX + otherHandlerName, HA_ADD_ONE);
    // make the call (will get exception if handler doesn't see property)
    int x = 1;
    // for the number adding handler
    int diff = 2;
    TestInt request = new TestInt();
    request.setIntin(x);
    TestIntResponse response = (TestIntResponse) dispatch.invoke(request);
    assertEquals("did not get proper response", x + diff, response.getIntout());
}
Also used : BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) HandlerTracker(fromwsdl.handler.common.HandlerTracker) ArrayList(java.util.ArrayList) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) AsyncHandler(jakarta.xml.ws.AsyncHandler) Handler(jakarta.xml.ws.handler.Handler)

Aggregations

BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)3 Handler (jakarta.xml.ws.handler.Handler)3 HandlerTracker (fromwsdl.handler.common.HandlerTracker)2 AsyncHandler (jakarta.xml.ws.AsyncHandler)2 ArrayList (java.util.ArrayList)2 Binding (jakarta.xml.ws.Binding)1 BindingProvider (jakarta.xml.ws.BindingProvider)1 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1