Examples of ConfigurationNode


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

     * CONFIGURATION-294.
     */
    @Test
    public void testAddNodesAndSave() throws ConfigurationException
    {
        ConfigurationNode node = new HierarchicalConfiguration.Node("test");
        ConfigurationNode child = new HierarchicalConfiguration.Node("child");
        node.addChild(child);
        ConfigurationNode attr = new HierarchicalConfiguration.Node("attr");
        node.addAttribute(attr);
        ConfigurationNode node2 = conf.createNode("test2");
        Collection<ConfigurationNode> nodes = new ArrayList<ConfigurationNode>(2);
        nodes.add(node);
        nodes.add(node2);
        conf.addNodes("add.nodes", nodes);
        conf.setFile(testSaveConf);
View Full Code Here

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

        conf.addProperty("testAddNodes.property(1).value", "value2");
        Collection<ConfigurationNode> nodes = new ArrayList<ConfigurationNode>();
        nodes.add(new HierarchicalConfiguration.Node("property"));
        conf.addNodes("testAddNodes", nodes);
        nodes.clear();
        ConfigurationNode nd = new HierarchicalConfiguration.Node("name",
                "prop3");
        nd.setAttribute(true);
        nodes.add(nd);
        conf.addNodes("testAddNodes.property(2)", nodes);
        assertEquals("Attribute not added", "prop3", conf
                .getString("testAddNodes.property(2)[@name]"));
    }
View Full Code Here

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

    public void testAddNodesToSubnodeConfiguration()
            throws ConfigurationException
    {
        SubnodeConfiguration sub = conf.configurationAt("element2");
        sub.addProperty("newKey", "newvalue");
        ConfigurationNode root = conf.getRootNode();
        ConfigurationNode elem = root.getChildren("element2").get(0);
        ConfigurationNode newNode = elem.getChildren("newKey").get(0);
        assertTrue("Wrong node type: " + newNode,
                newNode instanceof XMLConfiguration.XMLNode);
    }
View Full Code Here

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

        List list = config.configurationsAt("colors/*");
        Iterator iter = list.iterator();
        while (iter.hasNext())
        {
            SubnodeConfiguration sub = (SubnodeConfiguration)iter.next();
            ConfigurationNode node = sub.getRootNode();
            String value = (node.getValue() == null) ? "null" : node.getValue().toString();
            if (map.containsKey(node.getName()))
            {
                assertEquals(map.get(node.getName()), value);
            }
        }

    }
View Full Code Here

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

        List<HierarchicalConfiguration> list = config.configurationsAt("colors/*");
        Iterator<HierarchicalConfiguration> iter = list.iterator();
        while (iter.hasNext())
        {
            SubnodeConfiguration sub = (SubnodeConfiguration)iter.next();
            ConfigurationNode node = sub.getRootNode();
            String value = (node.getValue() == null) ? "null" : node.getValue().toString();
            if (map.containsKey(node.getName()))
            {
                assertEquals(map.get(node.getName()), value);
            }
        }

    }
View Full Code Here

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

    public void testInitCopy() throws ConfigurationException
    {
        XMLConfiguration copy = new XMLConfiguration(conf);
        assertEquals("value", copy.getProperty("element"));
        assertNull("Document was copied, too", copy.getDocument());
        ConfigurationNode root = copy.getRootNode();
        for(Iterator it = root.getChildren().iterator(); it.hasNext();)
        {
            ConfigurationNode node = (ConfigurationNode) it.next();
            assertNull("Reference was not cleared", node.getReference());
        }

        removeTestFile();
        copy.setFile(testSaveConf);
        copy.save();
View Full Code Here

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

     * Tests saving a configuration after a node was added. Test for
     * CONFIGURATION-294.
     */
    public void testAddNodesAndSave() throws ConfigurationException
    {
        ConfigurationNode node = new HierarchicalConfiguration.Node("test");
        ConfigurationNode child = new HierarchicalConfiguration.Node("child");
        node.addChild(child);
        ConfigurationNode attr = new HierarchicalConfiguration.Node("attr");
        node.addAttribute(attr);
        ConfigurationNode node2 = conf.createNode("test2");
        Collection nodes = new ArrayList(2);
        nodes.add(node);
        nodes.add(node2);
        conf.addNodes("add.nodes", nodes);
        conf.setFile(testSaveConf);
View Full Code Here

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

        conf.addProperty("testAddNodes.property(1).value", "value2");
        Collection nodes = new ArrayList();
        nodes.add(new HierarchicalConfiguration.Node("property"));
        conf.addNodes("testAddNodes", nodes);
        nodes.clear();
        ConfigurationNode nd = new HierarchicalConfiguration.Node("name",
                "prop3");
        nd.setAttribute(true);
        nodes.add(nd);
        conf.addNodes("testAddNodes.property(2)", nodes);
        assertEquals("Attribute not added", "prop3", conf
                .getString("testAddNodes.property(2)[@name]"));
    }
View Full Code Here

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

     * Tests adding an attribute node with the addNodes() method.
     */
    public void testAddNodesAttributeNode()
    {
        Collection nodes = new ArrayList();
        ConfigurationNode nd = createNode("length", "10");
        nd.setAttribute(true);
        nodes.add(nd);
        config.addNodes("tables.table(0).fields.field(1)", nodes);
        assertEquals("Attribute was not added", "10", config
                .getString("tables.table(0).fields.field(1)[@length]"));
    }
View Full Code Here

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

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