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

Examples of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath


    /**
     * Overloaded helper method.
     */
    protected void doTest(Element start, Text end, String expected) {
        ODOMXPath xpath = new ODOMXPath(start, end);
        verifyResult(expected, xpath.getExternalForm());
    }
View Full Code Here


    /**
     * Overloaded helper method.
     */
    protected void doTest(Element start, ODOMObservable end, String expected) {
        ODOMXPath xpath = new ODOMXPath(start, end);
        verifyResult(expected, xpath.getExternalForm());
    }
View Full Code Here

    /**
     * Overloaded helper method.
     */
    protected void doTest(Element start, Element end, String expected) {
        ODOMXPath xpath = new ODOMXPath(start, end);
        verifyResult(expected, xpath.getExternalForm());
    }
View Full Code Here

    /**
     * Test the creation of an ODOMXPath when node exists.
     */
    public void testCreateNodeExists() throws Exception {
        // Check when element exists
        ODOMXPath path = new ODOMXPath("cd[2]");
        ODOMObservable result = path.create((ODOMElement) root, factory);
        assertNull("Result should be null", result);

        // Check when attribute exists
        path = new ODOMXPath("cd[2]/@country");
        result = path.create((ODOMElement) root, factory);
        assertNull("Result should be null", result);

        // Check when text exists
        path = new ODOMXPath("cd[2]/title/text()");
        result = path.create((ODOMElement) root, factory);
        assertNull("Result should be null", result);
    }
View Full Code Here

    /**
     * Test the creation of an ODOMXPath when node exists.
     */
    public void testCreateNodeTooGeneral() throws Exception {
        // Check when element exists
        ODOMXPath path = new ODOMXPath("cd");
        try {
            path.create((ODOMElement) root, factory);
            fail("Expected an IllegalStateException.");
        } catch (IllegalStateException e) {
        }
    }
View Full Code Here

     * Test creation of a multi-step path where none of the path element steps
     * exist and where all but the last element step exists.
     */
    public void testCreateElementMultiStep() throws Exception {
        ODOMElement context = (ODOMElement) factory.element("root");
        ODOMXPath path = new ODOMXPath("a/b");

        // Test creation of whole path from empty context
        ODOMObservable newNode = path.create(context, factory);

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

        assertEquals("Created element path not as",
                     "/root/a/b",
                     new ODOMXPath(newNode).getExternalForm());

        // Test creation of single additional step
        path = new ODOMXPath(path, "c");

        newNode = path.create(context, factory);

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

        assertEquals("Created element path not as",
                     "/root/a/b/c",
                     new ODOMXPath(newNode).getExternalForm());
    }
View Full Code Here

     * Test creation of a multi-step path where none of the path element steps
     * exist and where all the element steps exist.
     */
    public void testCreateAttributeMultiStep() throws Exception {
        ODOMElement context = (ODOMElement) factory.element("root");
        ODOMXPath path = new ODOMXPath("a/@b");

        // Test creation of whole path from empty context
        ODOMObservable newNode = path.create(context, factory);

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

        assertEquals("Created attribute path not as",
                     "/root/a/@b",
                     new ODOMXPath(newNode).getExternalForm());

        // Test creation of single additional step
        path = new ODOMXPath("a/@c");

        newNode = path.create(context, factory);

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

        assertEquals("Created attribute path not as",
                     "/root/a/@c",
                     new ODOMXPath(newNode).getExternalForm());
    }
View Full Code Here

     * Test creation of a multi-step path where none of the path element steps
     * exist and where all the element steps exist.
     */
    public void testCreateTextMultiStep() throws Exception {
        ODOMElement context = (ODOMElement) factory.element("root");
        ODOMXPath path = new ODOMXPath("a/b/text()");

        // Test creation of whole path from empty context
        ODOMObservable newNode = path.create(context, factory);

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

        assertEquals("Created text path not as",
                     "/root/a/b/text()",
                     new ODOMXPath(newNode).getExternalForm());

        // Test creation of single additional step
        path = new ODOMXPath("a/text()");

        newNode = path.create(context, factory);

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

        assertEquals("Created text path not as",
                     "/root/a/text()",
                     new ODOMXPath(newNode).getExternalForm());
    }
View Full Code Here

        setUp(source);

        // 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

    /**
     * Tests multi-step path creation where the path is absolute.
     */
    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

TOP

Related Classes of com.volantis.mcs.eclipse.common.odom.xpath.ODOMXPath

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.