Examples of ImmutableNode


Examples of org.apache.commons.configuration2.tree.ImmutableNode

    public void testAddNodesAndSave() throws ConfigurationException
    {
        ImmutableNode.Builder bldrNode = new ImmutableNode.Builder(1);
        bldrNode.addChild(NodeStructureHelper.createNode("child", null));
        bldrNode.addAttribute("attr", "");
        ImmutableNode node2 = NodeStructureHelper.createNode("test2", null);
        conf.addNodes("add.nodes",
                Arrays.asList(bldrNode.name("test").create(), node2));
        saveTestConfig();
        conf.setProperty("add.nodes.test", "true");
        conf.setProperty("add.nodes.test.child", "yes");
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     */
    @Test
    public void testCanonicalKeyNoDuplicates()
    {
        ImmutableNode.Builder parentBuilder = new ImmutableNode.Builder(2);
        ImmutableNode c1 = new ImmutableNode.Builder().name("child").create();
        ImmutableNode c2 =
                new ImmutableNode.Builder().name("child_other").create();
        parentBuilder.addChildren(Arrays.asList(c2, c1));
        ImmutableNode parent = parentBuilder.create();
        NodeHandler<ImmutableNode> testHandler =
                new InMemoryNodeModel(parent).getNodeHandler();
        XPathExpressionEngine engine = new XPathExpressionEngine();
        assertEquals("Wrong canonical key", "parent/child[1]",
                engine.canonicalKey(c1, "parent", testHandler));
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     */
    @Test
    public void testCanonicalKeyWithDuplicates()
    {
        ImmutableNode.Builder parentBuilder = new ImmutableNode.Builder(3);
        ImmutableNode c1 = new ImmutableNode.Builder().name("child").create();
        ImmutableNode c2 = new ImmutableNode.Builder().name("child").create();
        ImmutableNode c3 =
                new ImmutableNode.Builder().name("child_other").create();
        parentBuilder.addChildren(Arrays.asList(c1, c2, c3));
        ImmutableNode parent = parentBuilder.create();
        NodeHandler<ImmutableNode> testHandler =
                new InMemoryNodeModel(parent).getNodeHandler();
        XPathExpressionEngine engine = new XPathExpressionEngine();
        assertEquals("Wrong key 1", "parent/child[1]",
                engine.canonicalKey(c1, "parent", testHandler));
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     */
    @Test
    public void testCanonicalKeyNoParentKey()
    {
        ImmutableNode.Builder parentBuilder = new ImmutableNode.Builder(1);
        ImmutableNode c1 = new ImmutableNode.Builder().name("child").create();
        ImmutableNode parent = parentBuilder.addChild(c1).create();
        NodeHandler<ImmutableNode> testHandler =
                new InMemoryNodeModel(parent).getNodeHandler();
        XPathExpressionEngine engine = new XPathExpressionEngine();
        assertEquals("Wrong key", "child[1]",
                engine.canonicalKey(c1, null, testHandler));
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

        List<NodePointer> nodes = iterationElements(it);
        assertEquals("Wrong size of iteration", CHILD_COUNT - 3, nodes.size());
        int index = 4;
        for (NodePointer np : nodes)
        {
            ImmutableNode node = (ImmutableNode) np.getImmediateNode();
            assertEquals("Wrong node value", String.valueOf(index),
                    node.getValue());
            index++;
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

                new ConfigurationNodeIteratorChildren<ImmutableNode>(
                        rootPointer, null, true, childPointer);
        int value = 3;
        for (int index = 1; it.setPosition(index); index++, value--)
        {
            ImmutableNode node = (ImmutableNode) it.getNodePointer().getNode();
            assertEquals("Incorrect value at index " + index,
                    String.valueOf(value), node.getValue());
        }
        assertEquals("Iteration ended not at end node", 0, value);
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

        ConfigurationNodeIteratorChildren<ImmutableNode> it =
                new ConfigurationNodeIteratorChildren<ImmutableNode>(
                        rootPointer, null, false, childPointer);
        assertEquals("Wrong size of iteration", CHILD_COUNT, iteratorSize(it));
        it.setPosition(1);
        ImmutableNode node = (ImmutableNode) it.getNodePointer().getNode();
        assertEquals("Wrong start node", "1", node.getValue());
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     *
     * @return the node pointer
     */
    private ConfigurationNodePointer<ImmutableNode> createPointerWithNamespace()
    {
        ImmutableNode node =
                new ImmutableNode.Builder(2)
                        .addChild(root)
                        .addChild(
                                NodeStructureHelper.createNode(PREFIX + ':'
                                        + PREFIX_NODE, "test")
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

    private void checkValues(NodeIterator iterator, int... expectedIndices)
    {
        List<NodePointer> nodes = iterationElements(iterator);
        for (int i = 0; i < expectedIndices.length; i++)
        {
            ImmutableNode child = (ImmutableNode) nodes.get(i).getImmediateNode();
            assertTrue("Wrong index value for child " + i, child.getValue()
                    .toString().endsWith(String.valueOf(expectedIndices[i])));
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     * Tests whether a correct context is created.
     */
    @Test
    public void testCreateContext()
    {
        ImmutableNode node =
                new ImmutableNode.Builder().name("testRoot").create();
        NodeHandler<ImmutableNode> handler =
                new InMemoryNodeModel(node).getNodeHandler();
        JXPathContext context = factory.createContext(node, handler);

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.