Package org.apache.commons.configuration.event

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


            Configuration src, int eventType)
    {
        Map events = new HashMap();
        for (Iterator it = l.events.iterator(); it.hasNext();)
        {
            ConfigurationEvent e = (ConfigurationEvent) it.next();
            assertEquals("Wrong event type", eventType, e.getType());
            assertTrue("Unknown property: " + e.getPropertyName(), src
                    .containsKey(e.getPropertyName()));
            assertEquals("Wrong property value for " + e.getPropertyName(), e
                    .getPropertyValue(), src.getProperty(e.getPropertyName()));
            if (!e.isBeforeUpdate())
            {
                assertTrue("After event without before event", events
                        .containsKey(e.getPropertyName()));
            }
            else
            {
                events.put(e.getPropertyName(), e);
            }
        }

        for (Iterator it = src.getKeys(); it.hasNext();)
        {
View Full Code Here


     * Tests whether an invalidate event is fired only after a change. This test
     * is related to CONFIGURATION-315.
     */
    public void testInvalidateAfterChange()
    {
        ConfigurationEvent event = new ConfigurationEvent(config, 0, null,
                null, true);
        config.configurationChanged(event);
        assertEquals("Invalidate event fired", 0, listener.invalidateEvents);
        event = new ConfigurationEvent(config, 0, null, null, false);
        config.configurationChanged(event);
        assertEquals("No invalidate event fired", 1, listener.invalidateEvents);
    }
View Full Code Here

     * is related to CONFIGURATION-315.
     */
    @Test
    public void testInvalidateAfterChange()
    {
        ConfigurationEvent event = new ConfigurationEvent(config, 0, null,
                null, true);
        config.configurationChanged(event);
        assertEquals("Invalidate event fired", 0, listener.invalidateEvents);
        event = new ConfigurationEvent(config, 0, null, null, false);
        config.configurationChanged(event);
        assertEquals("No 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,
                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

     * should then be a multi-line property.
     */
    @Test
    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

     * handled.
     */
    @Test
    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.
     */
    @Test
    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

     */
    @Test
    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.
     */
    @Test
    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

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.