commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1587302 - in /commons/proper/configuration/branches/immutableNodes/src: main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
Date Mon, 14 Apr 2014 20:09:30 GMT
Author: oheger
Date: Mon Apr 14 20:09:30 2014
New Revision: 1587302

URL: http://svn.apache.org/r1587302
Log:
Reworked XMLBeanDeclaration to work with new hierarchical configurations.

The can now deal with arbitrary node types for which a node handler is
available.

Modified:
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java?rev=1587302&r1=1587301&r2=1587302&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
Mon Apr 14 20:09:30 2014
@@ -19,17 +19,16 @@ package org.apache.commons.configuration
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import org.apache.commons.configuration.BaseHierarchicalConfiguration;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.SubnodeConfiguration;
 import org.apache.commons.configuration.ex.ConfigurationRuntimeException;
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
-import org.apache.commons.configuration.tree.ConfigurationNode;
-import org.apache.commons.configuration.tree.DefaultConfigurationNode;
+import org.apache.commons.configuration.tree.NodeHandler;
 
 /**
  * <p>
@@ -151,10 +150,10 @@ public class XMLBeanDeclaration implemen
     private static final String ATTR_CTOR_TYPE = RESERVED_PREFIX + "type";
 
     /** Stores the associated configuration. */
-    private final SubnodeConfiguration configuration;
+    private final HierarchicalConfiguration<?> configuration;
 
     /** Stores the configuration node that contains the bean declaration. */
-    private final ConfigurationNode node;
+    private final NodeData<?> node;
 
     /** The name of the default bean class. */
     private final String defaultBeanClassName;
@@ -171,7 +170,7 @@ public class XMLBeanDeclaration implemen
      * @throws IllegalArgumentException if required information is missing to
      *         construct the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key)
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String
key)
     {
         this(config, key, false);
     }
@@ -188,7 +187,7 @@ public class XMLBeanDeclaration implemen
      * @throws IllegalArgumentException if required information is missing to
      *         construct the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key,
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String
key,
             boolean optional)
     {
         this(config, key, optional, null);
@@ -217,7 +216,7 @@ public class XMLBeanDeclaration implemen
      *         construct the bean declaration
      * @since 2.0
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key,
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String
key,
             boolean optional, String defBeanClsName)
     {
         if (config == null)
@@ -226,24 +225,21 @@ public class XMLBeanDeclaration implemen
                     "Configuration must not be null!");
         }
 
-        SubnodeConfiguration tmpconfiguration = null;
-        ConfigurationNode tmpnode = null;
+        HierarchicalConfiguration<?> tmpconfiguration;
         try
         {
             tmpconfiguration = config.configurationAt(key);
-            tmpnode = tmpconfiguration.getRootNode();
         }
-        catch (IllegalArgumentException iex)
+        catch (ConfigurationRuntimeException iex)
         {
             // If we reach this block, the key does not have exactly one value
             if (!optional || config.getMaxIndex(key) > 0)
             {
                 throw iex;
             }
-            tmpconfiguration = config.configurationAt(null);
-            tmpnode = new DefaultConfigurationNode();
+            tmpconfiguration = new BaseHierarchicalConfiguration();
         }
-        this.node = tmpnode;
+        this.node = createNodeDataFromConfiguration(tmpconfiguration);
         this.configuration = tmpconfiguration;
         defaultBeanClassName = defBeanClsName;
         initSubnodeConfiguration(getConfiguration());
@@ -256,7 +252,7 @@ public class XMLBeanDeclaration implemen
      *
      * @param config the configuration with the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config)
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config)
     {
         this(config, (String) null);
     }
@@ -264,24 +260,14 @@ public class XMLBeanDeclaration implemen
     /**
      * Creates a new instance of {@code XMLBeanDeclaration} and
      * initializes it with the configuration node that contains the bean
-     * declaration.
+     * declaration. This constructor is used internally.
      *
      * @param config the configuration
      * @param node the node with the bean declaration.
      */
