Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.BaseConfiguration


    configurationFactory.afterPropertiesSet();
    assertNotNull(configurationFactory.getObject());
  }

  public void testMergeConfigurations() throws Exception {
    Configuration one = new BaseConfiguration();
    one.setProperty("foo", "bar");
    PropertiesConfiguration two = new PropertiesConfiguration();
    String properties = "## some header \n" + "foo = bar1\n" + "bar = foo\n";
    two.load(new StringReader(properties));

    configurationFactory.setConfigurations(new Configuration[] { one, two });
View Full Code Here


    assertEquals("bar", props.getProperty("foo"));
  }

  public void testLoadResources() throws Exception {
    configurationFactory.setLocations(new Resource[] { new ClassPathResource("configuration.file") });
    configurationFactory.setConfigurations(new Configuration[] { new BaseConfiguration() });
    configurationFactory.afterPropertiesSet();
   
    Properties props = (Properties) configurationFactory.getObject();
    assertEquals("satriani", props.getProperty("joe"));
  }
View Full Code Here

    Properties props = (Properties) configurationFactory.getObject();
    assertEquals("satriani", props.getProperty("joe"));
  }
 
  public void testInitialConfiguration() throws Exception {
    configurationFactory = new CommonsConfigurationFactoryBean(new BaseConfiguration());
    configurationFactory.afterPropertiesSet();
    assertNotNull(configurationFactory.getConfiguration());
  }
View Full Code Here

        // test the postgresql variation
        c = new Criteria();
        Criteria.Criterion cc =
            c.getNewCriterion("TABLE.COLUMN", Boolean.TRUE, Criteria.EQUAL);

        Configuration conf = new BaseConfiguration();
        conf.addProperty("driver", "org.postgresql.Driver");
        try
        {
            cc.setDB(DBFactory.create("org.postgresql.Driver"));
        }
        catch (Exception e)
View Full Code Here

     * Creates the underlying configuration object for the dyna bean.
     * @return the underlying configuration object
     */
    protected Configuration createConfiguration()
    {
        return new BaseConfiguration();
    }
View Full Code Here

*/
public class TestServletRequestConfiguration extends TestAbstractConfiguration
{
    protected AbstractConfiguration getConfiguration()
    {
        final Configuration configuration = new BaseConfiguration();
        ((BaseConfiguration) configuration).setListDelimiter('\0');
        configuration.setProperty("key1", "value1");
        configuration.setProperty("key2", "value2");
        configuration.addProperty("list", "value1");
        configuration.addProperty("list", "value2");
        configuration.addProperty("listesc", "value1\\,value2");

        return createConfiguration(configuration);
    }
View Full Code Here

        return createConfiguration(configuration);
    }

    protected AbstractConfiguration getEmptyConfiguration()
    {
        final Configuration configuration = new BaseConfiguration();

        ServletRequest request = new MockHttpServletRequest()
        {
            public String getParameter(String key)
            {
                return null;
            }

            public Enumeration getParameterNames()
            {
                return new IteratorEnumeration(configuration.getKeys());
            }
        };

        return new ServletRequestConfiguration(request);
    }
View Full Code Here

    public void testListWithEscapedElements()
    {
        String[] values =
        { "test1", "test2\\,test3", "test4\\,test5" };
        final String listKey = "test.list";
        BaseConfiguration config = new BaseConfiguration();
        config.setListDelimiter('\0');
        config.addProperty(listKey, values);
        assertEquals("Wrong number of list elements", values.length, config
                .getList(listKey).size());
        Configuration c = createConfiguration(config);
        List v = c.getList(listKey);
        assertEquals("Wrong number of elements in list", values.length, v
                .size());
View Full Code Here

*/
public class TestServletRequestConfiguration extends TestAbstractConfiguration
{
    protected AbstractConfiguration getConfiguration()
    {
        final Configuration configuration = new BaseConfiguration();
        configuration.setProperty("key1", "value1");
        configuration.setProperty("key2", "value2");
        configuration.addProperty("list", "value1");
        configuration.addProperty("list", "value2");

        ServletRequest request = new MockHttpServletRequest()
        {
            public String[] getParameterValues(String key)
            {
                return configuration.getStringArray(key);
            }

            public Enumeration getParameterNames()
            {
                return new IteratorEnumeration(configuration.getKeys());
            }
        };

        return new ServletRequestConfiguration(request);
    }
View Full Code Here

        return new ServletRequestConfiguration(request);
    }

    protected AbstractConfiguration getEmptyConfiguration()
    {
        final Configuration configuration = new BaseConfiguration();

        ServletRequest request = new MockHttpServletRequest()
        {
            public String getParameter(String key)
            {
                return null;
            }

            public Enumeration getParameterNames()
            {
                return new IteratorEnumeration(configuration.getKeys());
            }
        };

        return new ServletRequestConfiguration(request);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.BaseConfiguration

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.