Package org.apache.commons.configuration.tree

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


    /**
     * Tests comparing child node pointers for attribute nodes.
     */
    public void testCompareChildNodePointersAttributes()
    {
        root.addAttribute(new DefaultConfigurationNode("attr1", "test1"));
        root.addAttribute(new DefaultConfigurationNode("attr2", "test2"));
        NodePointer p1 = new ConfigurationNodePointer(pointer, root
                .getAttribute(0));
        NodePointer p2 = new ConfigurationNodePointer(pointer, root
                .getAttribute(1));
        assertEquals("Incorrect order", -1, pointer.compareChildNodePointers(
View Full Code Here


    /**
     * tests comparing child node pointers for both child and attribute nodes.
     */
    public void testCompareChildNodePointersChildAndAttribute()
    {
        root.addAttribute(new DefaultConfigurationNode("attr1", "test1"));
        NodePointer p1 = new ConfigurationNodePointer(pointer, root.getChild(2));
        NodePointer p2 = new ConfigurationNodePointer(pointer, root
                .getAttribute(0));
        assertEquals("Incorrect order for attributes", 1, pointer
                .compareChildNodePointers(p1, p2));
View Full Code Here

    /**
     * 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

     * Tests a normal call of nodeKey().
     */
    public void testNodeKeyNormal()
    {
        assertEquals("Wrong node key", "parent/child", engine.nodeKey(
                new DefaultConfigurationNode("child"), "parent"));
    }
View Full Code Here

    /**
     * Tests nodeKey() for an attribute node.
     */
    public void testNodeKeyAttribute()
    {
        ConfigurationNode node = new DefaultConfigurationNode("attr");
        node.setAttribute(true);
        assertEquals("Wrong attribute key", "node@attr", engine.nodeKey(node,
                "node"));
    }
View Full Code Here

     */
    public void testNodeKeyForRootNode()
    {
        assertEquals("Wrong key for root node", "", engine.nodeKey(ROOT, null));
        assertEquals("Null name not detected", "test", engine.nodeKey(
                new DefaultConfigurationNode(), "test"));
    }
View Full Code Here

    /**
     * Tests node key() for direct children of the root node.
     */
    public void testNodeKeyForRootChild()
    {
        ConfigurationNode node = new DefaultConfigurationNode("child");
        assertEquals("Wrong key for root child node", "child", engine.nodeKey(
                node, ""));
        node.setAttribute(true);
        assertEquals("Wrong key for root attribute", "@child", engine.nodeKey(
                node, ""));
    }
View Full Code Here

     * @param levels the number of levels in the hierarchy
     * @return the root node of the hierarchy
     */
    protected ConfigurationNode constructHierarchy(int levels)
    {
        ConfigurationNode result = new DefaultConfigurationNode();
        createLevel(result, levels);
        return result;
    }
View Full Code Here

            String prefix = (parent.getValue() == null) ? "" : parent
                    .getValue()
                    + ".";
            for (int i = 1; i <= CHILD_COUNT; i++)
            {
                ConfigurationNode child = new DefaultConfigurationNode(
                        (i % 2 == 0) ? CHILD_NAME1 : CHILD_NAME2, prefix + i);
                parent.addChild(child);
                child.addAttribute(new DefaultConfigurationNode(ATTR_NAME,
                        String.valueOf(i)));

                createLevel(child, level - 1);
            }
        }
View Full Code Here

     * iteration to start at the first position.
     */
    public void testIterateStartsWithInvalid()
    {
        NodePointer childPointer = new ConfigurationNodePointer(rootPointer,
                new DefaultConfigurationNode("newNode"));
        ConfigurationNodeIteratorChildren it = new ConfigurationNodeIteratorChildren(
                rootPointer, null, false, childPointer);
        assertEquals("Wrong size of iteration", CHILD_COUNT, iteratorSize(it));
        it.setPosition(1);
        ConfigurationNode node = (ConfigurationNode) it.getNodePointer()
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.tree.DefaultConfigurationNode

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.