-    public XMLBeanDeclaration(SubnodeConfiguration config,
-            ConfigurationNode node)
+    XMLBeanDeclaration(HierarchicalConfiguration<?> config,
+            NodeData<?> node)
     {
-        if (config == null)
-        {
-            throw new IllegalArgumentException(
-                    "Configuration must not be null!");
-        }
-        if (node == null)
-        {
-            throw new IllegalArgumentException("Node must not be null!");
-        }
-
         this.node = node;
         configuration = config;
         defaultBeanClassName = null;
@@ -293,7 +279,7 @@ public class XMLBeanDeclaration implemen
      *
      * @return the associated configuration
      */
-    public SubnodeConfiguration getConfiguration()
+    public HierarchicalConfiguration<?> getConfiguration()
     {
         return configuration;
     }
@@ -312,16 +298,6 @@ public class XMLBeanDeclaration implemen
     }
 
     /**
-     * Returns the node that contains the bean declaration.
-     *
-     * @return the configuration node this bean declaration is based on
-     */
-    public ConfigurationNode getNode()
-    {
-        return node;
-    }
-
-    /**
      * Returns the name of the bean factory. This information is fetched from
      * the {@code config-factory} attribute.
      *
@@ -330,7 +306,7 @@ public class XMLBeanDeclaration implemen
     @Override
     public String getBeanFactoryName()
     {
-        return getConfiguration().getString(ATTR_BEAN_FACTORY);
+        return getConfiguration().getString(ATTR_BEAN_FACTORY, null);
     }
 
     /**
@@ -367,11 +343,11 @@ public class XMLBeanDeclaration implemen
     public Map<String, Object> getBeanProperties()
     {
         Map<String, Object> props = new HashMap<String, Object>();
-        for (ConfigurationNode attr : getNode().getAttributes())
+        for (String key : getNode().getAttributes())
         {
-            if (!isReservedNode(attr))
+            if (!isReservedName(key))
             {
-                props.put(attr.getName(), interpolate(attr .getValue()));
+                props.put(key, interpolate(getNode().getAttribute(key)));
             }
         }
 
@@ -389,13 +365,13 @@ public class XMLBeanDeclaration implemen
     public Map<String, Object> getNestedBeanDeclarations()
     {
         Map<String, Object> nested = new HashMap<String, Object>();
-        for (ConfigurationNode child : getNode().getChildren())
+        for (NodeData<?> child : getNode().getChildren())
         {
-            if (!isReservedNode(child))
+            if (!isReservedName(child.nodeName()))
             {
-                if (nested.containsKey(child.getName()))
+                if (nested.containsKey(child.nodeName()))
                 {
-                    Object obj = nested.get(child.getName());
+                    Object obj = nested.get(child.nodeName());
                     List<BeanDeclaration> list;
                     if (obj instanceof List)
                     {
@@ -408,13 +384,13 @@ public class XMLBeanDeclaration implemen
                     {
                         list = new ArrayList<BeanDeclaration>();
                         list.add((BeanDeclaration) obj);
-                        nested.put(child.getName(), list);
+                        nested.put(child.nodeName(), list);
                     }
                     list.add(createBeanDeclaration(child));
                 }
                 else
                 {
-                    nested.put(child.getName(), createBeanDeclaration(child));
+                    nested.put(child.nodeName(), createBeanDeclaration(child));
                 }
             }
         }
@@ -433,7 +409,7 @@ public class XMLBeanDeclaration implemen
     public Collection<ConstructorArg> getConstructorArgs()
     {
         Collection<ConstructorArg> args = new LinkedList<ConstructorArg>();
-        for (ConfigurationNode child : getNode().getChildren(ELEM_CTOR_ARG))
+        for (NodeData<?> child : getNode().getChildren(ELEM_CTOR_ARG))
         {
             args.add(createConstructorArg(child));
         }
@@ -452,23 +428,33 @@ public class XMLBeanDeclaration implemen
     protected Object interpolate(Object value)
     {
         ConfigurationInterpolator interpolator =
-                getConfiguration().getParent().getInterpolator();
+                getConfiguration().getInterpolator();
         return (interpolator != null) ? interpolator.interpolate(value) : value;
     }
 
     /**
-     * Checks if the specified node is reserved and thus should be ignored. This
+     * Checks if the specified name of a node or attribute is reserved and thus should be
ignored. This
      * method is called when the maps for the bean's properties and complex
-     * properties are collected. It checks whether the name of the given node
+     * properties are collected. It checks whether the passed in name
      * starts with the reserved prefix.
      *
-     * @param nd the node to be checked
-     * @return a flag whether this node is reserved (and does not point to a
+     * @param name the name to be checked
+     * @return a flag whether this name is reserved (and does not point to a
      *         property)
      */
