You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Mark Roder <mr...@wamnet.com> on 2001/10/19 00:42:28 UTC
New test to validate decode of faults.
Here is a test to validate decode of faults.
This test shows an error I am seeing where the fault is not filled in.
Can someone add this to the test framework somewhere. Fixing the problem
would be great as well!!! :-)
Thanks
Mark
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPFaultElement;
import org.apache.axis.server.AxisServer;
public class FaultDecode extends TestCase
{
public FaultDecode(String name)
{
super(name);
}
public void testFault()
throws Exception
{
String messageText = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+"<soap:Header>"
+""
+"</soap:Header> "
+"<soap:Body> "
+" <soap:Fault>"
+" <faultcode>Some.FaultCode</faultcode>"
+" <faultstring>This caused a fault</faultstring>"
+" <detail>This was a really bad thing</detail>"
+" </soap:Fault>"
+"</soap:Body>"
+"</soap:Envelope>";
AxisServer server = new AxisServer();
Message message = new Message(messageText);
message.setMessageContext(new MessageContext(server));
SOAPEnvelope envelope = (SOAPEnvelope)message.getAsSOAPEnvelope();
this.assertNotNull("envelope", envelope);
SOAPBodyElement respBody = envelope.getFirstBody();
this.assertTrue("respBody should be a SOAPFaultElement",respBody
instanceof SOAPFaultElement);
AxisFault aFault = ((SOAPFaultElement)respBody).getAxisFault();
System.out.println(aFault);
this.assertNotNull("Fault should not be null",aFault);
this.assertNotNull("faultCode should not be
null",aFault.getFaultCode());
this.assertNotNull("faultString should not be
null",aFault.getFaultString());
this.assertNotNull("faultDetails should not be
null",aFault.getFaultDetails());
}
}