Search in sources :

Example 16 with HandlerTracker

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

the class EndToEndTest method testLogicalMessageContextInformation.

/**
 * Testcase for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=457
 *
 * Commenting it out since the fix hasn't gone into 2.1.4
 *
 *    public void testAddMimeHeadersInSOApMessage() throws Exception {
 *        HandlerTracker tracker = HandlerTracker.getClientInstance();
 *        TestService testStub = getTestStub(getService());
 *        tracker.clearAll();
 *        tracker.setHandlerAction(CLIENT_PREFIX + "4",HA_ADD_MIMEHEADER_OUTBOUND);
 *        ReportService reportStub = getReportStub(getService());
 *        reportStub.clearHandlerTracker();
 *        reportStub.setInstruction(SERVER_PREFIX + "4", HA_CHECK_MIMEHEADER_INBOUND);
 *
 *        testStub.testInt(2);
 *    }
 */
/*
     * Check LogicalMessageContext in handlers
     */
public void testLogicalMessageContextInformation() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService testStub = getTestStub(getService());
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + "0", HA_CHECK_LMC);
    tracker.setHandlerAction(CLIENT_PREFIX + "1", HA_CHECK_LMC);
    tracker.setHandlerAction(CLIENT_PREFIX + "3", HA_CHECK_LMC);
    testStub.testInt(4);
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 17 with HandlerTracker

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

the class EndToEndTest method testClientOneWayReturnFalse4.

/*
     * Have one of the client handlers return false during a
     * one-way request. The handler chain caller should stop
     * calling handlers and dispatch the message to the endpoint.
     */
public void testClientOneWayReturnFalse4() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    reportStub.clearHandlerTracker();
    tracker.clearAll();
    for (int i = 0; i < numTotalHandlers; i++) {
        tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    tracker.setHandlerAction(CLIENT_PREFIX + 7, HA_RETURN_FALSE);
    testStub.testIntOneWay(0);
    // handler 7 won't register
    int[] calledNames = { 0, 1, 3, 4, 5 };
    int[] closed = { 7, 5, 4, 3, 1, 0 };
    List<String> calledHandlers = tracker.getCalledHandlers();
    List<String> closedHandlers = tracker.getClosedHandlers();
    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", CLIENT_PREFIX + calledNames[i], calledHandlers.get(i));
    }
    assertEquals("did not get the right number of closed handlers", closed.length, closedHandlers.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not get expected handler name", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
    }
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 18 with HandlerTracker

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

the class EndToEndTest method testResponsePropertyAsync.

/*
     * Sets a property on the (client side) response handler context
     * and verifies that the client sees it in the response context.
     * This test uses an async client
     */
public void testResponsePropertyAsync() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService stub = getTestStub(getService());
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_USER_PROPERTY_INBOUND);
    int x = 1;
    Response<TestIntResponse> response = stub.testIntAsync(x);
    System.out.print("waiting for async response");
    while (!response.isDone()) {
        System.out.print(".");
        Thread.sleep(100);
    }
    System.out.println("");
    int y = response.get().getIntout();
    assertEquals("did not get expected response", x, y);
    Map context = response.getContext();
    assertNotNull("response context in Response<?> object is null", context);
    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(handler.handler_processing.common.HandlerTracker) Map(java.util.Map)

Example 19 with HandlerTracker

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

the class EndToEndTest method testRequestProperty.

/*
     * Sets a property on the request context with a static stub
     * and verifies that the property exists in the handler.
     */
public void testRequestProperty() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService stub = getTestStub(getService());
    ((BindingProvider) stub).getRequestContext().put(USER_CLIENT_PROPERTY_NAME, USER_PROPERTY_CLIENT_SET);
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_CHECK_FOR_USER_PROPERTY_OUTBOUND);
    stub.testInt(1);
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 20 with HandlerTracker

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

the class EndToEndTest method testClientOneWayReturnFalse3.

/*
     * Have one of the client handlers return false during a
     * one-way request. The handler chain caller should stop
     * calling handlers and dispatch the message to the endpoint.
     */
public void testClientOneWayReturnFalse3() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    reportStub.clearHandlerTracker();
    tracker.clearAll();
    for (int i = 0; i < numTotalHandlers; i++) {
        tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    tracker.setHandlerAction(CLIENT_PREFIX + 4, HA_RETURN_FALSE);
    testStub.testIntOneWay(0);
    // handler 4 won't register
    int[] calledNames = { 0, 1, 3 };
    int[] closed = { 4, 3, 1, 0 };
    List<String> calledHandlers = tracker.getCalledHandlers();
    List<String> closedHandlers = tracker.getClosedHandlers();
    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", CLIENT_PREFIX + calledNames[i], calledHandlers.get(i));
    }
    assertEquals("did not get the right number of closed handlers", closed.length, closedHandlers.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not get expected handler name", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
    }
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker)

Aggregations

HandlerTracker (handler.handler_processing.common.HandlerTracker)62 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 (handler.handler_processing.common.TestProtocolException)5 Map (java.util.Map)4 BindingProvider (jakarta.xml.ws.BindingProvider)3 Binding (jakarta.xml.ws.Binding)1 Handler (jakarta.xml.ws.handler.Handler)1 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)1 QName (javax.xml.namespace.QName)1