-    protected boolean isReservedNode(ConfigurationNode nd)
+    protected boolean isReservedName(String name)
+    {
+        return name == null || name.startsWith(RESERVED_PREFIX);
+    }
+
+    /**
+     * Returns the data about the associated node.
+     *
+     * @return the node with the bean declaration
+     */
+    NodeData<?> getNode()
     {
-        return nd.getName() == null || nd.getName().startsWith(RESERVED_PREFIX);
+        return node;
     }
 
     /**
@@ -483,39 +469,29 @@ public class XMLBeanDeclaration implemen
      * @param node the child node, for which a {@code BeanDeclaration} is
      *        to be created
      * @return the {@code BeanDeclaration} for this child node
-     * @since 1.6
      */
-    protected BeanDeclaration createBeanDeclaration(ConfigurationNode node)
+    BeanDeclaration createBeanDeclaration(NodeData<?> node)
     {
-        List<SubnodeConfiguration> list = getConfiguration().configurationsAt(node.getName());
-        if (list.size() == 1)
-        {
-            return new XMLBeanDeclaration(list.get(0), node);
-        }
-        else
+        for (HierarchicalConfiguration<?> config : getConfiguration()
+                .configurationsAt(node.nodeName()))
         {
-            Iterator<SubnodeConfiguration> iter = list.iterator();
-            while (iter.hasNext())
+            if (node.matchesConfigRootNode(config))
             {
-                SubnodeConfiguration config = iter.next();
-                if (config.getRootNode().equals(node))
-                {
-                    return new XMLBeanDeclaration(config, node);
-                }
+                return new XMLBeanDeclaration(config, node);
             }
-            throw new ConfigurationRuntimeException("Unable to match node for " + node.getName());
         }
+        throw new ConfigurationRuntimeException("Unable to match node for "
+                + node.nodeName());
     }
 
     /**
-     * Initializes the internally managed subnode configuration. This method
+     * Initializes the internally managed sub configuration. This method
      * will set some default values for some properties.
      *
      * @param conf the configuration to initialize
      */
-    private void initSubnodeConfiguration(SubnodeConfiguration conf)
+    private void initSubnodeConfiguration(HierarchicalConfiguration<?> conf)
     {
-        conf.setThrowExceptionOnMissing(false);
         conf.setExpressionEngine(null);
     }
 
@@ -526,7 +502,7 @@ public class XMLBeanDeclaration implemen
      * @param child the configuration node
      * @return the corresponding {@code ConstructorArg} object
      */
