Methods Summary |
---|
java.lang.String | getFaultString(org.apache.axis.MessageContext msgContext)Extract the fault string from the Soap Response
String stRetval = null;
Message message = msgContext.getResponseMessage();
try {
if (message != null) {
SOAPBody oBody = message.getSOAPEnvelope().getBody();
stRetval = oBody.getFault().getFaultString();
}
}
catch (javax.xml.soap.SOAPException e) {
e.printStackTrace();
assertTrue("Unforseen soap exception", false);
}
catch (AxisFault f) {
f.printStackTrace();
assertTrue("Unforseen axis fault", false);
}
return stRetval;
|
protected void | setup()
|
public static junit.framework.Test | suite()
return new TestSuite(TestChainFault.class);
|
public void | testFaultDetailAvailableDuringInvoke()Ensure that the fault detail is being passed back
to handlers that executed prior to the fault
// the handler instance to validate
// NOTE:must execute before the handler that throws the fault
TestHandler testHandler = null;
try {
SimpleChain c = new SimpleChain();
for (int i = 0; i < 5; i++) {
TestHandler th = new TestHandler(i);
if (i == 2)
testHandler = th;
if (i == 3) {
th.setToFault();
}
c.addHandler(th);
}
TestMessageContext mc = new TestMessageContext();
try {
c.invoke(mc);
assertTrue("Testcase error - didn't throw fault", false);
} catch (AxisFault f) {
// did we save off the fault string?
assertEquals("faultstring does not match constant",
TestChainFault.FAULT_MESSAGE,
testHandler.getFaultCatch());
// does saved faultString match AxisFault?
assertEquals("Fault not caught by handler",
testHandler.getFaultCatch(),f.getFaultString());
}
} catch (Exception ex) {
assertTrue("Unexpected exception", false);
}
|
public void | testSimpleChainFaultAfterInvoke()
try {
SimpleChain c = new SimpleChain();
for (int i = 0; i < 5; i++) {
c.addHandler(new TestHandler(i));
}
TestMessageContext mc = new TestMessageContext();
c.invoke(mc);
c.onFault(mc);
assertEquals("Some onFaults were missed", mc.count(), 0);
} catch (Exception ex) {
assertTrue("Unexpected exception", false);
ex.printStackTrace();
}
|
public void | testSimpleChainFaultDuringInvoke()
try {
SimpleChain c = new SimpleChain();
for (int i = 0; i < 5; i++) {
TestHandler th = new TestHandler(i);
if (i == 3) {
th.setToFault();
}
c.addHandler(th);
}
TestMessageContext mc = new TestMessageContext();
try {
c.invoke(mc);
assertTrue("Testcase error - didn't throw fault", false);
} catch (AxisFault f) {
assertEquals("Some onFaults were missed", mc.count(), 0);
}
} catch (Exception ex) {
ex.printStackTrace();
assertTrue("Unexpected exception", false);
}
|