FileDocCategorySizeDatePackage
TestAxisFault.javaAPI DocApache Axis 1.45021Sat Apr 22 18:57:28 BST 2006test.faults

TestAxisFault

public class TestAxisFault extends TestCase
unit tests for the ubiquitous AxisFault

Fields Summary
Constructors Summary
public TestAxisFault(String s)

        super(s);
    
Methods Summary
public org.w3c.dom.ElementcreateElement(java.lang.String tag, java.lang.String child)

        Document doc = null;
        try {
            doc = XMLUtils.newDocument();
        } catch (ParserConfigurationException e) {
            throw new RuntimeException("xml trouble");
        }
        Element element = doc.createElement(tag);
        Text text = doc.createTextNode(child);
        element.appendChild(text);
        return element;
    
private voiddumpFault(org.apache.axis.AxisFault af)
helper method to stick in when diagnosing stuff

param
af

        String s=af.dumpToString();
        System.out.println(s);
    
public static junit.framework.Testsuite()

        return new TestSuite(TestAxisFault.class);
    
public voidtestArrayAddWorks()

        AxisFault af = new AxisFault();
        af.addFaultDetailString("alles geht gut");
        Element array[]=new Element[2];
        array[0] = createElement("ein","un");
        array[1] = createElement("zwei", "deux");
        af.setFaultDetail(array);
        Element match = af.lookupFaultDetail(new QName(null, "zwei"));
        assertNotNull(match);
        Element old = af.lookupFaultDetail(new QName(null, "string"));
        assertNull(old);
    
public voidtestAxisFaultFillIn()
test that making an axis fault from an axis fault retains it

        AxisFault af1=new AxisFault("fault1");
        AxisFault af2=AxisFault.makeFault(af1);
        assertSame(af1,af2);
    
public voidtestDetailRemoval()
test we can remove some detail

        Exception e = new Exception("foo");
        AxisFault af = AxisFault.makeFault(e);
        assertTrue(af.removeFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE));
        Element stackTrace;
        stackTrace = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE);
        assertNull(stackTrace);
        String text=af.getFaultString();
        assertNotNull(text);
        text=af.toString();
        assertNotNull(text);
    
public voidtestEmptyArrayAddWorks()

        AxisFault af = new AxisFault();
        af.addFaultDetailString("alles geht gut");
        Element array[] = new Element[0];
        af.setFaultDetail(array);
        Element old = af.lookupFaultDetail(new QName(null, "string"));
        assertNull(old);
    
public voidtestEmptyNamespaceLookup()
verify we can properly lookup empty namespace stuff

        AxisFault af=new AxisFault();
        af.addFaultDetailString("alles geht gut");
        Element match=af.lookupFaultDetail(new QName(null,"string"));
        assertNotNull(match);
    
public voidtestExceptionFillIn()
test that exceptions are filled in

        Exception e=new Exception("foo");
        AxisFault af=AxisFault.makeFault(e);
        Element stackTrace;
        stackTrace = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE);
        assertNotNull(stackTrace);
        Element exceptionName;
        exceptionName = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_EXCEPTIONNAME);
        assertNull(exceptionName);
        QName faultCode=af.getFaultCode();
        assertEquals(faultCode.getLocalPart(), Constants.FAULT_SERVER_USER);
    
public voidtestSubclassProcessing()
test what happens with subclasses. We expect the classname to be preserved in the details

        AxisFault af=new NoEndPointException();
        Element exceptionName;
        exceptionName = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_EXCEPTIONNAME);
        assertNotNull(exceptionName);
        String exceptionClassname= XMLUtils.getInnerXMLString(exceptionName);
        assertTrue(exceptionClassname.indexOf("NoEndPointException")>=0);