Package com.volantis.mcs.eclipse.common.odom

Examples of com.volantis.mcs.eclipse.common.odom.ODOMElement


        // should have returned a ODOMElement
        assertEquals("should have returned a ODOMElement",
                     ODOMElement.class,
                     node.getClass());

        ODOMElement element = (ODOMElement) node;

        // check the name of the element
        assertEquals("element should be named 'newElement'",
                     "newElement",
                     element.getName());

        // check the namespaceURI of the element
        assertEquals("element bound to an unexpected namespace",
                     "http://www.w3.org/2001/XMLSchema",
                     element.getNamespaceURI());
    }
View Full Code Here


    /**
     * Test the removal of node and its parent nodes.
     */
    public void testRemoveGrandparentNodes() throws Exception {
        ODOMElement one = (ODOMElement) factory.element("one");
        ODOMElement two = (ODOMElement) factory.element("two");
        ODOMElement three = (ODOMElement) factory.element("three");
        ODOMAttribute threeAttrib =
                (ODOMAttribute) factory.attribute("threeAttrib", "");

        one.addContent(two);
        two.addContent(three);
        three.setAttribute(threeAttrib);

        ODOMXPath oneToThree = new ODOMXPath("two/three");
        ODOMXPath oneToThreeAttrib = new ODOMXPath(oneToThree,
                                           "@" + threeAttrib.getName());

        // Do the removal.
        ODOMObservable observable = oneToThreeAttrib.remove(one);

        assertNotNull("Node shouldn't be null", observable);
        assertTrue("Type should match", observable instanceof ODOMElement);
        ODOMElement element = (ODOMElement) observable;
        assertEquals("Name should match", "two", element.getName());
    }
View Full Code Here

    /**
     * Test removal of a grandchild that is the only child of an only child.
     */
    public void testRemoveMultiStepGrandchildElement() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMElement grandchild = (ODOMElement) factory.element("grandchild");
        ODOMXPath path = new ODOMXPath("child/grandchild");

        root.addContent(child.addContent(grandchild));

        ODOMObservable deleted = path.remove(root);
View Full Code Here

    /**
     * Test removal of a grandchild that is the only child of an only child.
     */
    public void testRemoveMultiStepGrandchildAttribute() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMAttribute grandchild = (ODOMAttribute) factory.attribute(
                "grandchild", "value");
        ODOMXPath path = new ODOMXPath("child/@grandchild");

        root.addContent(child);
        child.setAttribute(grandchild);

        ODOMObservable deleted = path.remove(root);

        assertNotNull("The deleted grandchild should have been found",
                      deleted);
View Full Code Here

    /**
     * Test removal of a grandchild that is the only child of an only child.
     */
    public void testRemoveMultiStepGrandchildText() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMText grandchild = (ODOMText) factory.text("grandchild");
        ODOMXPath path = new ODOMXPath("child/text()");

        root.addContent(child.addContent(grandchild));

        ODOMObservable deleted = path.remove(root);

        assertNotNull("The deleted grandchild should have been found",
                      deleted);
View Full Code Here

        assertEquals("parent not as ", null, path.getParent());
    }


    public void testSelectAttribute() throws Exception {
        final ODOMElement fourthCdElement = ((ODOMElement) (root.getChildren()
                .get(3)));
        ODOMAttribute attribute = (ODOMAttribute) fourthCdElement.getChild(
                "title")
                .getAttribute("testAttribute");
        assertEquals("sanity check", "remove", attribute.getValue());

        assertSelectFromODOMObservable(attribute);
View Full Code Here

        assertSelectFromODOMObservable(attribute);
    }


    public void testSelectAttributeWithinElemWithNS() throws Exception {
        final ODOMElement newElement = ((ODOMElement) (root.getChildren()
                .get(4)));
        ODOMAttribute attribute = (ODOMAttribute) newElement.getAttribute(
                "country");
        assertEquals("sanity check", "Nowhere", attribute.getValue());

        assertSelectFromODOMObservable(attribute);
    }
View Full Code Here

        assertSelectFromODOMObservable(attribute);
    }


    public void testSelectAttributeWithNSinPath() throws Exception {
        final ODOMElement newElement2 = ((ODOMElement) (root.getChildren()
                .get(5)));
        ODOMAttribute attribute = (ODOMAttribute) newElement2.getChild(
                "newElement2_2").getAttribute("attr2_2");
        assertEquals("sanity check", "attr2_2Value", attribute.getValue());

        assertSelectFromODOMObservable(attribute);
    }
View Full Code Here

        assertSelectFromODOMObservable(attribute);
    }

    public void testSelectTextNodeWithNSinPath() throws Exception {
        final ODOMElement newElement2 = ((ODOMElement) (root.getChildren()
                .get(5)));
        ODOMText odomText = (ODOMText) newElement2.getChild("newElement2_2").getContent().get(0);

        assertEquals("sanity check", "newElement2_2_text", odomText.getTextTrim());

        assertSelectFromODOMObservable(odomText);
    }
View Full Code Here

        assertSelectFromODOMObservable(odomText);
    }


    public void testSelectElementWithNS() throws Exception {
        final ODOMElement newElement2 = ((ODOMElement) (root.getChildren()
                .get(5)));
        assertEquals("sanity check", "newElement2", newElement2.getName());

        assertSelectFromODOMObservable(newElement2);
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.common.odom.ODOMElement

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.