Package org.apache.commons.configuration2

Examples of org.apache.commons.configuration2.BaseHierarchicalConfiguration


     * Tests whether the returned configuration correctly wraps the builder.
     */
    @Test
    public void testConfigurationBuilderWrapper()
    {
        BaseHierarchicalConfiguration conf =
                new BaseHierarchicalConfiguration();
        ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
                createBuilderMock(conf);
        EasyMock.replay(builder);
        conf.addProperty("test1", "value1");
        conf.addProperty("test2", "42");
        BuilderConfigurationWrapperFactory factory =
                new BuilderConfigurationWrapperFactory();
        HierarchicalConfiguration<?> wrapper =
                factory.createBuilderConfigurationWrapper(
                        HierarchicalConfiguration.class, builder);
        assertEquals("Wrong value (1)", "value1", wrapper.getString("test1"));
        assertEquals("Wrong value (2)", 42, wrapper.getInt("test2"));
        assertSame("Wrong root node", conf.getNodeModel().getNodeHandler()
                .getRootNode(), wrapper.getNodeModel().getNodeHandler()
                .getRootNode());
    }
View Full Code Here


     * Tests the factory if support for EventSource is disabled.
     */
    @Test
    public void testEventSourceSupportNone()
    {
        BaseHierarchicalConfiguration conf =
                new BaseHierarchicalConfiguration();
        ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
                createBuilderMock(conf);
        EasyMock.replay(builder);
        BuilderConfigurationWrapperFactory factory =
                new BuilderConfigurationWrapperFactory();
View Full Code Here

     * Tests the EventSource support level 'dummy'.
     */
    @Test
    public void testEventSourceSupportDummy()
    {
        BaseHierarchicalConfiguration conf =
                new BaseHierarchicalConfiguration();
        ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
                createBuilderMock(conf);
        EasyMock.replay(builder);
        BuilderConfigurationWrapperFactory factory =
                new BuilderConfigurationWrapperFactory(EventSourceSupport.DUMMY);
View Full Code Here

     * mock builder.
     */
    @Test
    public void testEventSourceSupportMockBuilder()
    {
        BaseHierarchicalConfiguration conf =
                new BaseHierarchicalConfiguration();
        ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
                createBuilderMock(conf);
        EventListenerTestImpl listener = new EventListenerTestImpl(null);
        builder.addEventListener(ConfigurationEvent.ANY, listener);
        EasyMock.replay(builder);
View Full Code Here

    {
        BuilderConfigurationWrapperFactory factory =
                new BuilderConfigurationWrapperFactory(
                        EventSourceSupport.BUILDER);
        factory.createBuilderConfigurationWrapper(null,
                createBuilderMock(new BaseHierarchicalConfiguration()));
    }
View Full Code Here

                    @Override
                    protected BeanDeclaration createResultDeclaration(
                            Map<String, Object> params)
                    {
                        return new XMLBeanDeclaration(
                                new BaseHierarchicalConfiguration(), "bean",
                                true, Object.class.getName());
                    }
                };
        builder.getConfiguration();
    }
View Full Code Here

        ImmutableNode cn =
                combiner.combine(conf1.getNodeModel().getNodeHandler()
                        .getRootNode(), conf2.getNodeModel().getNodeHandler()
                        .getRootNode());

        BaseHierarchicalConfiguration result = new BaseHierarchicalConfiguration();
        result.getNodeModel().setRootNode(cn);

        return result;
    }
View Full Code Here

     * @param reload a flag whether reload operations are supported
     * @return the configuration object
     */
    private HierarchicalConfiguration<?> setUpConfig(boolean reload)
    {
        HierarchicalConfiguration<?> config = new BaseHierarchicalConfiguration();
        config.addProperty(CombinedConfigurationBuilder.ATTR_RELOAD,
                Boolean.valueOf(reload));
        config.addProperty("[@throwExceptionOnMissing]", Boolean.TRUE);
        config.addProperty("[@path]",
                ConfigurationAssert.getTestFile("test.properties")
                        .getAbsolutePath());
        config.addProperty("listDelimiterHandler[@config-class]",
                DefaultListDelimiterHandler.class.getName());
        config.addProperty(
                "listDelimiterHandler.config-constrarg[@config-value]", ";");
        return config;
    }
View Full Code Here

        AbstractTestConfigurationEvents
{
    @Override
    protected AbstractConfiguration createConfiguration()
    {
        return new BaseHierarchicalConfiguration();
    }
View Full Code Here

     * Tests events generated by the clearTree() method.
     */
    @Test
    public void testClearTreeEvent()
    {
        BaseHierarchicalConfiguration hc = (BaseHierarchicalConfiguration) config;
        String key = EXIST_PROPERTY.substring(0, EXIST_PROPERTY.indexOf('.'));
        NodeHandler<ImmutableNode> nodeHandler = hc.getNodeModel().getNodeHandler();
        Collection<QueryResult<ImmutableNode>> nodes = hc.getExpressionEngine()
                .query(nodeHandler.getRootNode(), key, nodeHandler);
        hc.clearTree(key);
        listener.checkEvent(ConfigurationEvent.CLEAR_TREE, key, null,
                true);
        listener.checkEvent(ConfigurationEvent.CLEAR_TREE, key, nodes,
                false);
        listener.done();
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.BaseHierarchicalConfiguration

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.