-    private ConstructorArg createConstructorArg(ConfigurationNode child)
+    private ConstructorArg createConstructorArg(NodeData<?> child)
     {
         String type = getAttribute(child, ATTR_CTOR_TYPE);
         if (isBeanDeclarationArgument(child))
@@ -543,16 +519,16 @@ public class XMLBeanDeclaration implemen
 
     /**
      * Helper method for obtaining an attribute of a configuration node.
+     * This method also takes interpolation into account.
      *
      * @param nd the node
      * @param attr the name of the attribute
      * @return the string value of this attribute (can be <b>null</b>)
      */
-    private String getAttribute(ConfigurationNode nd, String attr)
+    private String getAttribute(NodeData<?> nd, String attr)
     {
-        List<ConfigurationNode> attributes = nd.getAttributes(attr);
-        return attributes.isEmpty() ? null : String
-                .valueOf(interpolate(attributes.get(0).getValue()));
+        Object value = nd.getAttribute(attr);
+        return (value == null) ? null : String.valueOf(interpolate(value));
     }
 
     /**
@@ -562,8 +538,134 @@ public class XMLBeanDeclaration implemen
      * @param nd the configuration node in question
      * @return a flag whether this constructor argument is a bean declaration
      */
-    private static boolean isBeanDeclarationArgument(ConfigurationNode nd)
+    private static boolean isBeanDeclarationArgument(NodeData<?> nd)
+    {
+        return !nd.getAttributes().contains(ATTR_BEAN_CLASS_NAME);
+    }
+
+    /**
+     * Creates a {@code NodeData} object from the root node of the given
+     * configuration.
+     *
+     * @param config the configuration
+     * @param <T> the type of the nodes
+     * @return the {@code NodeData} object
+     */
+    private static <T> NodeData<T> createNodeDataFromConfiguration(
+            HierarchicalConfiguration<T> config)
     {
-        return nd.getAttributes(ATTR_BEAN_CLASS_NAME).isEmpty();
+        NodeHandler<T> handler = config.getNodeModel().getNodeHandler();
+        return new NodeData<T>(handler.getRootNode(), handler);
+    }
+
+    /**
+     * An internally used helper class which wraps the node with the bean
+     * declaration and the corresponding node handler.
+     *
+     * @param <T> the type of the node
+     */
+    static class NodeData<T>
+    {
+        /** The wrapped node. */
+        private final T node;
+
+        /** The node handler for interacting with this node. */
+        private final NodeHandler<T> handler;
+
+        /**
+         * Creates a new instance of {@code NodeData}.
+         *
+         * @param nd the node
+         * @param hndlr the handler
+         */
+        public NodeData(T nd, NodeHandler<T> hndlr)
+        {
+            node = nd;
+            handler = hndlr;
+        }
+
+        /**
+         * Returns the name of the wrapped node.
+         *
+         * @return the node name
+         */
+        public String nodeName()
+        {
+            return handler.nodeName(node);
+        }
+
+        /**
+         * Returns a list with the children of the wrapped node, again wrapped
+         * into {@code NodeData} objects.
+         *
+         * @return a list with the children
+         */
+        public List<NodeData<T>> getChildren()
+        {
+            return wrapInNodeData(handler.getChildren(node));
+        }
+
+        /**
+         * Returns a list with the children of the wrapped node with the given
+         * name, again wrapped into {@code NodeData} objects.
+         *
+         * @param name the name of the desired child nodes
+         * @return a list with the children with this name
+         */
+        public List<NodeData<T>> getChildren(String name)
+        {
+            return wrapInNodeData(handler.getChildren(node, name));
+        }
+
+        /**
+         * Returns a set with the names of the attributes of the wrapped node.
+         *
+         * @return the attribute names of this node
+         */
+        public Set<String> getAttributes()
+        {
+            return handler.getAttributes(node);
+        }
+
+        /**
+         * Returns the value of the attribute with the given name of the wrapped
+         * node.
+         *
+         * @param key the key of the attribute
+         * @return the value of this attribute
+         */
+        public Object getAttribute(String key)
+        {
+            return handler.getAttributeValue(node, key);
+        }
+
+        /**
+         * Returns a flag whether the wrapped node is the root node of the
+         * passed in configuration.
+         *
+         * @param config the configuration
+         * @return a flag whether this node is the configuration's root node
+         */
+        public boolean matchesConfigRootNode(HierarchicalConfiguration<?> config)
+        {
+            return config.getNodeModel().getNodeHandler().getRootNode()
+                    .equals(node);
+        }
+
+        /**
+         * Wraps the passed in list of nodes in {@code NodeData} objects.
+         *
+         * @param nodes the list with nodes
+         * @return the wrapped nodes
+         */
+        private List<NodeData<T>> wrapInNodeData(List<T> nodes)
+        {
+            List<NodeData<T>> result = new ArrayList<NodeData<T>>(nodes.size());
+            for (T node : nodes)
+            {
+                result.add(new NodeData<T>(node, handler));
+            }
+            return result;
+        }
     }
 }

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java?rev=1587302&r1=1587301&r2=1587302&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
Mon Apr 14 20:09:30 2014
@@ -28,8 +28,7 @@ import java.util.Map;
 
 import org.apache.commons.configuration.BaseHierarchicalConfiguration;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.SubnodeConfiguration;
