Examples of ODOMXPath


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

    }


    private void assertSelectFromODOMObservable(ODOMObservable odomObservable)
            throws XPathException {
        ODOMXPath xpath = new ODOMXPath(odomObservable);
        assertEquals("selected odomObservable", odomObservable,
                     xpath.selectSingleNode(doc));
    }
View Full Code Here

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

        for (int i = 0; i < NAMESPACES.length; i++) {
            Namespace namespace = NAMESPACES[i];
            map.put(namespace.getPrefix(), namespace.getURI());
        }
        // Check using string path.
        verifyObjectState(new ODOMXPath(path), path, emptyMap);
        verifyObjectState(new ODOMXPath(path, namespacesNull), path, emptyMap);
        verifyObjectState(new ODOMXPath(path, NAMESPACES), path, map);

        // Check using element.
        Element parent = new Element("parent");
        String xpath = "/parent/element";
        Element element = new Element("element");
        parent.addContent(element);
        verifyObjectState(new ODOMXPath(element), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(element, namespacesNull), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(element, NAMESPACES), xpath, map);

        // Check using attribute.
        xpath = "/parent/@attribute";
        parent = new Element("parent");
        Attribute attribute = new Attribute("attribute", "");
        parent.setAttribute(attribute);
        verifyObjectState(new ODOMXPath(attribute), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(attribute, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(attribute, NAMESPACES), xpath, map);

        // Check using text.
        xpath = "/parent/text()";
        parent = new Element("parent");
        Text text = new Text("textExample");
        parent.addContent(text);
        verifyObjectState(new ODOMXPath(text), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(text, namespacesNull), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(text, NAMESPACES), xpath, map);

        // Check using ODOMObservable.
        xpath = "/parent/textExample";
        parent = new Element("parent");
        ODOMObservable node = (ODOMElement) factory.element("textExample");
        parent.addContent((Element) node);
        verifyObjectState(new ODOMXPath(node), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(node, namespacesNull), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(node, NAMESPACES), xpath, map);

        // Check using element.
        xpath = "/parent/element";
        parent = new Element("parent");
        Element start = new Element("startElement");
        element = new Element("element");
        parent.addContent(element);
        verifyObjectState(new ODOMXPath(start, element), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, element, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(start, element, NAMESPACES), xpath, map);

        // Check using attribute.
        xpath = "/parent/@attribute";
        parent = new Element("parent");
        start = new Element("startElement");
        attribute = new Attribute("attribute", "");
        parent.setAttribute(attribute);
        verifyObjectState(new ODOMXPath(start, attribute), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, attribute, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(start, attribute, NAMESPACES), xpath, map);

        // Check using text.
        xpath = "/parent/text()";
        parent = new Element("parent");
        text = new Text("textExample");
        parent.addContent(text);
        start = new Element("startElement");
        verifyObjectState(new ODOMXPath(start, text), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, text, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(start, text, NAMESPACES), xpath, map);

        // Check using ODOMObservable.
        xpath = "/parent/textExample";
        parent = new Element("parent");
        node = (ODOMElement) factory.element("textExample");
        parent.addContent((Element) node);
        start = new Element("startElement");
        verifyObjectState(new ODOMXPath(start, node), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, node, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(start, node, NAMESPACES), xpath, map);

        // Check using ODOMObservable.
        xpath = "/xpath/to/this/value/isOK";
        ODOMXPath testXPath = new ODOMXPath("/xpath/to/this/value");
        verifyObjectState(new ODOMXPath(testXPath, "isOK"), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(testXPath, "isOK", namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(testXPath, "isOK", NAMESPACES), xpath,
                          map);

        // Check using attribute.
        xpath = "/start/element/@attribute";
        parent = new Element("parent");
        attribute = new Attribute("attribute", "");
        parent.setAttribute(attribute);
        ODOMXPath startXPath = new ODOMXPath("/start/element");
        verifyObjectState(new ODOMXPath(startXPath, attribute), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(startXPath, attribute, namespacesNull),
                          xpath, emptyMap);
        verifyObjectState(new ODOMXPath(startXPath, attribute, NAMESPACES), xpath,
                          map);

        // Check using attribute.
        xpath = "/start/element/relative/xpath";
        parent = new Element("parent");
        attribute = new Attribute("attribute", "");
        parent.setAttribute(attribute);
        startXPath = new ODOMXPath("/start/element");
        ODOMXPath relative = new ODOMXPath("relative/xpath");
        verifyObjectState(new ODOMXPath(startXPath, relative), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(startXPath, relative, namespacesNull),
                          xpath, emptyMap);
        verifyObjectState(new ODOMXPath(startXPath, relative, NAMESPACES), xpath,
                          map);

    }
View Full Code Here

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

    /**
     * Test that the getDOMType() method behaves as expected for each of
     * the three current DOMTypes.
     */
    public void testGetDOMType() {
        ODOMXPath xPath = new ODOMXPath("/one/two/three");
        assertSame("Expected an ELEMENT_TYPE", DOMType.ELEMENT_TYPE,
                xPath.getDOMType());
        xPath = new ODOMXPath("/one/two/three@attribute");
        assertSame("Expected an ATTRIBUTE_TYPE", DOMType.ATTRIBUTE_TYPE,
                xPath.getDOMType());
        xPath = new ODOMXPath("/one/two/text()hello");
        assertSame("Expected a TEXT_TYPE", DOMType.TEXT_TYPE,
                xPath.getDOMType());
    }
View Full Code Here

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

            Namespace.getNamespace("second", "http://second/uri")
        };
        Map emptyMap = new HashMap();
        Map mapOne = new HashMap();
        Map mapMultiple = new HashMap();
        ODOMXPath encodedNamespaces;
        ODOMXPath encodedNamespacesNull;
        ODOMXPath encodedNamespacesOne;
        ODOMXPath encodedNamespacesMultiple;
        int i;

        for (i = 0; i < namespacesOne.length; i++) {
            mapOne.put(namespacesOne[i].getPrefix(),
                       namespacesOne[i].getURI());
        }

        for (i = 0; i < namespacesMultiple.length; i++) {
            mapMultiple.put(namespacesMultiple[i].getPrefix(),
                            namespacesMultiple[i].getURI());
        }

        // These constructors have been tested in another test
        encodedNamespaces = new ODOMXPath(path);
        encodedNamespacesNull = new ODOMXPath(path, namespacesNull);
        encodedNamespacesOne = new ODOMXPath(path, namespacesOne);
        encodedNamespacesMultiple = new ODOMXPath(path, namespacesMultiple);

        verifyObjectState(new ODOMXPath(path, (String) null),
                          path, emptyMap);
        verifyObjectState(
                new ODOMXPath(path, encodedNamespaces.getNamespacesString()),
                path, emptyMap);
        verifyObjectState(
                new ODOMXPath(path, encodedNamespacesNull.getNamespacesString()),
                path, emptyMap);
        verifyObjectState(
                new ODOMXPath(path, encodedNamespacesOne.getNamespacesString()),
                path, mapOne);
        verifyObjectState(new ODOMXPath(path,
                                    encodedNamespacesMultiple.getNamespacesString()),
                          path, mapMultiple);
    }
