Examples of OMFactory


Examples of org.apache.axiom.om.OMFactory

    public TestAddAttributeAlreadyOwnedByOtherElement(OMMetaFactory metaFactory) {
        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element1 = factory.createOMElement(new QName("test"));
        OMElement element2 = factory.createOMElement(new QName("test"));
        OMAttribute att1 = element1.addAttribute("test", "test", null);
        OMAttribute att2 = element2.addAttribute(att1);
        assertSame(element1, att1.getOwner());
        assertNotSame(att1, att2);
        assertSame(element2, att2.getOwner());
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public TestSetTextQNameWithExistingChildren(OMMetaFactory metaFactory) {
        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("TestElement", null);
       
        // Add some children of various types
        factory.createOMText(element, "some text");
        factory.createOMText(element, "cdata section", OMNode.CDATA_SECTION_NODE);
        factory.createOMComment(element, "comment");
        factory.createOMProcessingInstruction(element, "piTarget", "piData");
        factory.createOMElement("child", null, element);

        QName qname = new QName("urn:ns1", "test", "ns");
        element.setText(qname);

        assertEquals("ns:test", element.getText());
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public TestGetPrefixWithNamespace(OMMetaFactory metaFactory) {
        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement(new QName("urn:ns", "test", "p"));
        assertEquals("p", element.getPrefix());
    }
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

import java.util.Iterator;

public class OMChildrenWithSpecificAttributeIteratorTest extends TestCase {
    public void testChildrenRetrievalWithDetaching() {

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace testNamespace = factory.createOMNamespace("http://test.ws.org", "test");
        OMElement documentElement = getSampleDocumentElement(testNamespace);

        Iterator childrenIter = new OMChildrenWithSpecificAttributeIterator(
                documentElement.getFirstOMChild(),
                new QName(testNamespace.getNamespaceURI(), "myAttr",
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    }

    public void testChildrenRetrievalWithNoDetaching() {

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace testNamespace = factory.createOMNamespace("http://test.ws.org", "test");
        OMElement documentElement = getSampleDocumentElement(testNamespace);

        Iterator childrenIter = new OMChildrenWithSpecificAttributeIterator(
                documentElement.getFirstOMChild(),
                new QName(testNamespace.getNamespaceURI(), "myAttr",
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

                     childCount, 6);

    }

    private OMElement getSampleDocumentElement(OMNamespace testNamespace) {
        OMFactory factory = OMAbstractFactory.getOMFactory();

        OMElement documentElement = factory.createOMElement("Employees", testNamespace);
        documentElement.declareNamespace(testNamespace);

        OMElement employee;
        OMElement name;

        for (int i = 0; i < 5; i++) {
            employee = factory.createOMElement("Employee", testNamespace, documentElement);
            name = factory.createOMElement("Name" + i, testNamespace);
            employee.addAttribute("myAttr", "Axis2", testNamespace);
            name.setText("Apache Developer");
            employee.addChild(name);
        }

        //adding one more child with the given attr
        employee = factory.createOMElement("Employee", testNamespace, documentElement);
        name = factory.createOMElement("Name", testNamespace);
        name.addAttribute("myAttr", "Un-Related Value", testNamespace);
        name.setText("Apache Developer");
        employee.addChild(name);

        return documentElement;
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public TestCloneOMElement2(OMMetaFactory metaFactory, ConformanceTestFile file) {
        super(metaFactory, file);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        InputStream in = file.getAsStream();
        try {
            OMElement original = OMXMLBuilderFactory.createOMBuilder(factory, in).getDocumentElement();
            OMElement clone = original.cloneOMElement();
            XMLAssert.assertXMLIdentical(XMLUnit.compareXML(original.toString(), clone.toString()), true);
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public TestAddAttributeWithoutNamespace(OMMetaFactory metaFactory) {
        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", "urn:test", "");
        // Retrieve the namespace declaration generated by createOMElement
        OMNamespace ns = (OMNamespace)element.getAllDeclaredNamespaces().next();
        OMAttribute att = factory.createOMAttribute("test", null, "test");
        element.addAttribute(att);
        Iterator it = element.getAllDeclaredNamespaces();
        assertTrue(it.hasNext());
        assertEquals(ns, it.next());
        assertFalse(it.hasNext());
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public TestGetDefaultNamespace(OMMetaFactory metaFactory) {
        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement parent = factory.createOMElement("parent", "urn:ns1", "");
        OMElement child = factory.createOMElement(new QName("urn:ns2", "child", "p"), parent);
        OMNamespace ns = child.getDefaultNamespace();
        assertNotNull(ns);
        assertEquals("", ns.getPrefix());
        assertEquals("urn:ns1", ns.getNamespaceURI());
    }
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

       
        // Create a PEDS with the indicated behavior
        ParserInputStreamDataSource peds = new ParserInputStreamDataSource(is, "UTF-8", behavior);
       
        // Create a OM tree with a root that contains an OMSourcedElement with a PADS
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace ns = factory.createOMNamespace("urn://sample", "my");
        OMElement om = factory.createOMElement(peds, "payload", ns);
       
        QName rootQName = new QName("urn://root", "root", "pre");
        OMElement root = factory.createOMElement(rootQName);
        root.addChild(om);
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
       
        // Apply the scenario
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.