-import org.apache.commons.configuration.tree.ConfigurationNode;
+import org.apache.commons.configuration.ex.ConfigurationRuntimeException;
 import org.junit.Test;
 
 /**
@@ -92,24 +91,13 @@ public class TestXMLBeanDeclaration
     private static final String VARS = "variables.";
 
     /**
-     * Tests creating a declaration from a null node. This should cause an
-     * exception.
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testInitFromNullNode()
-    {
-        new XMLBeanDeclaration(new BaseHierarchicalConfiguration().configurationAt(null),
-                (ConfigurationNode) null);
-    }
-
-    /**
      * Tests creating a declaration from a null configuration. This should cause
      * an exception.
      */
     @Test(expected = IllegalArgumentException.class)
     public void testInitFromNullConfiguration()
     {
-        new XMLBeanDeclaration((HierarchicalConfiguration) null);
+        new XMLBeanDeclaration(null);
     }
 
     /**
@@ -123,17 +111,6 @@ public class TestXMLBeanDeclaration
     }
 
     /**
-     * Tests creating a declaration from a null configuration with a node. This
-     * should cause an exception.
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testInitFromNullConfigurationAndNode()
-    {
-        new XMLBeanDeclaration(null, new BaseHierarchicalConfiguration()
-                .getRootNode());
-    }
-
-    /**
      * Tests fetching the bean's class name.
      */
     @Test
@@ -157,6 +134,18 @@ public class TestXMLBeanDeclaration
     }
 
     /**
+     * Tests that a missing bean class name does not cause an exception.
+     */
+    @Test
+    public void testGetBeanClassNameUndefinedWithEx()
+    {
+        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        config.setThrowExceptionOnMissing(true);
+        XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
+        assertNull("Got a bean class name", decl.getBeanClassName());
+    }
+
+    /**
      * Tests whether a default bean class name is taken into account.
      */
     @Test
@@ -212,6 +201,18 @@ public class TestXMLBeanDeclaration
     }
 
     /**
+     * Tests that a missing bean factory name does not throw an exception.
+     */
+    @Test
+    public void testGetBeanFactoryNameUndefinedWithEx()
+    {
+        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        config.setThrowExceptionOnMissing(true);
+        XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
+        assertNull("Got a factory name", decl.getBeanFactoryName());
+    }
+
+    /**
      * Tests fetching the parameter for the bean factory.
      */
     @Test
@@ -237,6 +238,18 @@ public class TestXMLBeanDeclaration
     }
 
     /**
+     * Tests that an undefined bean factory parameter does not cause an exception.
+     */
+    @Test
+    public void testGetBeanFactoryParameterUndefinedWithEx()
+    {
+        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        config.setThrowExceptionOnMissing(true);
+        XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
+        assertNull("Got a factory parameter", decl.getBeanFactoryParameter());
+    }
+
+    /**
      * Tests if the bean's properties are correctly extracted from the
      * configuration object.
      */
@@ -278,9 +291,10 @@ public class TestXMLBeanDeclaration
     /**
      * Creates a configuration with data for testing nested bean declarations
      * including constructor arguments.
+     *
      * @return the initialized test configuration
      */