View Full Code Here

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

    /**
     * Test constructors.
     */
    public void testConstructorsThatShouldAnException() throws Exception {
        try {
            new ODOMXPath((String) null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath("");
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath("", (Namespace[]) null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((ODOMXPath) null, "");
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((ODOMXPath) null, "/relativePath");
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath("", (String) null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(null, "/relativePath", null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(odomObservable);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(odomObservable, null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(null, odomObservable, null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        new ODOMXPath((ODOMXPath) null, (ODOMXPath) null);
        try {
            new ODOMXPath(null, new ODOMXPath("/"));
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        // Test null relative ODOMXPath doesn't recurively call the same constructor.
        new ODOMXPath((ODOMXPath) null, (ODOMXPath) null);

        try {
            new ODOMXPath((Attribute) null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((Attribute) null, null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((ODOMXPath) null, new Attribute("", ""));
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }
        try {
            new ODOMXPath((ODOMXPath) null, new Attribute("", ""), null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((Element) null, (Attribute) null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(new Attribute("", ""));
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(new Attribute("", ""), null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }
        try {
            new ODOMXPath((Element) null, new Attribute("", ""), null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((Text) null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath((Text) null, null);
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(new Text(""));
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

    }
View Full Code Here

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

                                   "http://www.w3.org/2001/XMLSchema1"),
            Namespace.getNamespace("test2",
                                   "http://www.w3.org/2001/XMLSchema2"),
        };
        // Test that the xpath created contains just the namespaces.
        ODOMXPath xpath = new ODOMXPath("/path", NAMESPACES);
        Map namespaceMap = new HashMap();
        for (int i = 0; i < NAMESPACES.length; i++) {
            namespaceMap.put(NAMESPACES[i].getPrefix(),
                             NAMESPACES[i].getURI());
        }
        assertEquals("Namespace should match: ", namespaceMap,
                     getNamespacePrivateField(xpath));

        // Test the combination of namespaces maps...
        ODOMXPath xpathCombined = new ODOMXPath(xpath, (String) null, namespaces);
        for (int i = 0; i < namespaces.length; i++) {
            namespaceMap.put(namespaces[i].getPrefix(), namespaces[i]);
        }
        assertEquals("Namespace should match: ", namespaceMap.size(),
                     ((Map) getNamespacePrivateField(xpathCombined)).size());
View Full Code Here

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

    /**
     * Test the creation of a relative xpath with an observable element.
     */
    public void testCreateXPath() throws Exception {
        ODOMXPath xpath = new ODOMXPath("/");
        verifyResult("/", xpath.getExternalForm());
    }
View Full Code Here

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

    /**
     * Test the creation of a relative xpath with the root element.
     */
    public void testCreateXPathWithRoot() throws Exception {
        ODOMXPath xpath = new ODOMXPath(root);
        verifyResult("/catalog", xpath.getExternalForm());
    }
View Full Code Here

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

    /**
     * Test the creation of a relative xpath with the root element.
     */
    public void testCreateXPathWithRootRoot() throws Exception {
        ODOMXPath xpath = new ODOMXPath(root, root);
        verifyResult(".", xpath.getExternalForm());
    }
View Full Code Here

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

    /**
     * Overloaded helper method.
     */
    protected void doTest(Element start, Attribute end, String expected) {
        ODOMXPath xpath = new ODOMXPath(start, end);
        verifyResult(expected, xpath.getExternalForm());
    }
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.