Examples of ConfigurationNode


Examples of org.apache.commons.configuration.tree.ConfigurationNode

        DefaultConfigurationNode child1 = new DefaultConfigurationNode(
                "child1", "test1");
        root.addChild(child1);
        config.setRootNode(root);
        config.addProperty("child2", "test2");
        ConfigurationNode oldRoot = config.getRoot();
        assertEquals("Wrong number of children", 2, oldRoot.getChildrenCount());
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

     * @param conf the parent config
     * @return the root node for the subnode config
     */
    protected ConfigurationNode getSubnodeRoot(HierarchicalConfiguration conf)
    {
        ConfigurationNode root = conf.getRoot();
        return root.getChild(0).getChild(0);
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

    {
        List nodes = context.selectNodes(CHILD_NAME1);
        assertEquals("Incorrect number of results", 2, nodes.size());
        for (Iterator it = nodes.iterator(); it.hasNext();)
        {
            ConfigurationNode node = (ConfigurationNode) it.next();
            assertEquals("Incorrect node name", CHILD_NAME1, node.getName());
            assertEquals("Incorrect parent node", root, node.getParentNode());
        }

        nodes = context.selectNodes("/" + CHILD_NAME1);
        assertEquals("Incorrect number of results", 2, nodes.size());
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

        List nodes = context.selectNodes("/" + CHILD_NAME1 + "[1]/*");
        assertEquals("Wrong number of children", CHILD_COUNT, nodes.size());
        int index = 1;
        for (Iterator it = nodes.iterator(); it.hasNext(); index++)
        {
            ConfigurationNode node = (ConfigurationNode) it.next();
            assertEquals("Wrong node value for child " + index, "2." + index,
                    node.getValue());
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

        assertEquals("Incorrect attribute value", "1", context.getValue("/"
                + CHILD_NAME2 + "[1]/@" + ATTR_NAME));

        assertTrue("Found elements with name attribute", context.selectNodes(
                "//" + CHILD_NAME2 + "[@name]").isEmpty());
        ConfigurationNode node = (ConfigurationNode) root.getChild(2).getChild(
                1).getChildren(CHILD_NAME2).get(1);
        node.addAttribute(new DefaultConfigurationNode("name", "testValue"));
        List nodes = context.selectNodes("//" + CHILD_NAME2 + "[@name]");
        assertEquals("Name attribute not found", 1, nodes.size());
        assertEquals("Wrong node returned", node, nodes.get(0));
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

    public void testFollowingSiblingAxis()
    {
        List nodes = context.selectNodes("/" + CHILD_NAME1
                + "[2]/following-sibling::*");
        assertEquals("Wrong number of following siblings", 1, nodes.size());
        ConfigurationNode node = (ConfigurationNode) nodes.get(0);
        assertEquals("Wrong node type", CHILD_NAME2, node.getName());
        assertEquals("Wrong index", String.valueOf(CHILD_COUNT), node
                .getValue());
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

    protected void setUp() throws Exception
    {
        super.setUp();
       
        // Adds further attributes to the test node
        ConfigurationNode testNode = root.getChild(1);
        testNode.addAttribute(new DefaultConfigurationNode(TEST_ATTR, "yes"));
        pointer = new ConfigurationNodePointer(testNode, Locale.getDefault());
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

     * Tests comparing child node pointers for child nodes that do not belong to
     * the parent node.
     */
    public void testCompareChildNodePointersInvalidChildren()
    {
        ConfigurationNode node = root.getChild(1);
        NodePointer p1 = new ConfigurationNodePointer(pointer, node.getChild(1));
        NodePointer p2 = new ConfigurationNodePointer(pointer, node.getChild(3));
        assertEquals("Non child nodes could be sorted", 0, pointer
                .compareChildNodePointers(p1, p2));
        assertEquals("Non child nodes could be sorted symmetrically", 0,
                pointer.compareChildNodePointers(p2, p1));
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

    /**
     * Tests the attribute flag.
     */
    public void testIsAttribute()
    {
        ConfigurationNode node = new DefaultConfigurationNode("test", "testval");
        NodePointer p = new ConfigurationNodePointer(pointer, node);
        assertFalse("Node is an attribute", p.isAttribute());
        node.setAttribute(true);
        assertTrue("Node is no attribute", p.isAttribute());
    }
View Full Code Here

Examples of org.apache.commons.configuration.tree.ConfigurationNode

        assertFalse("Root node is leaf", pointer.isLeaf());

        NodePointer p = pointer;
        while (!p.isLeaf())
        {
            ConfigurationNode node = (ConfigurationNode) p.getNode();
            assertTrue("Node has no children", node.getChildrenCount() > 0);
            p = new ConfigurationNodePointer(p, node.getChild(0));
        }
        assertTrue("Node has children", ((ConfigurationNode) p.getNode())
                .getChildrenCount() == 0);
    }
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.