Search in sources :

Example 1 with HandlerTracker

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

the class EndToEndErrorTester 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(fromwsdl.handler.common.HandlerTracker)

Example 2 with HandlerTracker

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

the class EndToEndErrorTester method testServerInboundRuntimeException2.

/*
     * Have one of the server handlers throw a runtime
     * exception and check that the proper methods are called.
     * This test uses a protocol handler.
     */
public void testServerInboundRuntimeException2() 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_RUNTIME_EXCEPTION_INBOUND);
    // 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" };
    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 no destroyed handlers", destroyedHandlers.isEmpty());
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) HandlerTracker(fromwsdl.handler.common.HandlerTracker)

Example 3 with HandlerTracker

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

the class EndToEndErrorTester method testServerInboundRuntimeException1.

/*
     * Have one of the server handlers throw a runtime
     * exception and check that the proper methods are called.
     * This test uses a logical handler.
     */
public void testServerInboundRuntimeException1() 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 + 1, HA_THROW_RUNTIME_EXCEPTION_INBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    try {
        testStub.testInt(3);
        fail("did not receive exception");
    } catch (ProtocolException e) {
    // pass
    }
    // check result
    String[] called = { "4", "2", "1" };
    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 no destroyed handlers", destroyedHandlers.isEmpty());
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) HandlerTracker(fromwsdl.handler.common.HandlerTracker)

Example 4 with HandlerTracker

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

the class EndToEndErrorTester 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(fromwsdl.handler.common.HandlerTracker)

Example 5 with HandlerTracker

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

the class EndToEndErrorTester method testValidMustUnderstand.

/*
     * Test to make sure mustUnderstand headers of the right type get
     * through with no fault.
     */
public void testValidMustUnderstand() 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_ADD_GOOD_MU_HEADER_OUTBOUND);
    // so we clear out the client handlers afterwards
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_GOOD_MU_HEADER_OUTBOUND);
    // should get no fault
    int result = testStub.testInt(5);
    assertEquals("did not get int echoed back from server", 5, result);
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker)

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