Package com.volantis.mcs.xml.xpath

Examples of com.volantis.mcs.xml.xpath.XPath


            this.expectedErrorKey = expectedErrorKey;
        }

        // javadoc inherited
        public void reportError(ErrorDetails details) {
            XPath xPath = details.getXPath();
            String key = details.getKey();

            Assert.assertEquals("XPath not as",
                                new XPath(element).getExternalForm(),
                                xPath.getExternalForm());
            Assert.assertEquals("Error key not as",
                                expectedErrorKey,
                                key);
            reported = true;
        }
View Full Code Here


        resource = new MockFile(POLICY_FILE);


        // set up a number of paths for the test
        XPath root = new XPath("/");
        XPath aPath1 = new XPath("/aone");
        XPath aPath2 = new XPath("/aone/atwo");

        XPath bPath1 = new XPath("/bone");
        XPath bPath2 = new XPath("/bone/btwo");

        XPath bPath3 = new XPath("/bone/bthree");
        XPath cPath1 = new XPath("/cone");


        mger = new MarkerGeneratingErrorReporter(resource,
                new Element("aone"), null);

        // create PROBLEM markers from the paths
        IMarker marker1 = resource.createMarker(IMarker.PROBLEM);
        marker1.setAttribute(XPath.class.getName(), aPath2.getExternalForm());
        marker1.setAttribute(NAMESPACES_ATTRIBUTE, ":aPath2Test");

        IMarker marker2 = resource.createMarker(IMarker.PROBLEM);
        marker2.setAttribute(XPath.class.getName(), aPath1.getExternalForm());
        marker2.setAttribute(NAMESPACES_ATTRIBUTE, ":aPath1Test");

        IMarker marker3 = resource.createMarker(IMarker.PROBLEM);
        marker3.setAttribute(XPath.class.getName(), bPath2.getExternalForm());
        marker3.setAttribute(NAMESPACES_ATTRIBUTE, ":bPath2Test");

        // create some MESSAGE markers
        IMarker marker4 = resource.createMarker(IMarker.MESSAGE);
        marker4.setAttribute(XPath.class.getName(), bPath1.getExternalForm());
        marker4.setAttribute(NAMESPACES_ATTRIBUTE, ":bPath2Test");

        IMarker marker5= resource.createMarker(IMarker.MESSAGE);
        marker5.setAttribute(XPath.class.getName(), bPath3.getExternalForm());
        marker5.setAttribute(NAMESPACES_ATTRIBUTE, ":cPath1Test");


        IMarker markerc = resource.createMarker(IMarker.MESSAGE);
        markerc.setAttribute(XPath.class.getName(), cPath1.getExternalForm());
        markerc.setAttribute(NAMESPACES_ATTRIBUTE, ":cPathTest");

        // test to ensure that XPath is NOT returned for the correct path string but incorrect namespace
        Assert.assertEquals("try to obtain xPath using correct namespace",
                bPath2.getExternalForm(),
View Full Code Here

            ODOMElement context,
            String xpathStr)
            throws Exception {

        // Update is expected to work on exactly one entity
        final XPath xpath = new XPath(xpathStr);
        final List finds = xpath.selectNodes(context);
        if (finds == null) {
            throw new IllegalStateException(
                    "Found null: " + xpath.getExternalForm());
        }
        if (finds.size() != 1) {
            throw new IllegalStateException(
                    "Found " + finds.size() + " in " + xpath.getExternalForm());
        }
        final ODOMObservable found = (ODOMObservable)finds.get(0);
        Utils.print("\nFind OK: " + xpath.getExternalForm());
        return found;
    }
View Full Code Here

        private boolean completed;
        private List errors = new ArrayList();

        // javadoc iherited
        public void reportError(ErrorDetails details) {
            XPath xpath = details.getXPath();
            String key = details.getKey();

            assertEquals("Key should match", FaultTypes.DUPLICATE_NAME, key);
            errors.add(xpath.getExternalForm());
        }
View Full Code Here

     * @return the required element
     */
    protected ODOMElement buildLPDMODOM(String xml,
                                        String requiredElementXPath)
        throws Exception {
        XPath xpath = new XPath(requiredElementXPath,
                                new Namespace[] {MCSNamespace.LPDM});
        SAXBuilder builder = new SAXBuilder();

        // Make sure we create the DOM with default LPDM namespace
        builder.setFactory(new LPDMODOMFactory());

        return (ODOMElement)xpath.selectSingleNode(
            builder.build(new StringReader(xml)).getRootElement());
    }
