You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2008/03/22 19:48:36 UTC

svn commit: r640050 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/beanutils/ test/java/org/apache/commons/configuration2/beanutils/

Author: oheger
Date: Sat Mar 22 11:48:35 2008
New Revision: 640050

URL: http://svn.apache.org/viewvc?rev=640050&view=rev
Log:
File-based hierarchical configurations are now derived from AbstractHierarchicalConfiguration

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

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java?rev=640050&r1=640049&r2=640050&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java Sat Mar 22 11:48:35 2008
@@ -20,11 +20,10 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.configuration2.HierarchicalConfiguration;
+import org.apache.commons.configuration2.AbstractHierarchicalConfiguration;
 import org.apache.commons.configuration2.PropertyConverter;
-import org.apache.commons.configuration2.SubnodeConfiguration;
-import org.apache.commons.configuration2.tree.ConfigurationNode;
-import org.apache.commons.configuration2.tree.DefaultConfigurationNode;
+import org.apache.commons.configuration2.SubConfiguration;
+import org.apache.commons.configuration2.expr.NodeHandler;
 
 /**
  * <p>
@@ -34,10 +33,10 @@
  * <p>
  * This class defines the standard layout of a bean declaration in an XML
  * configuration file. Such a declaration must look like the following example
- * fragement:
+ * fragment:
  * </p>
  * <p>
- *
+ * 
  * <pre>
  *   ...
  *   &lt;personBean config-class=&quot;my.model.PersonBean&quot;
@@ -47,7 +46,7 @@
  *           city=&quot;TestCity&quot;/&gt;
  *   &lt;/personBean&gt;
  * </pre>
- *
+ * 
  * </p>
  * <p>
  * The bean declaration can be contained in an arbitrary element. Here it is the
@@ -96,17 +95,18 @@
  * class are understood by the configuration, the default expression engine will
  * be set.
  * </p>
- *
+ * 
  * @since 1.3
  * @author Oliver Heger
  * @version $Id$
+ * @param <T> the type of the nodes the declaration deals with
  */
