@Test public void testNewLineInExceptionMessage() throws Exception { Greeter greeter = getGreeter(); try { greeter.greetMe("newline"); fail("Should throw Exception!"); } catch (SOAPFaultException ex) { assertEquals("greetMeFault Caused by: Get a wrong name <greetMe>", ex.getMessage()); StackTraceElement[] elements = ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11", elements[0].getClassName()); assertTrue(ex.getCause().getCause().getMessage().endsWith("Test \n cause.")); } }
@org.junit.Test public void testPlaintext() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = EmptySOAPBodyTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = EmptySOAPBodyTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); try { port.doubleIt(25); fail("Should have thown an exception"); } catch (SOAPFaultException t) { assertTrue("Wrong exception cause " + t.getCause(), t.getCause() instanceof IllegalEmptyResponseException); } ((java.io.Closeable)port).close(); bus.shutdown(true); }
@Test public void testFaultMessage() throws Exception { Greeter greeter = getGreeter(); try { greeter.sayHi(); fail("Should throw Exception!"); } catch (SOAPFaultException ex) { assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>", ex.getMessage()); StackTraceElement[] element = ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl12", element[0].getClassName()); } }
fail("Should have thrown SOAPFaultException exception"); } catch (SOAPFaultException sfe) { assertEquals("TestIllegalArgumentException", sfe.getCause().getMessage()); sfe.printStackTrace(); } catch (ExecutionException ee) { SOAPFaultException sfe = (SOAPFaultException)ee.getCause(); assertEquals("TestIllegalArgumentException", sfe.getCause().getMessage());
} catch (SOAPFaultException ex) { assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>", ex.getMessage()); StackTraceElement[] elements = ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11", elements[0].getClassName());
@Test public void testComplexType() throws Exception { SOAPServiceRPCLit service = new SOAPServiceRPCLit(); assertNotNull(service); GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); updateAddressPort(greeter, PORT); MyComplexStruct in = new MyComplexStruct(); in.setElem1("elem1"); in.setElem2("elem2"); in.setElem3(45); try { ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE); MyComplexStruct out = greeter.sendReceiveData(in); assertNotNull("no response received from service", out); assertEquals(in.getElem1(), out.getElem1()); assertEquals(in.getElem2(), out.getElem2()); assertEquals(in.getElem3(), out.getElem3()); } catch (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } try { in.setElem2("invalid"); greeter.sendReceiveData(in); } catch (SOAPFaultException f) { assertTrue(f.getCause() instanceof UnmarshalException); } }