use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TestGetDocumentElementWithDiscardDocumentIllFormedEpilog method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<root/> there shouldn't be text here!"));
OMElement element = builder.getDocumentElement(true);
try {
element.build();
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TestAddChildWithExistingDocumentElement method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDocument document = factory.createOMDocument();
document.addChild(factory.createOMElement(new QName("root1")));
try {
document.addChild(factory.createOMElement(new QName("root2")));
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TestCreateOMBuilderFromDOMWithNSUnawarePrefixedAttribute method runTest.
@Override
protected void runTest() throws Throwable {
Element domElement = DOMImplementation.XERCES.newDocument().createElementNS(null, "test");
domElement.setAttribute("p:attr", "value");
try {
OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), domElement, false).getDocument().build();
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class AbstractOMDataSource method getXMLBytes.
@Override
public final byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(encoding);
try {
serialize(baos, format);
} catch (XMLStreamException ex) {
throw new OMException(ex);
}
return baos.toByteArray();
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TextContent method appendTo.
@Override
public void appendTo(StringBuilder buffer) {
if (binary) {
Base64EncodingStringBufferOutputStream out = new Base64EncodingStringBufferOutputStream(buffer);
try {
getDataHandler().writeTo(out);
out.complete();
} catch (IOException ex) {
throw new OMException(ex);
}
} else {
buffer.append(value);
}
}
Aggregations