Examples of BuilderEventListenerImpl


Examples of org.apache.commons.configuration2.builder.BuilderEventListenerImpl

     * Tests whether builder reset events are handled correctly.
     */
    @Test
    public void testBuilderListenerReset() throws ConfigurationException
    {
        BuilderEventListenerImpl listener = new BuilderEventListenerImpl();
        Collection<FileBasedConfigurationBuilder<XMLConfiguration>> managedBuilders =
                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,
                builder.getConfiguration());
    }
View Full Code Here

Examples of org.apache.commons.configuration2.builder.BuilderEventListenerImpl

     */
    @Test
    public void testRemoveBuilderListenerOnReset()
            throws ConfigurationException
    {
        BuilderEventListenerImpl listener = new BuilderEventListenerImpl();
        Collection<FileBasedConfigurationBuilder<XMLConfiguration>> managedBuilders =
                new ArrayList<FileBasedConfigurationBuilder<XMLConfiguration>>();
        MultiFileConfigurationBuilder<XMLConfiguration> builder =
                createBuilderWithAccessToManagedBuilders(managedBuilders);
        switchToConfig(1);
        builder.addEventListener(ConfigurationBuilderEvent.RESET, listener);
        builder.getConfiguration();
        builder.resetParameters();
        managedBuilders.iterator().next().resetResult();
        listener.assertNoMoreEvents();
    }
View Full Code Here

Examples of org.apache.commons.configuration2.builder.BuilderEventListenerImpl

     * Tests whether builder events of other types can be received.
     */
    @Test
    public void testBuilderListenerOtherTypes() throws ConfigurationException
    {
        BuilderEventListenerImpl listener = new BuilderEventListenerImpl();
        MultiFileConfigurationBuilder<XMLConfiguration> builder =
                createTestBuilder(null);
        builder.addEventListener(ConfigurationBuilderEvent.ANY, listener);
        switchToConfig(1);
        builder.getConfiguration();
        ConfigurationBuilderEvent event =
                listener.nextEvent(ConfigurationBuilderEvent.CONFIGURATION_REQUEST);
        assertEquals("Wrong event source of request event", builder,
                event.getSource());
        ConfigurationBuilderResultCreatedEvent createdEvent =
                listener.nextEvent(ConfigurationBuilderResultCreatedEvent.RESULT_CREATED);
        assertEquals("Wrong source of creation event", builder,
                createdEvent.getSource());
        listener.assertNoMoreEvents();
    }
View Full Code Here

Examples of org.apache.commons.configuration2.builder.BuilderEventListenerImpl

                    childBuilder instanceof ReloadingControllerSupport);
            ReloadingController ctrl =
                    ((ReloadingControllerSupport) childBuilder)
                            .getReloadingController();
            ctrl.checkForReloading(null); // initialize reloading
            BuilderEventListenerImpl l = new BuilderEventListenerImpl();
            childBuilder.addEventListener(ConfigurationBuilderEvent.RESET, l);
            reloadConfig.setProperty(key, "yes");
            handler.save();

            int attempts = 10;
            boolean changeDetected;
            do
            {
                changeDetected = ctrl.checkForReloading(null);
                if (!changeDetected)
                {
                    Thread.sleep(1000);
                    handler.save(outFile);
                }
            } while (!changeDetected && --attempts > 0);
            assertTrue("No change detected", changeDetected);
            assertEquals("Wrong updated property", "yes", builder
                    .getConfiguration().getString(key));
            ConfigurationBuilderEvent event = l.nextEvent(ConfigurationBuilderEvent.RESET);
            l.assertNoMoreEvents();
            BasicConfigurationBuilder<? extends Configuration> multiBuilder =
                    (BasicConfigurationBuilder<? extends Configuration>) event.getSource();
            childBuilder.removeEventListener(ConfigurationBuilderEvent.RESET, l);
            multiBuilder.resetResult();
            l.assertNoMoreEvents();
        }
        finally
        {
            assertTrue("Output file could not be deleted", outFile.delete());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.