Search in sources :

Example 6 with HandlerTracker

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

the class EndToEndErrorTest method testServerMustUnderstand1.

/*
     * Test to make sure mustUnderstand headers that are not understood
     * cause a fault.
     */
public void testServerMustUnderstand1() 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);
    }
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_BAD_MU_HEADER_OUTBOUND);
    // should get fault
    try {
        int result = testStub.testInt(5);
        fail("did not receive remote exception");
    } catch (WebServiceException e) {
    // ok
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 7 with HandlerTracker

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

the class EndToEndErrorTest method testServerOutboundProtocolException1.

/*
     * Have one of the server handlers throw a simple protocol
     * exception and check that the proper methods are called.
     */
public void testServerOutboundProtocolException1() 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_PROTOCOL_EXCEPTION_OUTBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    try {
        testStub.testInt(3);
        fail("did not receive exception");
    } catch (ProtocolException e) {
    // ok
    }
    // check result
    String[] called = { "4", "2", "1", "0", "0", "1", "2" };
    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));
    }
    // too many closes to check them all
    // should be no destroyed handlers
    List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
    assertTrue("Should be no destroyed handlers", destroyedHandlers.isEmpty());
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 8 with HandlerTracker

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

the class EndToEndErrorTest method testClientMustUnderstand1.

/*
     * Test to make sure mustUnderstand headers that are not understood
     * cause a fault. This test uses the "next" role.
     */
public void testClientMustUnderstand1() 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();
    reportStub.setInstruction(SERVER_PREFIX + 4, HA_ADD_BAD_MU_HEADER_OUTBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    // should get fault
    try {
        int result = testStub.testInt(5);
        fail("did not receive soap exception");
    } catch (WebServiceException e) {
    // ok
    }
    // check called and closed handlers
    List<String> closedHandlers = tracker.getClosedHandlers();
    // check client handlers
    int[] closed = { 7, 5, 4, 3, 1, 0 };
    assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 9 with HandlerTracker

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

the class EndToEndErrorTest method testClientOutboundRuntimeException2.

/*
     * Have one of the client handlers throw a runtime exception
     * and check that the proper methods are called. This test
     * is on outbound message with 2.0 handler (so handleFault
     * should not be called on the handler that throws the
     * exception). Testing with logical handler.
     */
public void testClientOutboundRuntimeException2() 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 + 1, HA_THROW_RUNTIME_EXCEPTION_OUTBOUND);
    try {
        testStub.testInt(42);
        fail("test did not throw any exception");
    } catch (WebServiceException e) {
        Throwable cause = e.getCause();
        assertNotNull("cause of exception is null", cause);
        assertTrue("cause should be runtime exception, instead is " + cause.getClass().toString(), cause instanceof RuntimeException);
    }
    // check result
    // one direction only
    int[] called = { 0, 1 };
    int[] closed = { 1, 0 };
    List<String> calledHandlers = tracker.getCalledHandlers();
    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", CLIENT_PREFIX + called[i], calledHandlers.get(i));
    }
    List<String> closedHandlers = tracker.getClosedHandlers();
    assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
    }
    // check destroyed handlers -- none in jaxws 2.0
    List<String> destroyedHandlers = tracker.getDestroyedHandlers();
    assertTrue("destroyed handler list should be empty", destroyedHandlers.isEmpty());
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) HandlerTracker(handler.handler_processing.common.HandlerTracker)

Example 10 with HandlerTracker

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

the class EndToEndErrorTest method testServerInboundProtocolException1.

/*
     * Have one of the server handlers throw a simple protocol
     * exception and check that the proper methods are called.
     *
     * This test checks the fault code as well -- related to
     * bug 6350633.
     */
public void testServerInboundProtocolException1() throws Exception {
    // the expected fault code local part
    String server = "Server";
    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_PROTOCOL_EXCEPTION_INBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    try {
        testStub.testInt(3);
        fail("did not receive exception");
    } catch (SOAPFaultException e) {
        SOAPFault fault = e.getFault();
        String faultCode = fault.getFaultCode();
        assertTrue("fault code should end with \"" + server + "\": " + faultCode, faultCode.endsWith(server));
    }
    // 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));
    }
    // too many closes to check them all
    // should be no destroyed handlers
    List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
    assertEquals("Should be 0 destroyed handlers", 0, destroyedHandlers.size());
}
Also used : HandlerTracker(handler.handler_processing.common.HandlerTracker) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SOAPFault(jakarta.xml.soap.SOAPFault)

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