-public class XMLBeanDeclaration implements BeanDeclaration
+public class XMLBeanDeclaration<T> implements BeanDeclaration
 {
     /** Constant for the prefix of reserved attributes. */
     public static final String RESERVED_PREFIX = "config-";
 
-    /** Constant for the prefix for reserved attributes.*/
+    /** Constant for the prefix for reserved attributes. */
     public static final String ATTR_PREFIX = "[@" + RESERVED_PREFIX;
 
     /** Constant for the bean class attribute. */
@@ -120,22 +120,23 @@
             + "factoryParam]";
 
     /** Stores the associated configuration. */
-    private SubnodeConfiguration configuration;
+    private SubConfiguration<T> configuration;
 
     /** Stores the configuration node that contains the bean declaration. */
-    private ConfigurationNode node;
+    private T node;
 
     /**
      * Creates a new instance of <code>XMLBeanDeclaration</code> and
      * initializes it from the given configuration. The passed in key points to
      * the bean declaration.
-     *
+     * 
      * @param config the configuration
      * @param key the key to the bean declaration (this key must point to
-     * exactly one bean declaration or a <code>IllegalArgumentException</code>
-     * exception will be thrown)
+     *        exactly one bean declaration or a
+     *        <code>IllegalArgumentException</code> exception will be thrown)
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key)
+    public XMLBeanDeclaration(AbstractHierarchicalConfiguration<T> config,
+            String key)
     {
         this(config, key, false);
     }
@@ -149,15 +150,15 @@
      * declaration if a default class is provided. If the key on the other hand
      * has multiple values or is undefined and the boolean argument is <b>false</b>,
      * a <code>IllegalArgumentException</code> exception will be thrown.
-     *
+     * 
      * @param config the configuration
      * @param key the key to the bean declaration
      * @param optional a flag whether this declaration is optional; if set to
-     * <b>true</b>, no exception will be thrown if the passed in key is
-     * undefined
+     *        <b>true</b>, no exception will be thrown if the passed in key is
+     *        undefined
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key,
-            boolean optional)
+    public XMLBeanDeclaration(AbstractHierarchicalConfiguration<T> config,
+            String key, boolean optional)
     {
         if (config == null)
         {
@@ -178,7 +179,7 @@
                 throw iex;
             }
             configuration = config.configurationAt(null);
-            node = new DefaultConfigurationNode();
+            node = null;
         }
         initSubnodeConfiguration(getConfiguration());
     }
@@ -187,10 +188,10 @@
      * Creates a new instance of <code>XMLBeanDeclaration</code> and
      * initializes it from the given configuration. The configuration's root
      * node must contain the bean declaration.
-     *
+     * 
      * @param config the configuration with the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config)
+    public XMLBeanDeclaration(AbstractHierarchicalConfiguration<T> config)
     {
         this(config, (String) null);
     }
@@ -199,12 +200,11 @@
      * Creates a new instance of <code>XMLBeanDeclaration</code> and
      * initializes it with the configuration node that contains the bean
      * declaration.
-     *
+     * 
      * @param config the configuration
      * @param node the node with the bean declaration.
      */
-    public XMLBeanDeclaration(SubnodeConfiguration config,
-            ConfigurationNode node)
+    public XMLBeanDeclaration(SubConfiguration<T> config, T node)
     {
         if (config == null)
         {
@@ -223,20 +223,20 @@
 
     /**
      * Returns the configuration object this bean declaration is based on.
-     *
+     * 
      * @return the associated configuration
      */
-    public SubnodeConfiguration getConfiguration()
+    public SubConfiguration<T> getConfiguration()
     {
         return configuration;
     }
 
     /**
      * Returns the node that contains the bean declaration.
-     *
+     * 
      * @return the configuration node this bean declaration is based on
      */
-    public ConfigurationNode getNode()
+    public T getNode()
     {
         return node;
     }
@@ -244,7 +244,7 @@
     /**
      * Returns the name of the bean factory. This information is fetched from
      * the <code>config-factory</code> attribute.
-     *
+     * 
      * @return the name of the bean factory
      */
     public String getBeanFactoryName()
@@ -255,7 +255,7 @@
     /**
      * Returns a parameter for the bean factory. This information is fetched
      * from the <code>config-factoryParam</code> attribute.
-     *
+     * 
      * @return the parameter for the bean factory
      */
     public Object getBeanFactoryParameter()
@@ -266,7 +266,7 @@
     /**
      * Returns the name of the class of the bean to be created. This information
      * is obtained from the <code>config-class</code> attribute.
-     *
+     * 
      * @return the name of the bean's class
      */
     public String getBeanClassName()
@@ -277,17 +277,21 @@
     /**
      * Returns a map with the bean's (simple) properties. The properties are
      * collected from all attribute nodes, which are not reserved.
-     *
+     * 
      * @return a map with the bean's properties
      */
-    public Map getBeanProperties()
+    public Map<String, Object> getBeanProperties()
     {
         Map<String, Object> props = new HashMap<String, Object>();
-        for (ConfigurationNode attribute : getNode().getAttributes())
+        if (getNode() != null)
         {
-            if (!isReservedNode(attribute))
+            for (String attribute : getNodeHandler().getAttributes(getNode()))
             {
-                props.put(attribute.getName(), interpolate(attribute.getValue()));
+                if (!isReservedAttribute(getNode(), attribute))
+                {
+                    props.put(attribute, interpolate(getNodeHandler()
+                            .getAttributeValue(getNode(), attribute)));
+                }
             }
         }
 
@@ -298,17 +302,23 @@
      * Returns a map with bean declarations for the complex properties of the
      * bean to be created. These declarations are obtained from the child nodes
      * of this declaration's root node.
-     *
+     * 
      * @return a map with bean declarations for complex properties
      */
-    public Map getNestedBeanDeclarations()
+    public Map<String, BeanDeclaration> getNestedBeanDeclarations()
     {
-        Map<String, XMLBeanDeclaration> nested = new HashMap<String, XMLBeanDeclaration>();
-        for (ConfigurationNode child : getNode().getChildren())
+        Map<String, BeanDeclaration> nested = new HashMap<String, BeanDeclaration>();
+        if (getNode() != null)
         {
-            if (!isReservedNode(child))
+            for (T child : getNodeHandler().getChildren(getNode()))
             {
-                nested.put(child.getName(), new XMLBeanDeclaration(getConfiguration().configurationAt(child.getName()), child));
+                if (!isReservedNode(child))
+                {
+                    String nodeName = getNodeHandler().nodeName(child);
+                    nested.put(nodeName,
+                            new XMLBeanDeclaration<T>(getConfiguration()
+                                    .configurationAt(nodeName), child));
+                }
             }
         }
 
@@ -320,7 +330,7 @@
      * interpolate against the current subnode configuration's parent. If sub
      * classes need a different interpolation mechanism, they should override
      * this method.
-     *
+     * 
      * @param value the value that is to be interpolated
      * @return the interpolated value
      */
@@ -333,27 +343,55 @@
     /**
      * Checks if the specified node 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 given node is an
-     * attribute node and if its name starts with the reserved prefix.
-     *
+     * properties are collected. Per default there are no reserved nodes, so
+     * this implementation always returns <b>false</b>. Derived classes may
+     * change this.
+     * 
      * @param nd the node to be checked
      * @return a flag whether this node is reserved (and does not point to a
-     * property)
+     *         property)
      */
-    protected boolean isReservedNode(ConfigurationNode nd)
+    protected boolean isReservedNode(T nd)
     {
-        return nd.isAttribute()
-                && (nd.getName() == null || nd.getName().startsWith(
-                        RESERVED_PREFIX));
+        return false;
+    }
+
+    /**
+     * Checks if the specified 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
+     * attribute starts with the reserved prefix.
+     * 
+     * @param parent the node to which the attribute belongs
+     * @param name the name of the attribute in question
+     * @return a flag whether this attribute is reserved (and does not point to
+     *         a property)
+     * @since 2.0
+     */
+    protected boolean isReservedAttribute(T parent, String name)
+    {
+        return name == null || name.startsWith(RESERVED_PREFIX);
+    }
+
+    /**
+     * Convenience method for obtaining the node handler.
+     * 
+     * @return the node handler
+     * @since 2.0
+     */
+    protected NodeHandler<T> getNodeHandler()
+    {
+        return getConfiguration().getNodeHandler();
     }
 
     /**
      * Initializes the internally managed subnode 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(
+            AbstractHierarchicalConfiguration<T> conf)
     {
         conf.setThrowExceptionOnMissing(false);
         conf.setExpressionEngine(null);

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestXMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestXMLBeanDeclaration.java?rev=640050&r1=640049&r2=640050&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestXMLBeanDeclaration.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestXMLBeanDeclaration.java Sat Mar 22 11:48:35 2008
@@ -18,13 +18,11 @@
 
 import java.util.Map;
 
-import org.apache.commons.configuration2.HierarchicalConfiguration;
-import org.apache.commons.configuration2.beanutils.BeanDeclaration;
-import org.apache.commons.configuration2.beanutils.XMLBeanDeclaration;
-import org.apache.commons.configuration2.tree.ConfigurationNode;
-
 import junit.framework.TestCase;
 
+import org.apache.commons.configuration2.InMemoryConfiguration;
+import org.apache.commons.configuration2.tree.ConfigurationNode;
+
 /**
  * Test class for XMLBeanDeclaration.
  *
@@ -35,42 +33,42 @@
 public class TestXMLBeanDeclaration extends TestCase
 {
     /** An array with some test properties. */
-    static final String[] TEST_PROPS =
+    private static final String[] TEST_PROPS =
     { "firstName", "lastName", "department", "age", "hobby"};
 
     /** An array with the values for the test properties. */
-    static final String[] TEST_VALUES =
+    private static final String[] TEST_VALUES =
     { "John", "Smith", "Engineering", "42", "TV"};
 
     /** An array with the names of nested (complex) properties. */
-    static final String[] COMPLEX_PROPS =
+    private static final String[] COMPLEX_PROPS =
     { "address", "car"};
 
     /** An array with the names of the classes of the complex properties. */
-    static final String[] COMPLEX_CLASSES =
+    private static final String[] COMPLEX_CLASSES =
     { "org.apache.commons.configuration2.test.AddressTest",
             "org.apache.commons.configuration2.test.CarTest"};
 
     /** An array with the property names of the complex properties. */
-    static final String[][] COMPLEX_ATTRIBUTES =
+    private static final String[][] COMPLEX_ATTRIBUTES =
     {
     { "street", "zip", "city", "country"},
     { "brand", "color"}};
 
     /** An array with the values of the complex properties. */
-    static final String[][] COMPLEX_VALUES =
+    private static final String[][] COMPLEX_VALUES =
     {
     { "Baker Street", "12354", "London", "UK"},
     { "Bentley", "silver"}};
 
     /** Constant for the key with the bean declaration. */
-    static final String KEY = "myBean";
+    private static final String KEY = "myBean";
 
     /** Constant for the section with the variables.*/
-    static final String VARS = "variables.";
+    private static final String VARS = "variables.";
 
     /** Stores the object to be tested. */
-    XMLBeanDeclaration decl;
+    private XMLBeanDeclaration<ConfigurationNode> decl;
 
     /**
      * Tests creating a declaration from a null node. This should cause an
@@ -80,7 +78,8 @@
     {
         try
         {
-            decl = new XMLBeanDeclaration(new HierarchicalConfiguration().configurationAt(null),
+            decl = new XMLBeanDeclaration<ConfigurationNode>(
+                    new InMemoryConfiguration().configurationAt(null),
                     (ConfigurationNode) null);
             fail("Could init declaration with null node!");
         }
@@ -98,7 +97,7 @@
     {
         try
         {
-            decl = new XMLBeanDeclaration((HierarchicalConfiguration) null);
+            decl = new XMLBeanDeclaration<ConfigurationNode>((InMemoryConfiguration) null);
             fail("Could init declaration with null configuration!");
         }
         catch (IllegalArgumentException iex)
@@ -115,7 +114,7 @@
     {
         try
         {
-            decl = new XMLBeanDeclaration(null, KEY);
+            decl = new XMLBeanDeclaration<ConfigurationNode>(null, KEY);
             fail("Could init declaration with null configuration and key!");
         }
         catch (IllegalArgumentException iex)
@@ -132,7 +131,7 @@
     {
         try
         {
-            decl = new XMLBeanDeclaration(null, new HierarchicalConfiguration()
+            decl = new XMLBeanDeclaration<ConfigurationNode>(null, new InMemoryConfiguration()
                     .getRootNode());
             fail("Could init declaration with null configuration and node!");
         }
@@ -147,9 +146,9 @@
      */
     public void testGetBeanClassName()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         config.addProperty(KEY + "[@config-class]", getClass().getName());
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         assertEquals("Wrong class name", getClass().getName(), decl
                 .getBeanClassName());
     }
@@ -159,7 +158,7 @@
      */
     public void testGetBeanClassNameUndefined()
     {
-        decl = new XMLBeanDeclaration(new HierarchicalConfiguration());
+        decl = new XMLBeanDeclaration<ConfigurationNode>(new InMemoryConfiguration());
         assertNull(decl.getBeanClassName());
     }
 
@@ -168,9 +167,9 @@
      */
     public void testGetBeanFactoryName()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         config.addProperty(KEY + "[@config-factory]", "myFactory");
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         assertEquals("Wrong factory name", "myFactory", decl
                 .getBeanFactoryName());
     }
@@ -180,7 +179,7 @@
      */
     public void testGetBeanFactoryNameUndefined()
     {
-        decl = new XMLBeanDeclaration(new HierarchicalConfiguration());
+        decl = new XMLBeanDeclaration<ConfigurationNode>(new InMemoryConfiguration());
         assertNull(decl.getBeanFactoryName());
     }
 
@@ -189,11 +188,11 @@
      */
     public void testGetBeanFactoryParameter()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         config
                 .addProperty(KEY + "[@config-factoryParam]",
                         "myFactoryParameter");
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         assertEquals("Wrong factory parameter", "myFactoryParameter", decl
                 .getBeanFactoryParameter());
     }
@@ -203,7 +202,7 @@
      */
     public void testGetBeanFactoryParameterUndefined()
     {
-        decl = new XMLBeanDeclaration(new HierarchicalConfiguration());
+        decl = new XMLBeanDeclaration<ConfigurationNode>(new InMemoryConfiguration());
         assertNull(decl.getBeanFactoryParameter());
     }
 
@@ -213,9 +212,9 @@
      */
     public void testGetBeanProperties()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         checkProperties(decl, TEST_PROPS, TEST_VALUES);
     }
 
@@ -225,11 +224,11 @@
      */
     public void testGetBeanPropertiesWithReservedAttributes()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
         config.addProperty(KEY + "[@config-testattr]", "yes");
         config.addProperty(KEY + "[@config-anothertest]", "this, too");
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         checkProperties(decl, TEST_PROPS, TEST_VALUES);
     }
 
