Package org.apache.commons.jxpath

Examples of org.apache.commons.jxpath.JXPathContext


    @Test
    public void testQueryAttributeExpression()
    {
        QueryResult<ImmutableNode> attrResult =
                QueryResult.createAttributeResult(root, "attr");
        JXPathContext ctx = expectSelect(attrResult);
        XPathExpressionEngine engine = setUpEngine(ctx);
        List<QueryResult<ImmutableNode>> result =
                engine.query(root, TEST_KEY, handler);
        assertEquals("Incorrect number of results", 1, result.size());
        assertSame("Wrong result", attrResult, result.get(0));
View Full Code Here


     * Tests a query that has no results. This should return an empty list.
     */
    @Test
    public void testQueryWithoutResult()
    {
        JXPathContext ctx = expectSelect();
        XPathExpressionEngine engine = setUpEngine(ctx);
        assertTrue("Got results", engine.query(root, TEST_KEY, handler)
                .isEmpty());
    }
View Full Code Here

     * Tests adding a single child node.
     */
    @Test
    public void testPrepareAddNode()
    {
        JXPathContext ctx = expectSelect(root);
        XPathExpressionEngine engine = setUpEngine(ctx);
        NodeAddData<ImmutableNode> data =
                engine.prepareAdd(root, TEST_KEY + "  newNode", handler);
        checkAddPath(data, false, "newNode");
    }
View Full Code Here

     * Tests adding a new attribute node.
     */
    @Test
    public void testPrepareAddAttribute()
    {
        JXPathContext ctx = expectSelect(root);
        XPathExpressionEngine engine = setUpEngine(ctx);
        NodeAddData<ImmutableNode> data =
                engine.prepareAdd(root, TEST_KEY + "\t@newAttr", handler);
        checkAddPath(data, true, "newAttr");
    }
View Full Code Here

     * Tests adding a complete path.
     */
    @Test
    public void testPrepareAddPath()
    {
        JXPathContext ctx = expectSelect(root);
        XPathExpressionEngine engine = setUpEngine(ctx);
        NodeAddData<ImmutableNode> data =
                engine.prepareAdd(root, TEST_KEY + " \t a/full/path/node",
                        handler);
        checkAddPath(data, false, "a", "full", "path", "node");
View Full Code Here

     * Tests adding a complete path whose final node is an attribute.
     */
    @Test
    public void testPrepareAddAttributePath()
    {
        JXPathContext ctx = expectSelect(root);
        XPathExpressionEngine engine = setUpEngine(ctx);
        NodeAddData<ImmutableNode> data =
                engine.prepareAdd(root, TEST_KEY + " a/full/path@attr", handler);
        checkAddPath(data, true, "a", "full", "path", "attr");
    }
View Full Code Here

     * Tests adding a new node to the root.
     */
    @Test
    public void testPrepareAddRootChild()
    {
        JXPathContext ctx = expectSelect(root);
        XPathExpressionEngine engine = setUpEngine(ctx);
        NodeAddData<ImmutableNode> data =
                engine.prepareAdd(root, " newNode", handler);
        checkAddPath(data, false, "newNode");
    }
View Full Code Here

     * Tests adding a new attribute to the root.
     */
    @Test
    public void testPrepareAddRootAttribute()
    {
        JXPathContext ctx = expectSelect(root);
        XPathExpressionEngine engine = setUpEngine(ctx);
        NodeAddData<ImmutableNode> data =
                engine.prepareAdd(root, " @attr", handler);
        checkAddPath(data, true, "attr");
    }
View Full Code Here

     * Tests an add operation with a query that does not return a single node.
     */
    @Test(expected = IllegalArgumentException.class)
    public void testPrepareAddInvalidParent()
    {
        JXPathContext ctx = expectSelect();
        XPathExpressionEngine engine = setUpEngine(ctx);
        engine.prepareAdd(root, TEST_KEY + " test", handler);
    }
View Full Code Here

    {
        ImmutableNode node =
                new ImmutableNode.Builder().name("testRoot").create();
        NodeHandler<ImmutableNode> handler =
                new InMemoryNodeModel(node).getNodeHandler();
        JXPathContext context = factory.createContext(node, handler);

        assertTrue("No lenient mode", context.isLenient());
        ConfigurationNodePointerFactory.NodeWrapper<?> wrapper =
                (ConfigurationNodePointerFactory.NodeWrapper<?>) context
                        .getContextBean();
        assertSame("Wrong node", node, wrapper.getNode());
        assertSame("Wrong handler", handler, wrapper.getNodeHandler());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jxpath.JXPathContext

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.