Search in sources :

Example 11 with HandlerTracker

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

the class EndToEndTester method testServerOneWayReturnFalse2.

/*
     *
     * Have one of the server handlers return false during a
     * one-way request. The handler chain caller should stop
     * calling handlers and dispatch the message to the endpoint.
     *
     * Same as testServerInboundReturnFalse2 but with a different
     * handler returning false.
     */
public void testServerOneWayReturnFalse2() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    reportStub.clearHandlerTracker();
    for (int i = 0; i < numTotalServerHandlers; i++) {
        reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    reportStub.setInstruction(SERVER_PREFIX + 1, HA_RETURN_FALSE);
    tracker.clearAll();
    testStub.testIntOneWay(0);
    // handler 1 will not register
    int[] calledNames = { 4, 2 };
    List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
    assertEquals("did not get the right number of called handlers", calledNames.length, calledHandlers.size());
    for (int i = 0; i < calledNames.length; i++) {
        assertEquals("did not get expected handler name", SERVER_PREFIX + calledNames[i], calledHandlers.get(i));
    }
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker)

Example 12 with HandlerTracker

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

the class EndToEndTester method testClientHandlers2.

/*
     * Make sure the right number of client side handlers are
     * in place for a one-way call.
     */
public void testClientHandlers2() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService_Service service = getService();
    TestService stub = getTestStub(service);
    tracker.clearAll();
    for (int i = 0; i < numTotalHandlers; i++) {
        // just set them all
        tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    stub.testIntOneWay(0);
    List<String> calledHandlers = tracker.getCalledHandlers();
    assertEquals("did not get the right number of called handlers", numTestHandlers, calledHandlers.size());
    int[] calledNames = { 0, 1, 3, 4, 5, 7 };
    for (int i = 0; i < calledNames.length; i++) {
        assertEquals("did not get expected handler name", CLIENT_PREFIX + calledNames[i], calledHandlers.get(i));
    }
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker)

Example 13 with HandlerTracker

use of fromwsdl.handler.common.HandlerTracker 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 14 with HandlerTracker

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

the class EndToEndTester method testServerInboundReturnFalse1.

/*
     * Have one of the server handlers return false and change
     * the message contents to look like a reply.
     *
     * This is really a test of the handler util
     * changeRequestToResponse() method used in client side tests.
     */
public void testServerInboundReturnFalse1() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    reportStub.clearHandlerTracker();
    reportStub.setInstruction(SERVER_PREFIX + 2, HA_RETURN_FALSE_CHANGE_MESSAGE);
    tracker.clearAll();
    for (int i = 0; i < numTotalHandlers; i++) {
        tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    int result = testStub.testInt(0);
    assertEquals("did not get expected value back", 0, result);
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker)

Example 15 with HandlerTracker

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

the class EndToEndTester method testResponseProperty.

/*
     * Sets a property on the (client side) response handler context
     * and verifies that the client sees it in the response context.
     */
public void testResponseProperty() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService stub = getTestStub(getService());
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_USER_PROPERTY_INBOUND);
    stub.testInt(1);
    Map context = ((BindingProvider) stub).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) BindingProvider(jakarta.xml.ws.BindingProvider) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HandlerTracker (fromwsdl.handler.common.HandlerTracker)64 WebServiceException (jakarta.xml.ws.WebServiceException)16 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)16 ProtocolException (jakarta.xml.ws.ProtocolException)13 SOAPFault (jakarta.xml.soap.SOAPFault)8 TestProtocolException (fromwsdl.handler.common.TestProtocolException)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 BindingProvider (jakarta.xml.ws.BindingProvider)3 Handler (jakarta.xml.ws.handler.Handler)3 BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)2 AsyncHandler (jakarta.xml.ws.AsyncHandler)2 ArrayList (java.util.ArrayList)2 Binding (jakarta.xml.ws.Binding)1 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)1 QName (javax.xml.namespace.QName)1