Package org.apache.commons.configuration.event

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


     * 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


            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

         * @param before the expected before flag
         */
        public void checkEvent(int type, String propName, Object propValue,
                boolean before)
        {
            ConfigurationEvent e = nextEvent(type);
            assertEquals("Wrong property name", propName, e.getPropertyName());
            assertEquals("Wrong property value", propValue, e
                    .getPropertyValue());
            assertEquals("Wrong before flag", before, e.isBeforeUpdate());
        }
View Full Code Here

         * @return the event object
         */
        public ConfigurationEvent nextEvent(int expectedType)
        {
            assertFalse("Too few events received", events.isEmpty());
            ConfigurationEvent e = (ConfigurationEvent) events.removeFirst();
            assertEquals("Wrong event source", config, e.getSource());
            assertEquals("Wrong event type", expectedType, e.getType());
            return e;
        }
View Full Code Here

         */
        public void skipToLast(int type)
        {
            while (events.size() > 1)
            {
                ConfigurationEvent e = (ConfigurationEvent) events
                        .removeFirst();
                assertTrue("Found end event in details", type != e.getType());
            }
        }
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

     * 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

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.