Package org.apache.commons.configuration2

Examples of org.apache.commons.configuration2.XMLConfiguration$XMLBuilderVisitor


     * @throws ConfigurationException if an error occurs
     */
    private static void checkTestConfiguration(FileHandler handler)
            throws ConfigurationException
    {
        XMLConfiguration config = new XMLConfiguration();
        FileHandler h2 = new FileHandler(config, handler);
        h2.load();
        assertEquals("Wrong content", "value", config.getString("element"));
    }
View Full Code Here


        builder.addEventListener(ConfigurationErrorEvent.ANY, l3);
        BasicConfigurationBuilder<XMLConfiguration> builder2 =
                new BasicConfigurationBuilder<XMLConfiguration>(
                        XMLConfiguration.class);
        builder.copyEventListeners(builder2);
        XMLConfiguration config = builder2.getConfiguration();
        Collection<EventListener<? super ConfigurationEvent>> listeners =
                config.getEventListeners(ConfigurationEvent.ANY);
        assertEquals("Wrong number of listeners", 1, listeners.size());
        assertTrue("Wrong listener", listeners.contains(l1));
        listeners =
                config.getEventListeners(ConfigurationEvent.ANY_HIERARCHICAL);
        assertEquals("Wrong number of listeners for hierarchical", 2,
                listeners.size());
        assertTrue("Listener 1 not found", listeners.contains(l1));
        assertTrue("Listener 2 not found", listeners.contains(l2));
        Collection<EventListener<? super ConfigurationErrorEvent>> errListeners =
                config.getEventListeners(ConfigurationErrorEvent.ANY);
        assertEquals("Wrong number of error listeners", 1, errListeners.size());
        assertTrue("Wrong error listener", errListeners.contains(l3));
    }
View Full Code Here

        logger.setAdditivity(false);
        ExprLookup.Variables vars = new ExprLookup.Variables();
        vars.add(new ExprLookup.Variable("String", org.apache.commons.lang3.StringUtils.class));
        vars.add(new ExprLookup.Variable("Util", new Utility("Hello")));
        vars.add(new ExprLookup.Variable("System", "Class:java.lang.System"));
        XMLConfiguration config = new XMLConfiguration();
        FileHandler handler = new FileHandler(config);
        handler.load(TEST_FILE);
        config.setLogger(log);
        ExprLookup lookup = new ExprLookup(vars);
        lookup.setInterpolator(config.getInterpolator());
        lookup.setLogger(log);
        String str = lookup.lookup(PATTERN1);
        assertTrue(str.startsWith("Goodbye"));
        str = lookup.lookup(PATTERN2);
        assertTrue("Incorrect value: " + str, str.equals("value Some text"));
View Full Code Here

     * @throws ConfigurationException if an error occurs
     */
    protected BaseHierarchicalConfiguration createCombinedConfiguration()
            throws ConfigurationException
    {
        XMLConfiguration conf1 = new XMLConfiguration();
        new FileHandler(conf1).load(CONF1);
        XMLConfiguration conf2 = new XMLConfiguration();
        new FileHandler(conf2).load(CONF2);
        ImmutableNode cn =
                combiner.combine(conf1.getNodeModel().getNodeHandler()
                        .getRootNode(), conf2.getNodeModel().getNodeHandler()
                        .getRootNode());

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

View Full Code Here

        ConfigurationInterpolator ci = createInterpolator();
        params.setInterpolator(ci).setListDelimiterHandler(
                new DefaultListDelimiterHandler('#'));
        builder.configure(params);
        switchToConfig(1);
        XMLConfiguration config = builder.getConfiguration();
        assertSame("Wrong expression engine", engine,
                config.getExpressionEngine());
        DefaultListDelimiterHandler listHandler =
                (DefaultListDelimiterHandler) config.getListDelimiterHandler();
        assertEquals("Wrong list delimiter", ';', listHandler.getDelimiter());
        assertNotSame("Interpolator was copied", ci, config.getInterpolator());
    }
View Full Code Here

        BasicBuilderParameters params = createTestBuilderParameters(null);
        MultiFileConfigurationBuilder<XMLConfiguration> builder =
                new MultiFileConfigurationBuilder<XMLConfiguration>(
                        XMLConfiguration.class, params.getParameters(), true);
        switchToConfig("unknown configuration ID");
        XMLConfiguration config = builder.getConfiguration();
        assertTrue("Got content", config.isEmpty());
    }
View Full Code Here

        EasyMock.replay(l2);
        MultiFileConfigurationBuilder<XMLConfiguration> builder =
                createTestBuilder(null);
        builder.addEventListener(ConfigurationEvent.ANY, l1);
        switchToConfig(1);
        XMLConfiguration config = builder.getConfiguration();
        assertTrue("Listener not added", config.getEventListeners(ConfigurationEvent.ANY)
                .contains(l1));
        builder.addEventListener(Event.ANY, l2);
        assertTrue("Listener 2 not added", config.getEventListeners(Event.ANY)
                .contains(l2));
        assertTrue("Wrong result", builder.removeEventListener(Event.ANY, l2));
        assertFalse("Wrong result after removal",
                builder.removeEventListener(Event.ANY, l2));
        assertFalse("Listener not removed", config.getEventListeners(Event.ANY)
                .contains(l2));
        switchToConfig(2);
        XMLConfiguration config2 = builder.getConfiguration();
        assertFalse("Listener not globally removed", config2
                .getEventListeners(Event.ANY).contains(l2));
    }
View Full Code Here

                new ArrayList<FileBasedConfigurationBuilder<XMLConfiguration>>();
        MultiFileConfigurationBuilder<XMLConfiguration> builder =
                createBuilderWithAccessToManagedBuilders(managedBuilders);
        switchToConfig(1);
        builder.addEventListener(ConfigurationBuilderEvent.RESET, listener);
        XMLConfiguration configuration = builder.getConfiguration();
        managedBuilders.iterator().next().resetResult();
        ConfigurationBuilderEvent event =
                listener.nextEvent(ConfigurationBuilderEvent.RESET);
        assertSame("Wrong event source", builder, event.getSource());
        assertNotSame("Configuration not reset", configuration,
View Full Code Here

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

     * @return the underlying configuration
     */
    @Override
    protected Configuration createConfiguration()
    {
        return new XMLConfiguration();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.XMLConfiguration$XMLBuilderVisitor

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.