Package org.apache.commons.configuration2.event

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


     * method.
     */
    @Test
    public void testEventListenerConfiguration() throws ConfigurationException
    {
        EventListenerTestImpl listener1 = new EventListenerTestImpl(null);
        EventListenerRegistrationData<ConfigurationErrorEvent> regData =
                new EventListenerRegistrationData<ConfigurationErrorEvent>(
                        ConfigurationErrorEvent.WRITE,
                        new ErrorListenerTestImpl(null));
        BasicConfigurationBuilder<PropertiesConfiguration> builder =
View Full Code Here


     */
    @Test
    public void testRemoveConfigurationListenersOnReset()
            throws ConfigurationException
    {
        EventListenerTestImpl listener = new EventListenerTestImpl(null);
        BasicConfigurationBuilder<PropertiesConfiguration> builder =
                new BasicConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class)
                        .configure(new EventListenerParameters()
                                .addEventListener(ConfigurationEvent.ANY,
                                        listener));
        PropertiesConfiguration config = builder.getConfiguration();
        builder.resetResult();
        config.addProperty("foo", "bar");
        listener.done();
    }
View Full Code Here

     * Tests whether an event listener with its type can be added.
     */
    @Test
    public void testAddEventListener()
    {
        EventListenerTestImpl listener = new EventListenerTestImpl(null);
        EventListenerParameters parameters = new EventListenerParameters();
        assertSame("Wrong result", parameters, parameters.addEventListener(
                ConfigurationEvent.ADD_PROPERTY, listener));
        assertEquals("Wrong number of registrations", 1, parameters
                .getListeners().getRegistrations().size());
View Full Code Here

    public void testAddEventListenerRegistration()
    {
        EventListenerRegistrationData<ConfigurationEvent> reg =
                new EventListenerRegistrationData<ConfigurationEvent>(
                        ConfigurationEvent.SET_PROPERTY,
                        new EventListenerTestImpl(null));
        EventListenerParameters parameters = new EventListenerParameters();
        assertSame("Wrong result", parameters, parameters.addEventListener(reg));
        assertEquals("Wrong number of registrations", 1, parameters
                .getListeners().getRegistrations().size());
        assertEquals("Wrong registration", reg, parameters.getListeners()
View Full Code Here

     * configuration is cloned. They should not be registered at the clone.
     */
    @Test
    public void testCloneWithEventListeners()
    {
        EventListener<ConfigurationEvent> l = new EventListenerTestImpl(null);
        config.addEventListener(ConfigurationEvent.ANY, l);
        AbstractHierarchicalConfiguration<?> copy =
                (AbstractHierarchicalConfiguration<?>) config.clone();
        assertFalse("Event listener registered at clone", copy
                .getEventListeners(ConfigurationEvent.ANY).contains(l));
View Full Code Here

     * Ensures that event listeners are not cloned.
     */
    @Test
    public void testCloneEventListener()
    {
        cc.addEventListener(ConfigurationEvent.ANY, new EventListenerTestImpl(null));
        CompositeConfiguration cc2 = (CompositeConfiguration) cc.clone();
        assertTrue("Listeners have been cloned", cc2
                .getEventListeners(ConfigurationEvent.ANY).isEmpty());
    }
View Full Code Here

     * Tests whether add property events are triggered.
     */
    @Test
    public void testEventAddProperty()
    {
        EventListenerTestImpl listener = new EventListenerTestImpl(cc);
        cc.addEventListener(ConfigurationEvent.ANY, listener);
        cc.addProperty("test", "value");
        listener.checkEvent(ConfigurationEvent.ADD_PROPERTY, "test", "value", true);
        listener.checkEvent(ConfigurationEvent.ADD_PROPERTY, "test", "value", false);
        listener.done();
    }
View Full Code Here

     * Tests whether set property events are triggered.
     */
    @Test
    public void testEventSetProperty()
    {
        EventListenerTestImpl listener = new EventListenerTestImpl(cc);
        cc.addEventListener(ConfigurationEvent.ANY, listener);
        cc.setProperty("test", "value");
        listener.checkEvent(ConfigurationEvent.SET_PROPERTY, "test", "value", true);
        listener.checkEvent(ConfigurationEvent.SET_PROPERTY, "test", "value", false);
        listener.done();
    }
View Full Code Here

    {
        cc.addConfiguration(conf1);
        String key = "configuration.loaded";
        assertTrue("Wrong value for property", cc
                .getBoolean(key));
        EventListenerTestImpl listener = new EventListenerTestImpl(cc);
        cc.addEventListener(ConfigurationEvent.ANY, listener);
        cc.clearProperty(key);
        assertFalse("Key still present", cc.containsKey(key));
        listener.checkEvent(ConfigurationEvent.CLEAR_PROPERTY, key, null, true);
        listener.checkEvent(ConfigurationEvent.CLEAR_PROPERTY, key, null, false);
        listener.done();
    }
View Full Code Here

     * Tests whether a cloned configuration is decoupled from its original.
     */
    @Test
    public void testCloneModify()
    {
        EventListener<ConfigurationEvent> l = new EventListenerTestImpl(config);
        config.addEventListener(ConfigurationEvent.ANY, l);
        config.addProperty("original", Boolean.TRUE);
        BaseConfiguration config2 = (BaseConfiguration) config.clone();

        config2.addProperty("clone", Boolean.TRUE);
View Full Code Here

TOP

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

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.