Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMFactory


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

    protected void runTest() throws Throwable {
        OMFactory f = metaFactory.getOMFactory();

        // Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
        OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
        OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
        OMElement element =
                f.createOMElement(new TestDataSource(testDocument), "DUMMYNAME", ns);
        OMElement root = f.createOMElement("root", rootNS);
        root.addChild(element);

        // Test getting the namespace, localpart and prefix.  This should used not result in expansion
        assertTrue(element.getLocalName().equals("DUMMYNAME"));
        assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
View Full Code Here


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

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement parent = factory.createOMElement("parent", null);
        OMElement child = factory.createOMElement("child", null, parent);
        OMNamespace ns = parent.declareNamespace("urn:test", "p");
        child.undeclarePrefix("p");
        assertEquals(ns, parent.findNamespaceURI("p"));
        assertNull(child.findNamespaceURI("p"));
    }
View Full Code Here

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

    protected void runTest() throws Throwable {
        OMFactory f = metaFactory.getOMFactory();

        // Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
        OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
        OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
        OMElement element =
                f.createOMElement(new TestDataSource(testDocument2), "library", ns);
        OMElement root = f.createOMElement("root", rootNS);
        root.addChild(element);

        // Test getting the namespace, localpart and prefix.  This should used not result in expansion
        assertTrue(element.getLocalName().equals("library"));
        assertTrue(element.getNamespace().getNamespaceURI().equals(
View Full Code Here

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

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

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

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element1 = factory.createOMElement("test", null);
        element1.addAttribute("attr", "value", null);
        OMElement element2 = factory.createOMElement("test", null);
        OMAttribute attr = element2.addAttribute("attr", "value", null);
        try {
            element1.removeAttribute(attr);
            fail("Expected OMException");
        } catch (OMException ex) {
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        // Build a root element and child OMSE
        OMFactory f = metaFactory.getOMFactory();
        OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
        OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
        OMElement child = f.createOMElement(new TestDataSource(testDocument), "library", ns);
        OMElement root = f.createOMElement("root", rootNS);
       
        // Trigger expansion of the child OMSE
        // This will cause the child to be partially parsed (i.e. incomplete)
        child.getChildren();
       
        // Add the child OMSE to the root.
        root.addChild(child);
       
        // Normally adding an incomplete child to a parent will
        // cause the parent to be marked as incomplete.
        // But OMSE's are self-contained...therefore the root
        // should still be complete
        assertTrue(!child.isComplete());
        assertTrue(root.isComplete());
       
        // Now repeat the test, but this time trigger the
        // partial parsing of the child after adding it to the root.
        child = f.createOMElement(new TestDataSource(testDocument), "library", ns);
        root = f.createOMElement("root", rootNS);
       
        root.addChild(child);
        child.getChildren(); // causes partial parsing...i.e. incomplete child
   
        assertTrue(!child.isComplete());
View Full Code Here

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

    protected void runTest() throws Throwable {
        OMFactory f = metaFactory.getOMFactory();

        // Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
        OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
        OMNamespace ns = f.createOMNamespace("", "");
        OMElement element =
                f.createOMElement(new TestDataSource(testDocument3), "library", ns);
        OMElement root = f.createOMElement("root", rootNS);
        root.addChild(element);

        // Test getting the namespace, localpart and prefix.  This should used not result in expansion
        assertTrue(element.getLocalName().equals("library"));
        assertNull(element.getNamespace());
View Full Code Here

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

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        OMAttribute attr1 = element.addAttribute("attr1", "value1", null);
        OMAttribute attr2 = element.addAttribute("attr2", "value2", null);
        element.removeAttribute(attr1);
        assertNull(attr1.getOwner());
        Iterator it = element.getAllAttributes();
View Full Code Here

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

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement incompleteElement = OMXMLBuilderFactory.createOMBuilder(factory,
                new StringReader("<elem>text</elem>")).getDocumentElement(true);
        OMElement root = factory.createOMElement("root", null);
        OMElement child = factory.createOMElement("child", null, root);
        child.addChild(incompleteElement);
        StringWriter out = new StringWriter();
        root.serializeAndConsume(out);
        assertEquals("<root><child><elem>text</elem></child></root>", out.toString());
        assertConsumed(incompleteElement);
View Full Code Here

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

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMNamespace ns = factory.createOMNamespace("urn:test", "p");
        OMElement parent = factory.createOMElement("parent", ns);
        OMElement child = factory.createOMElement("child", null, parent);
        child.setNamespace(ns);
        assertEquals(new QName("urn:test", "child"), child.getQName());
        assertEquals(ns, child.getNamespace());
        assertFalse(child.getAllDeclaredNamespaces().hasNext());
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMFactory

Copyright © 2018 www.massapicom. 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.