Browse Source

Add some more tests to check recently added features of Configurer

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270974 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
a99711a13e
12 changed files with 288 additions and 4 deletions
  1. +0
    -1
      proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java
  2. +26
    -0
      proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java
  3. +29
    -0
      proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java
  4. +53
    -1
      proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
  5. +18
    -0
      proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1.java
  6. +18
    -0
      proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole2.java
  7. +0
    -1
      proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java
  8. +26
    -0
      proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java
  9. +29
    -0
      proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java
  10. +53
    -1
      proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
  11. +18
    -0
      proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1.java
  12. +18
    -0
      proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole2.java

+ 0
- 1
proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java View File

@@ -80,5 +80,4 @@ public class ConfigTest3
{
m_prop3.add( value );
}

}

+ 26
- 0
proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java View File

@@ -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" );
}
}

+ 29
- 0
proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java View File

@@ -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 )
{
}
}

+ 53
- 1
proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java View File

@@ -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" );


+ 18
- 0
proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1.java View File

@@ -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
{
}

+ 18
- 0
proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole2.java View File

@@ -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
{
}

+ 0
- 1
proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java View File

@@ -80,5 +80,4 @@ public class ConfigTest3
{
m_prop3.add( value );
}

}

+ 26
- 0
proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java View File

@@ -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" );
}
}

+ 29
- 0
proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java View File

@@ -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 )
{
}
}

+ 53
- 1
proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java View File

@@ -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" );


+ 18
- 0
proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1.java View File

@@ -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
{
}

+ 18
- 0
proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole2.java View File

@@ -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
{
}

Loading…
Cancel
Save