Package org.apache.commons.configuration.event

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


        config.getString("name");
        assertEquals("Wrong number of events", 2, l.events.size());
        boolean before = true;
        for (Iterator it = l.events.iterator(); it.hasNext();)
        {
            ConfigurationEvent e = (ConfigurationEvent) it.next();
            assertEquals("Wrong configuration", config, e.getSource());
            assertEquals("Wrong event type",
                    HierarchicalConfiguration.EVENT_SUBNODE_CHANGED, e
                            .getType());
            assertNull("Got a property name", e.getPropertyName());
            assertNull("Got a property value", e.getPropertyValue());
            assertEquals("Wrong before flag", before, e.isBeforeUpdate());
            before = !before;
        }
    }
View Full Code Here


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

     * Tests adding a property multiple time through an event. The property
     * should then be a multi-line property.
     */
    public void testEventAddMultiple()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.configurationChanged(event);
        layout.configurationChanged(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(builder.getReader());
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.configurationChanged(event);
        assertFalse("No multi-line property", layout.isSingleLine(TEST_KEY));
        assertEquals("Comment was modified", TEST_COMMENT, layout
View Full Code Here

     * Tests if a set property event for a non existing property is correctly
     * handled.
     */
    public void testEventSetNonExisting()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_SET_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.configurationChanged(event);
        assertTrue("New property was not found", layout.getKeys().contains(
                TEST_KEY));
View Full Code Here

    /**
     * Tests if a property delete event is correctly processed.
     */
    public void testEventDelete()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                false);
        layout.configurationChanged(event);
        event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_CLEAR_PROPERTY, TEST_KEY, null,
                false);
        layout.configurationChanged(event);
        assertFalse("Property still existing", layout.getKeys().contains(
                TEST_KEY));
View Full Code Here

     * Tests if a clear event is correctly processed.
     */
    public void testEventClearConfig() throws ConfigurationException
    {
        fillLayout();
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_CLEAR, null, null, false);
        layout.configurationChanged(event);
        assertTrue("Keys not empty", layout.getKeys().isEmpty());
        assertNull("Header comment was not reset", layout.getHeaderComment());
    }
View Full Code Here

    /**
     * Tests if a before update event is correctly ignored.
     */
    public void testEventAddBefore()
    {
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractConfiguration.EVENT_ADD_PROPERTY, TEST_KEY, TEST_VALUE,
                true);
        layout.configurationChanged(event);
        assertFalse("Property already stored", layout.getKeys().contains(
                TEST_KEY));
View Full Code Here

     * Tests if a reload update is correctly processed.
     */
    public void testEventReload()
    {
        fillLayout();
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractFileConfiguration.EVENT_RELOAD, null, null, true);
        layout.configurationChanged(event);
        assertTrue("Keys not empty", layout.getKeys().isEmpty());
        assertNull("Header comment was not reset", layout.getHeaderComment());
    }
View Full Code Here

     * ignored.
     */
    public void testEventReloadAfter()
    {
        fillLayout();
        ConfigurationEvent event = new ConfigurationEvent(this,
                AbstractFileConfiguration.EVENT_RELOAD, null, null, false);
        layout.configurationChanged(event);
        assertFalse("Keys are empty", layout.getKeys().isEmpty());
        assertNotNull("Header comment was reset", layout.getHeaderComment());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.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.