@@ -238,17 +237,18 @@
      */
     public void testGetBeanPropertiesEmpty()
     {
-        decl = new XMLBeanDeclaration(new HierarchicalConfiguration());
-        Map props = decl.getBeanProperties();
+        decl = new XMLBeanDeclaration<ConfigurationNode>(new InMemoryConfiguration());
+        Map<String, Object> props = decl.getBeanProperties();
         assertTrue("Properties found", props == null || props.isEmpty());
     }
 
     /**
      * Tests fetching nested bean declarations.
      */
+    @SuppressWarnings("unchecked")
     public void testGetNestedBeanDeclarations()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
         for (int i = 0; i < COMPLEX_PROPS.length; i++)
         {
@@ -259,15 +259,15 @@
                     COMPLEX_CLASSES[i]);
         }
 
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         checkProperties(decl, TEST_PROPS, TEST_VALUES);
 
-        Map nested = decl.getNestedBeanDeclarations();
+        Map<String, BeanDeclaration> nested = decl.getNestedBeanDeclarations();
         assertEquals("Wrong number of nested declarations",
                 COMPLEX_PROPS.length, nested.size());
         for (int i = 0; i < COMPLEX_PROPS.length; i++)
         {
-            XMLBeanDeclaration d = (XMLBeanDeclaration) nested
+            XMLBeanDeclaration<ConfigurationNode> d = (XMLBeanDeclaration<ConfigurationNode>) nested
                     .get(COMPLEX_PROPS[i]);
             assertNotNull("No declaration found for " + COMPLEX_PROPS[i], d);
             checkProperties(d, COMPLEX_ATTRIBUTES[i], COMPLEX_VALUES[i]);
@@ -281,10 +281,10 @@
      */
     public void testGetNestedBeanDeclarationsEmpty()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
-        decl = new XMLBeanDeclaration(config, KEY);
-        Map nested = decl.getNestedBeanDeclarations();
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
+        Map<String, BeanDeclaration> nested = decl.getNestedBeanDeclarations();
         assertTrue("Found nested declarations", nested == null
                 || nested.isEmpty());
     }
