Search in sources :

Example 11 with HandlerTracker

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

the class EndToEndErrorTest method testServerInboundSoapFaultException1.

/*
     * Have one of the server handlers throw a soap fault
     * exception and check that the proper methods are called.
     */
public void testServerInboundSoapFaultException1() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    // these lines make calls to the server
    reportStub.clearHandlerTracker();
    for (int i = 0; i < numTotalHandlers; i++) {
        reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
    }
    reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_SOAP_FAULT_EXCEPTION_INBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    try {
        testStub.testInt(3);
        fail("did not receive any exception");
    } catch (SOAPFaultException e) {
        // check some details
        SOAPFault fault = e.getFault();
        assertEquals("did not get proper fault actor", "faultActor", fault.getFaultActor());
        assertEquals("did not get proper fault string", "fault", fault.getFaultString());
        assertEquals("did not get proper fault code", new QName("uri", "local", "prefix"), fault.getFaultCodeAsQName());
    }
    // check result
    String[] called = { "4", "2", "4_FAULT" };
    List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
    assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
    for (int i = 0; i < called.length; i++) {
        assertEquals("did not find expected handler", SERVER_PREFIX + called[i], calledHandlers.get(i));
    }
    // should be no destroyed handlers
    List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
    assertTrue("Should be 0 destroyed handlers", destroyedHandlers.isEmpty());
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker) QName(javax.xml.namespace.QName) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SOAPFault(jakarta.xml.soap.SOAPFault)

Example 12 with HandlerTracker

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

the class EndToEndTest method testServerOutboundReturnFalse1.

/*
     * Have one of the server handlers return false and check
     * that the proper handlers were called.
     */
public void testServerOutboundReturnFalse1() 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 + "0", HA_RETURN_FALSE_OUTBOUND);
    tracker.clearAll();
    int result = testStub.testInt(0);
    assertEquals("did not get expected value back", 0, result);
    // check called handlers on server side
    List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
    // server0 called twice, the rest are skipped
    int[] called = { 4, 2, 1, 0, 0 };
    assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
    for (int i = 0; i < called.length; i++) {
        assertEquals("did not find expected handler", SERVER_PREFIX + called[i], calledHandlers.get(i));
    }
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 13 with HandlerTracker

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

the class EndToEndTest method testSOAPMessageContextInformationServer.

/*
     * Check SOAPMessageContext in handlers on server side.
     */
public void testSOAPMessageContextInformationServer() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService testStub = getTestStub(getService());
    ReportService reportStub = getReportStub(getService());
    reportStub.clearHandlerTracker();
    reportStub.setInstruction(SERVER_PREFIX + "2", HA_CHECK_SMC);
    reportStub.setInstruction(SERVER_PREFIX + "4", HA_CHECK_SMC);
    tracker.clearAll();
    testStub.testInt(4);
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 14 with HandlerTracker

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

the class EndToEndTest 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(handler.handler_processing.common.HandlerTracker) BindingProvider(jakarta.xml.ws.BindingProvider) Map(java.util.Map)

Example 15 with HandlerTracker

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

the class EndToEndTest 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(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