Search in sources :

Example 1 with SOAPFaultChild

use of org.apache.axiom.ts.soap.SOAPFaultChild in project webservices-axiom by apache.

the class TestChildOrder method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFault fault = soapFactory.createSOAPFault();
    // Add the elements in the specified order.
    for (int i = 0; i < inputOrder.length; i++) {
        SOAPElementTypeAdapter adapter = inputOrder[i].getAdapter(SOAPElementTypeAdapter.class);
        adapter.getSetter().invoke(fault, adapter.create(soapFactory));
    }
    // Calculate the order in which we expect to see the children. Note that a given type
    // may be added multiple times. Therefore we need to use a Set.
    SortedSet<SOAPFaultChild> outputOrder = new TreeSet<>(new Comparator<SOAPFaultChild>() {

        @Override
        public int compare(SOAPFaultChild o1, SOAPFaultChild o2) {
            return o1.getOrder() - o2.getOrder();
        }
    });
    outputOrder.addAll(Arrays.asList(inputOrder));
    // Check the result using the given serialization strategy
    Document document = DOMImplementation.XERCES.parse(serializationStrategy.serialize(fault).getInputSource());
    Element domFault = document.getDocumentElement();
    Node child = domFault.getFirstChild();
    for (SOAPFaultChild type : outputOrder) {
        assertNotNull(child);
        assertEquals(type.getQName(spec).getLocalPart(), child.getLocalName());
        child = child.getNextSibling();
    }
    assertNull(child);
}
Also used : TreeSet(java.util.TreeSet) SOAPElementTypeAdapter(org.apache.axiom.ts.soap.SOAPElementTypeAdapter) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) SOAPFault(org.apache.axiom.soap.SOAPFault) Document(org.w3c.dom.Document) SOAPFaultChild(org.apache.axiom.ts.soap.SOAPFaultChild)

Aggregations

TreeSet (java.util.TreeSet)1 SOAPFault (org.apache.axiom.soap.SOAPFault)1 SOAPElementTypeAdapter (org.apache.axiom.ts.soap.SOAPElementTypeAdapter)1 SOAPFaultChild (org.apache.axiom.ts.soap.SOAPFaultChild)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1