@@ -294,7 +294,7 @@
      */
     public void testGetInterpolatedBeanProperties()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         String[] varValues = new String[TEST_PROPS.length];
         for(int i = 0; i < TEST_PROPS.length; i++)
         {
@@ -302,7 +302,7 @@
             config.addProperty(VARS + TEST_PROPS[i], TEST_VALUES[i]);
         }
         setupBeanDeclaration(config, KEY, TEST_PROPS, varValues);
-        decl = new XMLBeanDeclaration(config, KEY);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
         checkProperties(decl, TEST_PROPS, TEST_VALUES);
     }
 
@@ -312,11 +312,11 @@
      */
     public void testInitFromUndefinedKey()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
         try
         {
-            decl = new XMLBeanDeclaration(config, "undefined_key");
+            decl = new XMLBeanDeclaration<ConfigurationNode>(config, "undefined_key");
             fail("Could create declaration from an undefined key!");
         }
         catch (IllegalArgumentException iex)
@@ -333,9 +333,9 @@
      */
     public void testInitFromUndefinedKeyOptional()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
-        decl = new XMLBeanDeclaration(config, "undefined_key", true);
+        decl = new XMLBeanDeclaration<ConfigurationNode>(config, "undefined_key", true);
         assertNull("Found a bean class", decl.getBeanClassName());
     }
 
