Examples of DefaultConfigurationNode


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

        assertTrue(config.isEmpty());
    }

    public void testSetRootNode()
    {
        config.setRootNode(new DefaultConfigurationNode("testNode"));
        assertNotSame("Same root node", config.getRootNode(), config.getRoot());
        assertEquals("Wrong name of root node", "testNode", config.getRoot().getName());

        config.setRootNode(new HierarchicalConfiguration.Node("test"));
        assertSame("Wrong root node", config.getRootNode(), config.getRoot());
View Full Code Here

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

     * Tests the parents of nodes when setRootNode() is involved. This is
     * related to CONFIGURATION-334.
     */
    public void testNodeParentsAfterSetRootNode()
    {
        DefaultConfigurationNode root = new DefaultConfigurationNode();
        DefaultConfigurationNode child1 = new DefaultConfigurationNode(
                "child1", "test1");
        root.addChild(child1);
        config.setRootNode(root);
        config.addProperty("child2", "test2");
        List nodes = config.getExpressionEngine().query(config.getRootNode(),
                "child2");
        assertEquals("Wrong number of result nodes", 1, nodes.size());
        ConfigurationNode child2 = (ConfigurationNode) nodes.get(0);
        assertEquals("Different parent nodes", child1.getParentNode(), child2
                .getParentNode());
    }
View Full Code Here

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

     * further child nodes have been added. The newly add child nodes should be
     * present in the root node returned.
     */
    public void testGetRootAfterSetRootNode()
    {
        DefaultConfigurationNode root = new DefaultConfigurationNode();
        DefaultConfigurationNode child1 = new DefaultConfigurationNode(
                "child1", "test1");
        root.addChild(child1);
        config.setRootNode(root);
        config.addProperty("child2", "test2");
        ConfigurationNode oldRoot = config.getRoot();
View Full Code Here

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

    @Test
    public void testConfigurationDeclarationIsReserved()
    {
        DefaultConfigurationBuilder.ConfigurationDeclaration decl = new DefaultConfigurationBuilder.ConfigurationDeclaration(
                factory, factory);
        DefaultConfigurationNode parent = new DefaultConfigurationNode();
        DefaultConfigurationNode nd = new DefaultConfigurationNode("at");
        parent.addAttribute(nd);
        assertTrue("Attribute at not recognized", decl.isReservedNode(nd));
        nd = new DefaultConfigurationNode("optional");
        parent.addAttribute(nd);
        assertTrue("Attribute optional not recognized", decl.isReservedNode(nd));
        nd = new DefaultConfigurationNode("config-class");
        parent.addAttribute(nd);
        assertTrue("Inherited attribute not recognized", decl
                .isReservedNode(nd));
        nd = new DefaultConfigurationNode("different");
        parent.addAttribute(nd);
        assertFalse("Wrong reserved attribute", decl.isReservedNode(nd));
        nd = new DefaultConfigurationNode("at");
        parent.addChild(nd);
        assertFalse("Node type not evaluated", decl.isReservedNode(nd));
    }
View Full Code Here

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

     */
    private void checkOldReservedAttribute(String name)
    {
        DefaultConfigurationBuilder.ConfigurationDeclaration decl = new DefaultConfigurationBuilder.ConfigurationDeclaration(
                factory, factory);
        DefaultConfigurationNode parent = new DefaultConfigurationNode();
        DefaultConfigurationNode nd = new DefaultConfigurationNode("config-"
                + name);
        parent.addAttribute(nd);
        assertTrue("config-" + name + " attribute not recognized", decl
                .isReservedNode(nd));
        DefaultConfigurationNode nd2 = new DefaultConfigurationNode(name);
        parent.addAttribute(nd2);
        assertFalse(name + " is reserved though config- exists", decl
                .isReservedNode(nd2));
        assertTrue("config- attribute not recognized when " + name + " exists",
                decl.isReservedNode(nd));
View Full Code Here

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

     */
    public void testConfigurationDeclarationIsReserved()
    {
        DefaultConfigurationBuilder.ConfigurationDeclaration decl = new DefaultConfigurationBuilder.ConfigurationDeclaration(
                factory, factory);
        DefaultConfigurationNode parent = new DefaultConfigurationNode();
        DefaultConfigurationNode nd = new DefaultConfigurationNode("at");
        parent.addAttribute(nd);
        assertTrue("Attribute at not recognized", decl.isReservedNode(nd));
        nd = new DefaultConfigurationNode("optional");
        parent.addAttribute(nd);
        assertTrue("Attribute optional not recognized", decl.isReservedNode(nd));
        nd = new DefaultConfigurationNode("config-class");
        parent.addAttribute(nd);
        assertTrue("Inherited attribute not recognized", decl
                .isReservedNode(nd));
        nd = new DefaultConfigurationNode("different");
        parent.addAttribute(nd);
        assertFalse("Wrong reserved attribute", decl.isReservedNode(nd));
        nd = new DefaultConfigurationNode("at");
        parent.addChild(nd);
        assertFalse("Node type not evaluated", decl.isReservedNode(nd));
    }
View Full Code Here

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

     */
    private void checkOldReservedAttribute(String name)
    {
        DefaultConfigurationBuilder.ConfigurationDeclaration decl = new DefaultConfigurationBuilder.ConfigurationDeclaration(
                factory, factory);
        DefaultConfigurationNode parent = new DefaultConfigurationNode();
        DefaultConfigurationNode nd = new DefaultConfigurationNode("config-"
                + name);
        parent.addAttribute(nd);
        assertTrue("config-" + name + " attribute not recognized", decl
                .isReservedNode(nd));
        DefaultConfigurationNode nd2 = new DefaultConfigurationNode(name);
        parent.addAttribute(nd2);
        assertFalse(name + " is reserved though config- exists", decl
                .isReservedNode(nd2));
        assertTrue("config- attribute not recognized when " + name + " exists",
                decl.isReservedNode(nd));
View Full Code Here

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

        assertTrue(config.isEmpty());
    }

    public void testSetRootNode()
    {
        config.setRootNode(new DefaultConfigurationNode("testNode"));
        assertNotSame("Same root node", config.getRootNode(), config.getRoot());
        assertEquals("Wrong name of root node", "testNode", config.getRoot().getName());

        config.setRootNode(new HierarchicalConfiguration.Node("test"));
        assertSame("Wrong root node", config.getRootNode(), config.getRoot());
View Full Code Here

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

    /**
     * Tests accessing attributes.
     */
    public void testAttributes()
    {
        root.addAttribute(new DefaultConfigurationNode("testAttr", "true"));
        assertEquals("Did not find attribute of root node", "true", context
                .getValue("@testAttr"));
        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.DefaultConfigurationNode

    {
        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
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.