Search in sources :

Example 1 with NodeUnavailableException

use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.

the class TestAddChildDiscarded method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement parent = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<root><a/><b/></root>")).getDocumentElement();
    // Partially build the parent
    parent.getFirstOMChild();
    parent.discard();
    try {
        parent.addChild(factory.createOMElement("c", null));
        fail("Expected NodeUnavailableException");
    } catch (NodeUnavailableException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringReader(java.io.StringReader) NodeUnavailableException(org.apache.axiom.om.NodeUnavailableException) OMElement(org.apache.axiom.om.OMElement)

Example 2 with NodeUnavailableException

use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.

the class TestGetNextOMSiblingAfterDiscard method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<element><!--comment--><a/><!--comment--></element>")).getDocumentElement();
    OMNode child = element.getFirstOMChild();
    element.discard();
    try {
        child.getNextOMSibling();
        fail("Expected NodeUnavailableException");
    } catch (NodeUnavailableException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNode(org.apache.axiom.om.OMNode) StringReader(java.io.StringReader) NodeUnavailableException(org.apache.axiom.om.NodeUnavailableException) OMElement(org.apache.axiom.om.OMElement)

Example 3 with NodeUnavailableException

use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.

the class TestBuildDiscarded method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement parent = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<root><a/><b/></root>")).getDocumentElement();
    // Partially build the parent
    parent.getFirstOMChild();
    parent.discard();
    try {
        parent.build();
        fail("Expected NodeUnavailableException");
    } catch (NodeUnavailableException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringReader(java.io.StringReader) NodeUnavailableException(org.apache.axiom.om.NodeUnavailableException) OMElement(org.apache.axiom.om.OMElement)

Example 4 with NodeUnavailableException

use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.

the class TestGetFirstOMChildAfterConsume method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<element><!--comment--><a/><!--comment--></element>")).getDocumentElement();
    XMLStreamReader reader = element.getXMLStreamReaderWithoutCaching();
    while (reader.hasNext()) {
        reader.next();
    }
    try {
        element.getFirstOMChild();
        fail("Expected NodeUnavailableException");
    } catch (NodeUnavailableException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) XMLStreamReader(javax.xml.stream.XMLStreamReader) StringReader(java.io.StringReader) NodeUnavailableException(org.apache.axiom.om.NodeUnavailableException) OMElement(org.apache.axiom.om.OMElement)

Example 5 with NodeUnavailableException

use of org.apache.axiom.om.NodeUnavailableException in project webservices-axiom by apache.

the class TestGetFirstOMChildAfterDiscard method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<element><!--comment--><a/><!--comment--></element>")).getDocumentElement();
    element.discard();
    try {
        element.getFirstOMChild();
        fail("Expected NodeUnavailableException");
    } catch (NodeUnavailableException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringReader(java.io.StringReader) NodeUnavailableException(org.apache.axiom.om.NodeUnavailableException) OMElement(org.apache.axiom.om.OMElement)

Aggregations

NodeUnavailableException (org.apache.axiom.om.NodeUnavailableException)7 OMElement (org.apache.axiom.om.OMElement)7 StringReader (java.io.StringReader)5 OMFactory (org.apache.axiom.om.OMFactory)5 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)2 OMNode (org.apache.axiom.om.OMNode)1