private void testFail(FaultLocation location, boolean usingAddressing, boolean robust) throws PingMeFault { // System.out.print("Test interceptor failing in phase: " + location.getPhase()); control.setFaultLocation(location); // oneway reports a plain fault (although server sends a soap fault) boolean expectOnewayFault = robust || comparator.compare(preLogicalPhase, getPhase(location.getPhase())) > 0; try { greeter.greetMeOneWay("oneway"); if (expectOnewayFault) { fail("Oneway operation unexpectedly succeded for phase " + location.getPhase()); } } catch (WebServiceException ex) { if (!expectOnewayFault) { fail("Oneway operation unexpectedly failed."); } assertEquals(FAULT_MESSAGE, ex.getMessage()); } String expectedMsg = getExpectedInterceptorFaultMessage(location.getPhase()); try { greeter.greetMe("cxf"); fail("Twoway operation unexpectedly succeded."); } catch (WebServiceException ex) { Throwable cause = ex.getCause(); SoapFault sf = (SoapFault) cause; assertEquals(expectedMsg, sf.getReason()); assertEquals(SOAP_FAULT_CODE, sf.getFaultCode()); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch (WebServiceException ex) { Throwable cause = ex.getCause(); SoapFault sf = (SoapFault) cause; assertEquals(expectedMsg, sf.getReason()); assertEquals(SOAP_FAULT_CODE, sf.getFaultCode()); } }
private void testInterceptorsPass(boolean robust) { greeter.greetMeOneWay("one"); // wait 5 seconds for the non-robust case if (!robust) { try { Thread.sleep(5000); } catch (InterruptedException e) { // ignore } } // verify both the previous greetMeOneWay call and this greetMe call assertEquals("one", greeter.greetMe("two")); try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch (PingMeFault f) { assertEquals(20, f.getFaultInfo().getMajor()); assertEquals(10, f.getFaultInfo().getMinor()); } }