@@ -345,12 +345,12 @@
      */
     public void testInitFromMultiValueKey()
     {
-        HierarchicalConfiguration config = new HierarchicalConfiguration();
+        InMemoryConfiguration config = new InMemoryConfiguration();
         config.addProperty(KEY, "myFirstKey");
         config.addProperty(KEY, "mySecondKey");
         try
         {
-            decl = new XMLBeanDeclaration(config, KEY);
+            decl = new XMLBeanDeclaration<ConfigurationNode>(config, KEY);
             fail("Could create declaration from multi-valued property!");
         }
         catch (IllegalArgumentException iex)
@@ -368,7 +368,7 @@
      * @param names an array with the names of the properties
      * @param values an array with the corresponding values
      */
-    private void setupBeanDeclaration(HierarchicalConfiguration config,
+    private void setupBeanDeclaration(InMemoryConfiguration config,
             String key, String[] names, String[] values)
     {
         for (int i = 0; i < names.length; i++)
@@ -387,7 +387,7 @@
     private void checkProperties(BeanDeclaration beanDecl, String[] names,
             String[] values)
     {
-        Map props = beanDecl.getBeanProperties();
+        Map<String, Object> props = beanDecl.getBeanProperties();
         assertEquals("Wrong number of properties", names.length, props.size());
         for (int i = 0; i < names.length; i++)
         {