-    private HierarchicalConfiguration prepareNestedBeanDeclarations()
+    private static BaseHierarchicalConfiguration prepareNestedBeanDeclarations()
     {
         BaseHierarchicalConfiguration config =
                 new BaseHierarchicalConfiguration();
@@ -308,7 +322,7 @@ public class TestXMLBeanDeclaration
     @Test
     public void testGetNestedBeanDeclarations()
     {
-        HierarchicalConfiguration config = prepareNestedBeanDeclarations();
+        BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
         XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
         checkProperties(decl, TEST_PROPS, TEST_VALUES);
 
@@ -333,15 +347,14 @@ public class TestXMLBeanDeclaration
     @Test
     public void testGetNestedBeanDeclarationsFactoryMethod()
     {
-        HierarchicalConfiguration config = prepareNestedBeanDeclarations();
+        BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
         XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY)
         {
             @Override
-            protected BeanDeclaration createBeanDeclaration(
-                    ConfigurationNode node)
+            BeanDeclaration createBeanDeclaration(NodeData<?> node)
             {
                 return new XMLBeanDeclarationTestImpl(getConfiguration()
-                        .configurationAt(node.getName()), node);
+                        .configurationAt(node.nodeName()), node);
             }
         };
         Map<String, Object> nested = decl.getNestedBeanDeclarations();
@@ -388,7 +401,7 @@ public class TestXMLBeanDeclaration
      * Tests constructing a bean declaration from an undefined key. This should
      * cause an exception.
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testInitFromUndefinedKey()
     {
         BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
@@ -415,7 +428,7 @@ public class TestXMLBeanDeclaration
      * Tests constructing a bean declaration from a key with multiple values.
      * This should cause an exception because keys must be unique.
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testInitFromMultiValueKey()
     {
         BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
@@ -430,7 +443,7 @@ public class TestXMLBeanDeclaration
     @Test
     public void testGetConstructorArgs()
     {
-        HierarchicalConfiguration config = prepareNestedBeanDeclarations();
+        BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
         XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
         Collection<ConstructorArg> args = decl.getConstructorArgs();
         assertEquals("Wrong number of constructor arguments", 2, args.size());
@@ -454,7 +467,7 @@ public class TestXMLBeanDeclaration
     @Test
     public void testGetConstructorArgsNullArg()
     {
-        HierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
         config.addProperty(KEY + ".config-constrarg", "");
         XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
@@ -471,7 +484,7 @@ public class TestXMLBeanDeclaration
     @Test
     public void testGetInterpolatedConstructorArgs()
     {
-        HierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
         String expectedValue = "ctorArg";
         config.addProperty("value", expectedValue);
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
@@ -488,7 +501,7 @@ public class TestXMLBeanDeclaration
     @Test
     public void testInterpolateNoInterpolator()
     {
-        HierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
         config.addProperty("value", "expectedValue");
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
         String value = "${value}";
@@ -509,7 +522,7 @@ public class TestXMLBeanDeclaration
      * @param names an array with the names of the properties
      * @param values an array with the corresponding values
      */
-    private void setupBeanDeclaration(HierarchicalConfiguration config,
+    private static void setupBeanDeclaration(HierarchicalConfiguration config,
             String key, String[] names, String[] values)
     {
         for (int i = 0; i < names.length; i++)
@@ -525,7 +538,7 @@ public class TestXMLBeanDeclaration
      * @param names an array with the expected property names
      * @param values an array with the expected property values
      */
-    private void checkProperties(BeanDeclaration beanDecl, String[] names,
+    private static void checkProperties(BeanDeclaration beanDecl, String[] names,
             String[] values)
     {
         Map<String, Object> props = beanDecl.getBeanProperties();
@@ -545,8 +558,8 @@ public class TestXMLBeanDeclaration
      */
     private static class XMLBeanDeclarationTestImpl extends XMLBeanDeclaration
     {
-        public XMLBeanDeclarationTestImpl(SubnodeConfiguration config,
-                ConfigurationNode node)
+        public XMLBeanDeclarationTestImpl(HierarchicalConfiguration<?> config,
+                NodeData<?> node)
         {
             super(config, node);
         }



Mime
View raw message