git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270974 13f79535-47bb-0310-9956-ffa450edef68master
@@ -80,5 +80,4 @@ public class ConfigTest3 | |||||
{ | { | ||||
m_prop3.add( value ); | m_prop3.add( value ); | ||||
} | } | ||||
} | } |
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @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" ); | |||||
} | |||||
} |
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @version $Revision$ $Date$ | |||||
*/ | |||||
public class ConfigTest5 | |||||
{ | |||||
public void add( final MyRole1 role1 ) | |||||
{ | |||||
} | |||||
public void add( final MyRole2 role2 ) | |||||
{ | |||||
} | |||||
} |
@@ -361,6 +361,57 @@ public class DefaultConfigurerTest | |||||
assertEquals( expected, test ); | 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. | * Test resolving properties in an id. | ||||
*/ | */ | ||||
@@ -473,7 +524,8 @@ public class DefaultConfigurerTest | |||||
* Tests that string setter/adder/creators are ignored when there | * Tests that string setter/adder/creators are ignored when there | ||||
* are multiple. | * are multiple. | ||||
*/ | */ | ||||
public void testIgnoreStringMethods() throws Exception | |||||
public void testIgnoreStringMethods() | |||||
throws Exception | |||||
{ | { | ||||
// Setup test data | // Setup test data | ||||
final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); | final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); | ||||
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @version $Revision$ $Date$ | |||||
*/ | |||||
public interface MyRole1 | |||||
{ | |||||
} |
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @version $Revision$ $Date$ | |||||
*/ | |||||
public interface MyRole2 | |||||
{ | |||||
} |
@@ -80,5 +80,4 @@ public class ConfigTest3 | |||||
{ | { | ||||
m_prop3.add( value ); | m_prop3.add( value ); | ||||
} | } | ||||
} | } |
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @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" ); | |||||
} | |||||
} |
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @version $Revision$ $Date$ | |||||
*/ | |||||
public class ConfigTest5 | |||||
{ | |||||
public void add( final MyRole1 role1 ) | |||||
{ | |||||
} | |||||
public void add( final MyRole2 role2 ) | |||||
{ | |||||
} | |||||
} |
@@ -361,6 +361,57 @@ public class DefaultConfigurerTest | |||||
assertEquals( expected, test ); | 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. | * Test resolving properties in an id. | ||||
*/ | */ | ||||
@@ -473,7 +524,8 @@ public class DefaultConfigurerTest | |||||
* Tests that string setter/adder/creators are ignored when there | * Tests that string setter/adder/creators are ignored when there | ||||
* are multiple. | * are multiple. | ||||
*/ | */ | ||||
public void testIgnoreStringMethods() throws Exception | |||||
public void testIgnoreStringMethods() | |||||
throws Exception | |||||
{ | { | ||||
// Setup test data | // Setup test data | ||||
final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); | final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); | ||||
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @version $Revision$ $Date$ | |||||
*/ | |||||
public interface MyRole1 | |||||
{ | |||||
} |
@@ -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 <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
* @version $Revision$ $Date$ | |||||
*/ | |||||
public interface MyRole2 | |||||
{ | |||||
} |