Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMSourcedElement.serialize()


    }
   
    public void testSerializeToBytes() throws Exception {
        OMSourcedElement element = createSourcedElement("test", UTF8);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        element.serialize(baos);
        byte[] actual = baos.toByteArray();
        baos.reset();
        // We validate the result by creating an equivalent OMElement
        // and calling serialize on it. The two results must be identical.
        element.cloneOMElement().serialize(baos);
View Full Code Here


    }
   
    public void testSerializeToChars() throws Exception {
        OMSourcedElement element = createSourcedElement("test", UTF8);
        StringWriter sw = new StringWriter();
        element.serialize(sw);
        String actual = sw.toString();
        sw.getBuffer().setLength(0);
        // Compare with the behavior of an equivalent OMElement
        element.cloneOMElement().serialize(sw);
        String expected = sw.toString();
View Full Code Here

        DocumentBean object = new DocumentBean();
        object.setId("test");
        OMSourcedElement element = omFactory.createOMElement(new JAXBOMDataSource(context, object));
        XMLStreamException exception = new XMLStreamException("TEST");
        try {
            element.serialize(new ExceptionXMLStreamWriterWrapper(StAXUtils.createXMLStreamWriter(new ByteArrayOutputStream()), exception));
            fail("Expected XMLStreamException");
        } catch (XMLStreamException ex) {
            assertSame(exception, ex);
        }
    }
View Full Code Here

    @Test
    public void test() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        JAXBContext context = JAXBContext.newInstance(DummyBean.class);
        OMSourcedElement element = factory.createOMElement(new JAXBOMDataSource(context, new DummyBean()));
        element.serialize(new ByteArrayOutputStream());
    }
}
View Full Code Here

    }
   
    public void testSerializeToBytes() throws Exception {
        OMSourcedElement element = createSourcedElement("test", UTF8);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        element.serialize(baos);
        byte[] actual = baos.toByteArray();
        baos.reset();
        // We validate the result by creating an equivalent OMElement
        // and calling serialize on it. The two results must be identical.
        element.cloneOMElement().serialize(baos);
View Full Code Here

    }
   
    public void testSerializeToChars() throws Exception {
        OMSourcedElement element = createSourcedElement("test", UTF8);
        StringWriter sw = new StringWriter();
        element.serialize(sw);
        String actual = sw.toString();
        sw.getBuffer().setLength(0);
        // Compare with the behavior of an equivalent OMElement
        element.cloneOMElement().serialize(sw);
        String expected = sw.toString();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.