FileDocCategorySizeDatePackage
TestSOAPFaultDetail.javaAPI DocApache Axis 1.43293Sat Apr 22 18:57:28 BST 2006test.saaj

TestSOAPFaultDetail

public class TestSOAPFaultDetail extends TestCase

Fields Summary
private org.apache.axis.MessageContext
_msgContext
String
xmlString
Constructors Summary
public TestSOAPFaultDetail(String name)

        super(name);
        _msgContext = new MessageContext(new AxisServer());
    
Methods Summary
private org.apache.axis.message.SOAPBodyElementgetFirstBody(org.xml.sax.InputSource msgSource)

        DeserializationContext dser = new DeserializationContext(
                msgSource, _msgContext, Message.RESPONSE);
        dser.parse();
        SOAPEnvelope env = dser.getEnvelope();

        return env.getFirstBody();
    
public static voidmain(java.lang.String[] args)
Main

        TestSOAPFaultDetail detailTest = new TestSOAPFaultDetail("faultdetails");
        detailTest.testDetails();
    
public voidtestDetails()



        
    
        Reader reader = new StringReader(xmlString);
        InputSource src = new InputSource(reader);
        SOAPBodyElement bodyItem = getFirstBody(src);
        assertTrue("The SOAPBodyElement I got was not a SOAPFault, it was a " +
                bodyItem.getClass().getName(), bodyItem instanceof SOAPFault);
        SOAPFault flt = (SOAPFault)bodyItem;
        flt.addDetail();
        javax.xml.soap.Detail d = flt.getDetail();
        Iterator i = d.getDetailEntries();
        while (i.hasNext())
        {
            DetailEntry entry = (DetailEntry) i.next();
            String name = entry.getElementName().getLocalName();
            if ("tickerSymbol".equals(name)) {
                assertEquals("the value of the tickerSymbol element didn't match",
                        "MACR", entry.getValue());
            } else if ("exceptionName".equals(name)) {
                assertEquals("the value of the exceptionName element didn't match",
                        "test.wsdl.faults.InvalidTickerFaultMessage", entry.getValue());
            } else {
                assertTrue("Expecting details element name of 'tickerSymbol' or 'expceptionName' - I found :" + name, false);
            }
        }
        assertTrue(d != null);