use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class EmptySOAPBodyTest method testPlaintext.
@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 IllegalStateException);
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class Soap11ClientServerTest method testFaultMessage.
@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[] elements = ex.getCause().getStackTrace();
assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11", elements[0].getClassName());
}
// testing Fault(new NullPointerException())
try {
greeter.greetMe("Anya");
fail("Should throw Exception!");
} catch (SOAPFaultException ex) {
assertEquals(NullPointerException.class.getName(), ex.getMessage());
}
// testing Fault(new IllegalArgumentException("Get a wrong name for greetMe"))
try {
greeter.greetMe("Banya");
fail("Should throw Exception!");
} catch (SOAPFaultException ex) {
assertEquals("Get a wrong name for greetMe", ex.getMessage());
}
// testing Fault("unexpected null", LOG, new NullPointerException())
try {
greeter.greetMe("Canya");
fail("Should throw Exception!");
} catch (SOAPFaultException ex) {
assertEquals("unexpected null", ex.getMessage());
}
// testing Fault("greetMeFault", LOG, new IllegalArgumentException("Get a wrong name greetMe"))
try {
greeter.greetMe("Danya");
fail("Should throw Exception!");
} catch (SOAPFaultException ex) {
assertEquals("greetMeFault Caused by: Get a wrong name greetMe", ex.getMessage());
}
// testing Fault("invalid", LOG)
try {
greeter.greetMe("Eanna");
fail("Should throw Exception!");
} catch (SOAPFaultException ex) {
assertEquals("invalid", ex.getMessage());
}
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class Soap11ClientServerTest method testNewLineInExceptionMessage.
@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."));
}
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class SOAPDocLitClientTypeTest method testValidationFailureOnServerOut.
@Test
public void testValidationFailureOnServerOut() throws Exception {
FixedArray x = new FixedArray();
FixedArray yOrig = new FixedArray();
x.getItem().addAll(Arrays.asList(24, 42, 2008));
yOrig.getItem().addAll(Arrays.asList(24, 0, 1));
Holder<FixedArray> y = new Holder<FixedArray>(yOrig);
Holder<FixedArray> z = new Holder<FixedArray>();
try {
docClient.testFixedArray(x, y, z);
fail("should have thrown exception");
} catch (SOAPFaultException ex) {
assertTrue(ex.getMessage(), ex.getMessage().contains("Marshalling"));
}
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class AbstractJAXWSMethodInvoker method createFault.
@Override
protected Fault createFault(Throwable ex, Method m, List<Object> params, boolean checked) {
// map the JAX-WS faults
SOAPFaultException sfe = findSoapFaultException(ex);
if (sfe != null) {
SoapFault fault = new SoapFault(sfe.getFault().getFaultString(), ex, sfe.getFault().getFaultCodeAsQName());
fault.setRole(sfe.getFault().getFaultActor());
if (sfe.getFault().hasDetail()) {
fault.setDetail(sfe.getFault().getDetail());
}
return fault;
}
return super.createFault(ex, m, params, checked);
}
Aggregations