Package org.apache.commons.configuration2.event

Examples of org.apache.commons.configuration2.event.ConfigurationEvent


    @Test
    public void testGetPropertyTrimNoSplit()
    {
        MapConfiguration config = (MapConfiguration) getConfiguration();
        config.getMap().put(KEY, SPACE_VALUE);
        config.setListDelimiterHandler(new DisabledListDelimiterHandler());
        assertEquals("Wrong trimmed value", SPACE_VALUE, config.getProperty(KEY));
    }
View Full Code Here


        // first clone this configuration
        AbstractConfiguration c = (AbstractConfiguration) ConfigurationUtils
                .cloneConfiguration(this);

        // now perform interpolation
        c.setListDelimiterHandler(new DisabledListDelimiterHandler());
        for (Iterator<String> it = getKeys(); it.hasNext();)
        {
            String key = it.next();
            c.setProperty(key, getList(key));
        }
View Full Code Here

     * @param value the value to be added
     */
    @Override
    protected void addPropertyInternal(String key, Object value)
    {
        ListDelimiterHandler oldHandler = getListDelimiterHandler();
        try
        {
            // temporarily disable delimiter parsing
            setListDelimiterHandler(DisabledListDelimiterHandler.INSTANCE);
            super.addPropertyInternal(key, value);
View Full Code Here

     * from the parent.
     */
    @Test
    public void testSetListDelimiterHandler()
    {
        ListDelimiterHandler handler1 = new DefaultListDelimiterHandler('/');
        ListDelimiterHandler handler2 = new DefaultListDelimiterHandler(';');
        parent.setListDelimiterHandler(handler1);
        setUpSubnodeConfig();
        parent.setListDelimiterHandler(handler2);
        assertEquals("List delimiter handler not obtained from parent",
                handler1, config.getListDelimiterHandler());
View Full Code Here

     * @return Properties created from the Configuration
     */
    public static Properties getProperties(Configuration config)
    {
        Properties props = new Properties();
        ListDelimiterHandler listHandler;
        boolean useDelimiterHandler;

        if(config instanceof AbstractConfiguration)
        {
            listHandler = ((AbstractConfiguration) config).getListDelimiterHandler();
            useDelimiterHandler = true;
        }
        else
        {
            listHandler = null;
            useDelimiterHandler = false;
        }

        for (Iterator<String> keys = config.getKeys(); keys.hasNext();)
        {
            String key = keys.next();
            List<Object> list = config.getList(key);

            String propValue;
            if (useDelimiterHandler)
            {
                try
                {
                    propValue =
                            String.valueOf(listHandler.escapeList(list,
                                    ListDelimiterHandler.NOOP_TRANSFORMER));
                }
                catch (Exception ex)
                {
                    // obviously, the list handler does not support splitting
View Full Code Here

     * test is related to CONFIGURATION-315.
     */
    @Test
    public void testInvalidateEventBeforeAndAfterChange()
    {
        ConfigurationEvent event =
                new ConfigurationEvent(config, ConfigurationEvent.ANY, null, null, true);
        config.onEvent(event);
        assertEquals("No invalidate event fired", 1, listener.invalidateEvents);
        event = new ConfigurationEvent(config, ConfigurationEvent.ANY, null, null, false);
        config.onEvent(event);
        assertEquals("Another invalidate event fired", 1,
                listener.invalidateEvents);
    }
View Full Code Here

     * Tests if a property add event is correctly processed.
     */
    @Test
    public void testEventAdd()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.onEvent(event);
        assertTrue("Property not stored", layout.getKeys().contains(TEST_KEY));
        assertEquals("Blanc lines before new property", 0, layout
View Full Code Here

     * should then be a multi-line property.
     */
    @Test
    public void testEventAddMultiple()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.onEvent(event);
        layout.onEvent(event);
        assertFalse("No multi-line property", layout.isSingleLine(TEST_KEY));
View Full Code Here

    public void testEventAddExisting() throws ConfigurationException
    {
        builder.addComment(TEST_COMMENT);
        builder.addProperty(TEST_KEY, TEST_VALUE);
        layout.load(config, builder.getReader());
        ConfigurationEvent event = new ConfigurationEvent(this,
                ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.onEvent(event);
        assertFalse("No multi-line property", layout.isSingleLine(TEST_KEY));
        assertEquals("Comment was modified", TEST_COMMENT, layout
View Full Code Here

     * handled.
     */
    @Test
    public void testEventSetNonExisting()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                ConfigurationEvent.SET_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.onEvent(event);
        assertTrue("New property was not found", layout.getKeys().contains(
                TEST_KEY));
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.event.ConfigurationEvent

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.