diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java
index 62d408838..d8882d26d 100644
--- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java
@@ -80,5 +80,4 @@ public class ConfigTest3
{
m_prop3.add( value );
}
-
}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java
new file mode 100644
index 000000000..b0b16f150
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+import java.util.ArrayList;
+import junit.framework.AssertionFailedError;
+
+/**
+ * Simple class to test typed adder.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public class ConfigTest4
+{
+ public void add( final Integer integer )
+ {
+ System.out.println( "This should not have been called as " +
+ "Integer is not an interface" );
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java
new file mode 100644
index 000000000..7d727acce
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+import java.util.ArrayList;
+import junit.framework.AssertionFailedError;
+import org.apache.avalon.framework.configuration.Configuration;
+
+/**
+ * Simple class to test typed adder.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public class ConfigTest5
+{
+ public void add( final MyRole1 role1 )
+ {
+ }
+
+ public void add( final MyRole2 role2 )
+ {
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
index 0d6c5f240..6501e9a44 100644
--- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
@@ -361,6 +361,57 @@ public class DefaultConfigurerTest
assertEquals( expected, test );
}
+ /**
+ * Tests reference resolution via a nested element.
+ */
+ public void testNonInterfaceTypedAdder()
+ throws Exception
+ {
+ // Setup test data
+ final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
+
+ final ConfigTest4 test = new ConfigTest4();
+
+ try
+ {
+ // Configure the object
+ m_configurer.configure( test, config, m_context );
+ }
+ catch( final ConfigurationException ce )
+ {
+ final String message = REZ.getString( "typed-adder-non-interface.error",
+ ConfigTest4.class.getName(),
+ Integer.class.getName() );
+ assertSameMessage( message, ce );
+ }
+ }
+
+ /**
+ * Tests whether a object with multiple typed adders causes an exception.
+ */
+ public void testMultipleTypedAdder()
+ throws Exception
+ {
+ // Setup test data
+ final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
+
+ final ConfigTest5 test = new ConfigTest5();
+
+ try
+ {
+ // Configure the object
+ m_configurer.configure( test, config, m_context );
+ }
+ catch( final ConfigurationException ce )
+ {
+ final String message = REZ.getString( "multiple-typed-adder-methods-for-element.error",
+ ConfigTest5.class.getName(),
+ MyRole1.class.getName(),
+ MyRole2.class.getName() );
+ assertSameMessage( message, ce );
+ }
+ }
+
/**
* Test resolving properties in an id.
*/
@@ -473,7 +524,8 @@ public class DefaultConfigurerTest
* Tests that string setter/adder/creators are ignored when there
* are multiple.
*/
- public void testIgnoreStringMethods() throws Exception
+ public void testIgnoreStringMethods()
+ throws Exception
{
// Setup test data
final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1.java
new file mode 100644
index 000000000..4e524204d
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+/**
+ * A basic interface to test configurer.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public interface MyRole1
+{
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole2.java
new file mode 100644
index 000000000..0b061d8b4
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole2.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+/**
+ * A basic interface to test configurer.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public interface MyRole2
+{
+}
diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java
index 62d408838..d8882d26d 100644
--- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java
+++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java
@@ -80,5 +80,4 @@ public class ConfigTest3
{
m_prop3.add( value );
}
-
}
diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java
new file mode 100644
index 000000000..b0b16f150
--- /dev/null
+++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+import java.util.ArrayList;
+import junit.framework.AssertionFailedError;
+
+/**
+ * Simple class to test typed adder.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public class ConfigTest4
+{
+ public void add( final Integer integer )
+ {
+ System.out.println( "This should not have been called as " +
+ "Integer is not an interface" );
+ }
+}
diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java
new file mode 100644
index 000000000..7d727acce
--- /dev/null
+++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+import java.util.ArrayList;
+import junit.framework.AssertionFailedError;
+import org.apache.avalon.framework.configuration.Configuration;
+
+/**
+ * Simple class to test typed adder.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public class ConfigTest5
+{
+ public void add( final MyRole1 role1 )
+ {
+ }
+
+ public void add( final MyRole2 role2 )
+ {
+ }
+}
diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
index 0d6c5f240..6501e9a44 100644
--- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
+++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
@@ -361,6 +361,57 @@ public class DefaultConfigurerTest
assertEquals( expected, test );
}
+ /**
+ * Tests reference resolution via a nested element.
+ */
+ public void testNonInterfaceTypedAdder()
+ throws Exception
+ {
+ // Setup test data
+ final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
+
+ final ConfigTest4 test = new ConfigTest4();
+
+ try
+ {
+ // Configure the object
+ m_configurer.configure( test, config, m_context );
+ }
+ catch( final ConfigurationException ce )
+ {
+ final String message = REZ.getString( "typed-adder-non-interface.error",
+ ConfigTest4.class.getName(),
+ Integer.class.getName() );
+ assertSameMessage( message, ce );
+ }
+ }
+
+ /**
+ * Tests whether a object with multiple typed adders causes an exception.
+ */
+ public void testMultipleTypedAdder()
+ throws Exception
+ {
+ // Setup test data
+ final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
+
+ final ConfigTest5 test = new ConfigTest5();
+
+ try
+ {
+ // Configure the object
+ m_configurer.configure( test, config, m_context );
+ }
+ catch( final ConfigurationException ce )
+ {
+ final String message = REZ.getString( "multiple-typed-adder-methods-for-element.error",
+ ConfigTest5.class.getName(),
+ MyRole1.class.getName(),
+ MyRole2.class.getName() );
+ assertSameMessage( message, ce );
+ }
+ }
+
/**
* Test resolving properties in an id.
*/
@@ -473,7 +524,8 @@ public class DefaultConfigurerTest
* Tests that string setter/adder/creators are ignored when there
* are multiple.
*/
- public void testIgnoreStringMethods() throws Exception
+ public void testIgnoreStringMethods()
+ throws Exception
{
// Setup test data
final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1.java
new file mode 100644
index 000000000..4e524204d
--- /dev/null
+++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+/**
+ * A basic interface to test configurer.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public interface MyRole1
+{
+}
diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole2.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole2.java
new file mode 100644
index 000000000..0b061d8b4
--- /dev/null
+++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole2.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.configurer;
+
+/**
+ * A basic interface to test configurer.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ */
+public interface MyRole2
+{
+}