Package org.apache.commons.configuration2

Examples of org.apache.commons.configuration2.BaseHierarchicalConfiguration$BuilderVisitor


     * Tests fetching properties if none are defined.
     */
    @Test
    public void testGetBeanPropertiesEmpty()
    {
        XMLBeanDeclaration decl = new XMLBeanDeclaration(new BaseHierarchicalConfiguration());
        Map<String, Object> props = decl.getBeanProperties();
        assertTrue("Properties found", props == null || props.isEmpty());
    }
View Full Code Here


     *
     * @return the initialized test configuration
     */
    private static BaseHierarchicalConfiguration prepareNestedBeanDeclarations()
    {
        BaseHierarchicalConfiguration config =
                new BaseHierarchicalConfiguration();
        setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
        String keyCtorArg = KEY + ".config-constrarg";
        setupBeanDeclaration(config, keyCtorArg, CTOR_COMPLEX_ATTRIBUTES,
                CTOR_COMPLEX_VALUES);
        config.addProperty(keyCtorArg + "[@config-class]", "TestClass");
        config.addProperty(keyCtorArg + "(-1)[@config-value]", CTOR_ID);
        config.addProperty(keyCtorArg + "[@config-type]", "long");
        for (int i = 0; i < COMPLEX_PROPS.length; i++)
        {
            setupBeanDeclaration(config, KEY + '.' + COMPLEX_PROPS[i],
                    COMPLEX_ATTRIBUTES[i], COMPLEX_VALUES[i]);
            config.addProperty(
                    KEY + '.' + COMPLEX_PROPS[i] + "[@config-class]",
                    COMPLEX_CLASSES[i]);
        }
        return config;
    }
View Full Code Here

     * Tests fetching nested bean declarations.
     */
    @Test
    public void testGetNestedBeanDeclarations()
    {
        BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
        checkProperties(decl, TEST_PROPS, TEST_VALUES);

        Map<String, Object> nested = decl.getNestedBeanDeclarations();
        assertEquals("Wrong number of nested declarations",
View Full Code Here

     * are handled correctly. This is related to CONFIGURATION-567.
     */
    @Test
    public void testGetNestedBeanDeclarationsReservedCharacter()
    {
        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
        String key = KEY + ".address..private";
        setupBeanDeclaration(config, key, COMPLEX_ATTRIBUTES[0], COMPLEX_VALUES[0]);
        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);

        Map<String, Object> nested = decl.getNestedBeanDeclarations();
View Full Code Here

     * gets called.
     */
    @Test
    public void testGetNestedBeanDeclarationsFactoryMethod()
    {
        BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY)
        {
            @Override
            BeanDeclaration createBeanDeclaration(NodeData<?> node)
            {
View Full Code Here

     * Tests fetching nested bean declarations if none are defined.
     */
    @Test
    public void testGetNestedBeanDeclarationsEmpty()
    {
        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
        setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
        Map<String, Object> nested = decl.getNestedBeanDeclarations();
        assertTrue("Found nested declarations", nested == null
                || nested.isEmpty());
View Full Code Here

     * Tests whether interpolation of bean properties works.
     */
    @Test
    public void testGetInterpolatedBeanProperties()
    {
        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
        String[] varValues = new String[TEST_PROPS.length];
        for(int i = 0; i < TEST_PROPS.length; i++)
        {
            varValues[i] = "${" + VARS + TEST_PROPS[i] + "}";
            config.addProperty(VARS + TEST_PROPS[i], TEST_VALUES[i]);
        }
        setupBeanDeclaration(config, KEY, TEST_PROPS, varValues);
        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
        checkProperties(decl, TEST_PROPS, TEST_VALUES);
    }
View Full Code Here

     * cause an exception.
     */
    @Test(expected = ConfigurationRuntimeException.class)
    public void testInitFromUndefinedKey()
    {
        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
        setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
        new XMLBeanDeclaration(config, "undefined_key");
    }
View Full Code Here

     * is provided.
     */
    @Test
    public void testInitFromUndefinedKeyOptional()
    {
        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
        setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, "undefined_key", true);
        assertNull("Found a bean class", decl.getBeanClassName());
    }
View Full Code Here

     * This should cause an exception because keys must be unique.
     */
    @Test(expected = ConfigurationRuntimeException.class)
    public void testInitFromMultiValueKey()
    {
        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
        config.addProperty(KEY, "myFirstKey");
        config.addProperty(KEY, "mySecondKey");
        new XMLBeanDeclaration(config, KEY);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.BaseHierarchicalConfiguration$BuilderVisitor

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.