View Full Code Here

            }
        });

        manager.performOperation(new ODOMEditorContextOperation() {
            public void perform(ODOMEditorContext context) throws Exception {
                XPath root = new XPath("/");
                XPath aPath1 = new XPath("/aone");
                XPath aPath2 = new XPath("/aone/atwo");

                XPath bPath1 = new XPath("/bone");
                XPath bPath2 = new XPath("/bone/btwo");

                IMarker marker1 = resource.createMarker(IMarker.PROBLEM);
                marker1.setAttribute(XPath.class.getName(),
                        aPath2.getExternalForm());
                IMarker marker2 = resource.createMarker(IMarker.PROBLEM);
                marker2.setAttribute(XPath.class.getName(),
                        aPath1.getExternalForm());
                IMarker marker3 = resource.createMarker(IMarker.PROBLEM);
                marker3.setAttribute(XPath.class.getName(),
                        bPath2.getExternalForm());
                IMarker marker4 = resource.createMarker(IMarker.MESSAGE);
                marker4.setAttribute(XPath.class.getName(),
                        bPath1.getExternalForm());

                IMarker markers [];
View Full Code Here

        ODOMElement[] selection;

        if (xpaths == null) {
            selection = new ODOMElement[0];
        } else {
            XPath xpath;
            selection = new ODOMElement[xpaths.length];

            for (int i = 0; i < xpaths.length; i++) {
                xpath = new XPath(xpaths[i], namespaces);

                selection[i] = (ODOMElement)xpath.selectSingleElement(
                        data.getDocument());
            }
        }

        ((TestDataImpl)data).setSelection(selection);
View Full Code Here

        builder.setFactory(FormatPrototype.factory);

        Element root = builder.build(new StringReader(xml)).getRootElement();


         XPath gridXPath = new XPath("/action:layout/" +
                "action:canvasLayout[2]/" +
                "action:gridFormat", namespace);

         XPath paneXPath = new XPath("/action:layout/" +
                "action:canvasLayout[2]/" +
                "action:gridFormat/" +
                "action:gridFormatRow/" +
                "action:paneFormat", namespace);

        Element grid = gridXPath.selectSingleElement(root);
        Element pane = paneXPath.selectSingleElement(root);

        assertTrue("pane and grid do not have a common layout",
                ActionSupport.haveCommonLayout(grid, pane));

        XPath otherPaneXPath = new XPath("/action:layout/" +
                "action:canvasLayout[1]/" +
                "action:paneFormat", namespace);

        Element otherPane = otherPaneXPath.selectSingleElement(root);
        assertNotNull(otherPane);
        assertFalse("otherPane and pane do have a common layout",
                ActionSupport.haveCommonLayout(pane, otherPane));
    }
View Full Code Here

        builder.setFactory(FormatPrototype.factory);

        Element root = builder.build(new StringReader(xml)).getRootElement();


         XPath gridXPath = new XPath("/action:layout/" +
                "action:canvasLayout[2]/" +
                "action:gridFormat", namespace);

         XPath paneXPath = new XPath("/action:layout/" +
                "action:canvasLayout[2]/" +
                "action:gridFormat/" +
                "action:gridFormatRow/" +
                "action:paneFormat", namespace);

        Element grid = gridXPath.selectSingleElement(root);
        Element pane = paneXPath.selectSingleElement(root);

        assertTrue("pane is not a descendent of grid",
                ActionSupport.isDescendent(grid, pane));

        XPath otherPaneXPath = new XPath("/action:layout/" +
                "action:canvasLayout[1]/" +
                "action:paneFormat", namespace);

        Element otherPane = otherPaneXPath.selectSingleElement(root);
        assertNotNull(otherPane);
        assertFalse("otherPane is a descendent of grid",
                ActionSupport.isDescendent(grid, otherPane));
    }
View Full Code Here

                "                <paneFormat name='pane'/>" +
                "            </gridFormatRow>" +
                "        </gridFormat>" +
                "    </canvasLayout>" +
                "</layout>",
                new XPath("/action:layout/" +
                "action:canvasLayout[2]/" +
                "action:gridFormat/" +
                "action:gridFormatRow/" +
                "action:paneFormat",
                        namespace));
View Full Code Here

TOP

Related Classes of com.volantis.mcs.xml.xpath.XPath

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.