Examples of ODOMObservable


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

        // This should cause the creation of a second page with a number
        // attribute
        ODOMXPath path = new ODOMXPath("catalogue/page[2]/@number");

        ODOMObservable newNode = path.create((ODOMElement) root, factory);

        assertTrue("New node not an attribute (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Attribute);

        assertEquals("Created page attribute path not as",
                     "/root/catalogue/page[2]/@number",
                     new ODOMXPath(newNode).getExternalForm());

        // This should cause the creation of a new item with nested name
        // element
        path = new ODOMXPath("catalogue/page[2]/item/name");

        newNode = path.create((ODOMElement) root, factory);

        assertTrue("New node not an element (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Element);

        assertEquals("Created item name element path not as",
                     "/root/catalogue/page[2]/item/name",
                     new ODOMXPath(newNode).getExternalForm());

        // This should cause the creation of a text node within the previously
        // created item's name element
        path = new ODOMXPath(path, "text()");

        newNode = path.create((ODOMElement) root, factory);

        assertTrue("New node not a text (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Text);

        assertEquals("Created item name text path not as",
                     "/root/catalogue/page[2]/item/name/text()",
                     new ODOMXPath(newNode).getExternalForm());
View Full Code Here

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

    public void testCreateWithAbsolutePath() throws Exception {
        ODOMXPath path = new ODOMXPath("/catalog/cd[6]/title/text()");

        // This should cause the creation of CD nodes 5 and 6 and a title
        // node within CD 6 with a nested text node
        ODOMObservable newNode = path.create((ODOMElement) root, factory);

        assertTrue("New CD title text not a text (is a " +
                   newNode.getClass().getName() + ")",
                   newNode instanceof Text);

        assertEquals("Created CD title text path not as",
                     path.getExternalForm(),
                     new ODOMXPath(newNode).getExternalForm());
View Full Code Here

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

     */
    public void testCreateSimple() throws Exception {
        // Check when element does not exist.
        String elementName = "newElement";
        ODOMXPath path = new ODOMXPath(elementName);
        ODOMObservable result = path.create((ODOMElement) root, factory);
        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Element);
        assertEquals("Value should match", elementName,
                     ((Element) result).getName());

View Full Code Here

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

     */
    public void testCreateWithNamespace() throws Exception {
        // Check when element does not exist.
        String elementName = "ns1:newElement/notNamespaced/ns1:namespaced";
        ODOMXPath path = new ODOMXPath(elementName);
        ODOMObservable result = null;
        try {
            result = path.create((ODOMElement) root, factory);
            fail("Expected IllegalStateException (no namespaces set)");
        } catch (IllegalStateException e) {
        }
        path = new ODOMXPath(elementName, NAMESPACES);
        result = path.create((ODOMElement) root, factory);
        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Element);
        assertEquals("Value should match", "namespaced",
                     ((Element) result).getName());
        assertEquals("Value should match", "ns1",
                     ((Element) result).getNamespace().getPrefix());
        Element parent = result.getParent();
        assertEquals("Value for parent should match",
                     "notNamespaced", parent.getName());
        assertEquals("Prefix for parent namespace should match",
                     "", parent.getNamespacePrefix());
    }
View Full Code Here

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

     */
    public void testCreateWithNamespaceExists() throws Exception {
        // Check when element does not exist.
        String elementName = "ns1:newElement";
        ODOMXPath path = new ODOMXPath(elementName);
        ODOMObservable result = null;
        try {
            result = path.create((ODOMElement) root, factory);
            fail("Expected IllegalStateException (no namespaces set)");
        } catch (IllegalStateException e) {
        }
View Full Code Here

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

     */
    public void testCreateWithPredicateNoneExist() throws Exception {
        // Check when element does not exist.
        String elementName = "predicateElement[4]";
        ODOMXPath path = new ODOMXPath(elementName);
        ODOMObservable result = null;
        result = path.create((ODOMElement) root, factory);
        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Element);
        assertEquals("Value should match", "predicateElement",
                     ((Element) result).getName());
View Full Code Here

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

     */
    public void testCreateWithPredicateForText() throws Exception {
        // Check when element does not exist.
        String path = "cd[1]/title/text()[2]";
        ODOMXPath xpath = new ODOMXPath(path);
        ODOMObservable result = xpath.create((ODOMElement) root, factory);

        assertNotNull("Result should not be null", result);
        assertTrue("Type should match", result instanceof Text);
        ((Text) result).setText("Garbage");
        //showDocument();
View Full Code Here

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

    public void testSelectSingleNodeWithNamespaces() throws Exception {

        // select the newElement node in the
        // http://www.w3.org/2001/XMLSchema namespace.
        ODOMXPath xpath = new ODOMXPath("ns1:newElement", NAMESPACES);
        ODOMObservable node = xpath.selectSingleNode((ODOMObservable) root);

        // ensure the node is not null
        assertNotNull("node selected was null", node);

        // 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'",
View Full Code Here

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

        // use a different prefix (same URI) to that in the DOM
        ODOMXPath xpath = new ODOMXPath("p:newElement", new Namespace[]{
            Namespace.getNamespace("p", "http://www.w3.org/2001/XMLSchema")
        });

        ODOMObservable node = xpath.selectSingleNode((ODOMObservable) root);

        // ensure the node is not null
        assertNotNull("node selected was null", node);

        // 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'",
View Full Code Here

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

     * Test the removal of an Element node.
     */
    public void testRemoveElement() throws Exception {
        ODOMXPath path = new ODOMXPath("cd");

        ODOMObservable removed = path.remove((ODOMObservable) root);

        assertNotNull("Removed element should exist", removed);
        assertTrue("Should be an Element", removed instanceof Element);
        Element element = (Element) removed;
        assertEquals("Name should match", "cd", element.getName());
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.