ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data ConfigTestSetAndAdd.java ConfigTestEmpty.java ConfigTestIgnoreStringMethods.java ConfigTestSetAttribute.java ConfigTestSetElement.java ConfigTestTypedAdder.java ConfigTestUnknownReference.java
Date Tue, 19 Mar 2002 11:19:24 GMT
adammurdoch    02/03/19 03:19:24

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer
                        DefaultObjectConfigurer.java Resources.properties
               proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test
                        DefaultConfigurerTestCase.java
               proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data
                        ConfigTestEmpty.java
                        ConfigTestIgnoreStringMethods.java
                        ConfigTestSetAttribute.java
                        ConfigTestSetElement.java ConfigTestTypedAdder.java
                        ConfigTestUnknownReference.java
  Added:       proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data
                        ConfigTestSetAndAdd.java
  Log:
  Configurer changes:
  
  * Handle the case where a class has both a setFoo() and addFoo() method.
  
  * Ignore addContent( String ) if there is a non-String addContent() method.
  
  * Ignore add( String ) if there is a non-String add() method.
  
  * Added test cases for these.
  
  Revision  Changes    Path
  1.18      +144 -140  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultObjectConfigurer.java
  
  Index: DefaultObjectConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultObjectConfigurer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DefaultObjectConfigurer.java	16 Mar 2002 04:08:06 -0000	1.17
  +++ DefaultObjectConfigurer.java	19 Mar 2002 11:19:23 -0000	1.18
  @@ -10,11 +10,11 @@
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.ArrayList;
  -import java.util.Collection;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Collection;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -24,7 +24,7 @@
    * of a class.
    *
    * @author <a href="mailto:adammurdoch_ml@yahoo.com">Adam Murdoch</a>
  - * @version $Revision: 1.17 $ $Date: 2002/03/16 04:08:06 $
  + * @version $Revision: 1.18 $ $Date: 2002/03/19 11:19:23 $
    */
   class DefaultObjectConfigurer
       implements ObjectConfigurer
  @@ -35,7 +35,7 @@
       private final Class m_class;
   
       /**
  -     * All property configurers. (For XML elements)
  +     * Adder property configurers. (For XML elements)
        */
       private final HashMap m_adders = new HashMap();
   
  @@ -55,6 +55,11 @@
       private PropertyConfigurer m_contentConfigurer;
   
       /**
  +     * Total number of properties.
  +     */
  +    private int m_propCount;
  +
  +    /**
        * Creates an object configurer for a particular class.  The newly
        * created configurer will not handle any attributes, elements, or content.
        * Use the various <code>enable</code> methods to enable handling of these.
  @@ -70,97 +75,143 @@
       private void enableAll()
           throws ConfigurationException
       {
  -        enableProperties();
  +        enableSetters();
  +        enableAdders();
  +        enableTypedAdder();
           enableContent();
       }
   
       /**
  -     * Enables all adders.
  +     * Enables all setters.
        */
  -    private void enableProperties()
  +    private void enableSetters()
           throws ConfigurationException
       {
  -        final Map configurers = findPropertyConfigurers();
  +        // Locate all the setter methods
  +        final Collection methods = findMethods( "set", false );
   
  -        // Add the elements
  +        // Create a configurer for each setter
  +        final Iterator iterator = methods.iterator();
  +        while( iterator.hasNext() )
  +        {
  +            final Method method = (Method)iterator.next();
  +            final Class type = method.getParameterTypes()[ 0 ];
  +            final String propName = extractName( 3, method.getName() );
   
  -        final Iterator iterator = configurers.keySet().iterator();
  +            final DefaultPropertyConfigurer setter =
  +                new DefaultPropertyConfigurer( getPropertyCount(),
  +                                               type,
  +                                               method,
  +                                               1 );
  +            m_setters.put( propName, setter );
  +        }
  +    }
  +
  +    /**
  +     * Enables all adders.
  +     */
  +    private void enableAdders()
  +        throws ConfigurationException
  +    {
  +        // Locate all the adder methods
  +        final Collection methods = findMethods( "add", false );
  +
  +        final Iterator iterator = methods.iterator();
           while( iterator.hasNext() )
           {
  -            final String name = (String)iterator.next();
  -            final Method method = (Method)configurers.get( name );
  -            final boolean isSetter = method.getName().startsWith( "set" );
  +            final Method method = (Method)iterator.next();
  +            final String methodName = method.getName();
   
  -            // Determine and check the return type
  -            final Class type = method.getParameterTypes()[ 0 ];
  -            final boolean isTypedProp = ( name.length() == 0 );
  -            if( isTypedProp && !type.isInterface() )
  -            {
  -                final String message =
  -                    REZ.getString( "typed-adder-non-interface.error",
  -                                   m_class.getName(),
  -                                   type.getName() );
  -                throw new ConfigurationException( message );
  -            }
  -            else if( isTypedProp && isSetter )
  -            {
  -                final String message =
  -                    REZ.getString( "typed-setter-not-allowed.error",
  -                                   m_class.getName(),
  -                                   type.getName() );
  -                throw new ConfigurationException( message );
  -            }
  -            else if( isTypedProp && null != m_typedPropertyConfigurer )
  +            // Skip the text content method
  +            if( methodName.equals( "addContent" ) )
               {
  -                final String message =
  -                    REZ.getString( "typed-adder-duplicates.error",
  -                                   m_class.getName(),
  -                                   type.getName() );
  -                throw new ConfigurationException( message );
  +                continue;
               }
   
  -            // Determine the max count for the property
  -            if( isSetter )
  -            {
  -                final DefaultPropertyConfigurer setter =
  -                    new DefaultPropertyConfigurer( getPropertyCount(),
  -                                                   type,
  -                                                   method,
  -                                                   1 );
  -                m_setters.put( name, setter );
  -            }
  -            else
  -            {
  -                final DefaultPropertyConfigurer configurer =
  -                    new DefaultPropertyConfigurer( getPropertyCount(),
  -                                                   type,
  -                                                   method,
  -                                                   Integer.MAX_VALUE );
  -                if( isTypedProp )
  -                {
  -                    m_typedPropertyConfigurer = configurer;
  -                }
  -                else
  -                {
  -                    m_adders.put( name, configurer );
  -                }
  -            }
  +            final Class type = method.getParameterTypes()[ 0 ];
  +            final String propName = extractName( 3, methodName );
  +
  +            final DefaultPropertyConfigurer configurer =
  +                new DefaultPropertyConfigurer( getPropertyCount(),
  +                                               type,
  +                                               method,
  +                                               Integer.MAX_VALUE );
  +            m_adders.put( propName, configurer );
           }
       }
   
       /**
  -     * Locate all 'add' and 'set' methods which return void, and take a
  -     * single parameter.
  +     * Enables the typed adder.
        */
  -    private Map findPropertyConfigurers()
  +    private void enableTypedAdder()
           throws ConfigurationException
       {
  -        final Map adders = new HashMap();
  -        final List methodSet = new ArrayList();
  -        findMethodsWithPrefix( "add", methodSet );
  -        findMethodsWithPrefix( "set", methodSet );
  +        final Collection methods = findMethods( "add", true );
  +        if( methods.size() == 0 )
  +        {
  +            return;
  +        }
  +
  +        final Method method = (Method)methods.iterator().next();
  +        final Class type = method.getParameterTypes()[ 0 ];
  +
  +        // TODO - this isn't necessary
  +        if( !type.isInterface() )
  +        {
  +            final String message =
  +                REZ.getString( "typed-adder-non-interface.error",
  +                               m_class.getName(),
  +                               type.getName() );
  +            throw new ConfigurationException( message );
  +        }
  +
  +        m_typedPropertyConfigurer
  +            = new DefaultPropertyConfigurer( getPropertyCount(),
  +                                             type,
  +                                             method,
  +                                             Integer.MAX_VALUE );
  +    }
   
  -        final Iterator iterator = methodSet.iterator();
  +    /**
  +     * Enables text content.
  +     */
  +    private void enableContent()
  +        throws ConfigurationException
  +    {
  +        // Locate the 'addContent' methods, which return void, and take
  +        // a single parameter.
  +        final Collection methods = findMethods( "addContent", true );
  +        if( methods.size() == 0 )
  +        {
  +            return;
  +        }
  +
  +        final Method method = (Method)methods.iterator().next();
  +        final Class type = method.getParameterTypes()[ 0 ];
  +        m_contentConfigurer = new DefaultPropertyConfigurer( getPropertyCount(),
  +                                                             type,
  +                                                             method,
  +                                                             1 );
  +    }
  +
  +    /**
  +     * Locate all methods whose name starts with a particular
  +     * prefix, and which are non-static, return void, and take a single
  +     * parameter.  If there are more than one matching methods of a given
  +     * name, the method that takes a String parameter (if any) is ignored.
  +     * If after that there are more than one matching methods of a given
  +     * name, an exception is thrown.
  +     *
  +     * @return Map from property name -> Method object for that property.
  +     */
  +    private Collection findMethods( final String prefix,
  +                                    final boolean exactMatch )
  +        throws ConfigurationException
  +    {
  +        final Map methods = new HashMap();
  +        final List allMethods = findMethodsWithPrefix( prefix, exactMatch );
  +
  +        final Iterator iterator = allMethods.iterator();
           while( iterator.hasNext() )
           {
               final Method method = (Method)iterator.next();
  @@ -171,26 +222,13 @@
                   continue;
               }
   
  -            // Skip the text content method
  -            if( methodName.equals( "addContent" ) )
  -            {
  -                continue;
  -            }
  -
               // Extract property name
  -            final String propName = extractName( 3, methodName );
               final Class type = method.getParameterTypes()[ 0 ];
   
               // Add to the adders map
  -            if( adders.containsKey( propName ) )
  +            if( methods.containsKey( methodName ) )
               {
  -                final Method candidate = (Method)adders.get( propName );
  -                final String operation = methodName.substring( 0, 3 );
  -                if( !candidate.getName().startsWith( operation ) )
  -                {
  -                    continue;
  -                }
  -
  +                final Method candidate = (Method)methods.get( methodName );
                   final Class currentType = candidate.getParameterTypes()[ 0 ];
   
                   // Ditch the string version, if any
  @@ -202,70 +240,27 @@
                   }
                   else if( currentType != String.class || type == String.class )
                   {
  -                    // Both are string, or both are not string
  +                    // Both are string (which would be odd), or both are not string
                       final String message =
  -                        REZ.getString( "multiple-adder-methods-for-element.error",
  +                        REZ.getString( "multiple-methods-for-element.error",
                                          m_class.getName(),
  -                                       propName );
  +                                       methodName );
                       throw new ConfigurationException( message );
                   }
   
                   // Else, current type is string, and new type is not, so
  -                // continue below, and overwrite the current method
  +                // continue below, and replace the current method
               }
   
  -            adders.put( propName, method );
  +            methods.put( methodName, method );
           }
  -        return adders;
  -    }
   
  -    /**
  -     * Enables content.
  -     */
  -    private void enableContent()
  -        throws ConfigurationException
  -    {
  -        // TODO - should be using 'setContent', rather than 'addContent',
  -        // to better match the call-at-most-once semantics of the other
  -        // setter methods
  -
  -        // Locate any 'addContent' methods, which return void, and take
  -        // a single parameter.
  -        final Method[] methods = m_class.getMethods();
  -        for( int i = 0; i < methods.length; i++ )
  -        {
  -            final Method method = methods[ i ];
  -            final String methodName = method.getName();
  -            if( Modifier.isStatic( method.getModifiers() ) ||
  -                !methodName.equals( "addContent" ) ||
  -                method.getReturnType() != Void.TYPE ||
  -                method.getParameterTypes().length != 1 )
  -            {
  -                continue;
  -            }
  -
  -            // Check for multiple content setters
  -            if( null != m_contentConfigurer )
  -            {
  -                final String message =
  -                    REZ.getString( "multiple-content-setter-methods.error", m_class.getName()
);
  -                throw new ConfigurationException( message );
  -            }
  -
  -            final Class type = method.getParameterTypes()[ 0 ];
  -            m_contentConfigurer =
  -                new DefaultPropertyConfigurer( getPropertyCount(),
  -                                               type,
  -                                               method,
  -                                               1 );
  -        }
  +        return methods.values();
       }
   
       private int getPropertyCount()
       {
  -        final int typedSize = ( null != m_typedPropertyConfigurer ) ? 1 : 0;
  -        final int contentSize = ( null != m_contentConfigurer ) ? 1 : 0;
  -        return m_adders.size() + m_setters.size() + contentSize + typedSize;
  +        return m_propCount++;
       }
   
       /**
  @@ -369,22 +364,31 @@
        * Locates all non-static methods whose name starts with a particular
        * prefix.
        */
  -    private void findMethodsWithPrefix( final String prefix, final Collection matches )
  +    private List findMethodsWithPrefix( final String prefix,
  +                                        final boolean exactMatch )
       {
  +        final ArrayList matches = new ArrayList();
           final int prefixLen = prefix.length();
           final Method[] methods = m_class.getMethods();
           for( int i = 0; i < methods.length; i++ )
           {
               final Method method = methods[ i ];
               final String methodName = method.getName();
  -            if( Modifier.isStatic( method.getModifiers() ) ||
  -                methodName.length() < prefixLen ||
  -                !methodName.startsWith( prefix ) )
  +            if( Modifier.isStatic( method.getModifiers() ) )
  +            {
  +                continue;
  +            }
  +            if( methodName.length() < prefixLen || !methodName.startsWith( prefix )
)
  +            {
  +                continue;
  +            }
  +            if( exactMatch && methodName.length() != prefixLen )
               {
                   continue;
               }
   
               matches.add( method );
           }
  +        return matches;
       }
   }
  
  
  
  1.18      +2 -6      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Resources.properties	5 Mar 2002 14:46:05 -0000	1.17
  +++ Resources.properties	19 Mar 2002 11:19:23 -0000	1.18
  @@ -2,9 +2,7 @@
   extra-config-for-ref.error=A reference element can only include an "id" attribute.
   mismatch-ref-types.error=Could not convert reference "{0}" to the type expected for property
"{1}".
   incompatible-element-types.error=Incompatible creator and adder/setter methods found in
class {0} for property "{1}".
  -multiple-adder-methods-for-element.error=Multiple add{1}() or set{1}() methods found in
class {0}.
  -multiple-content-setter-methods.error=Multiple content setter methods found in class {0}.
  -pending-property-value.error=An object created using the creator method has not been set
using the adder/setter method.
  +multiple-methods-for-element.error=Multiple non-String {1}() methods found in class {0}.
   too-many-values.error=Too many values for this property.
   no-complex-type.error=Can not get complex type for non-primitive type {0}.
   no-such-attribute.error=Element <{0}> does not support attribute "{1}".
  @@ -16,6 +14,4 @@
   typed-adder-non-interface.error=The typed adder for class "{0}" must have a single parameter
that is an interface rather than {1} which defines a class.
   create-typed-object.error=Could not create an object of type "{0}" of class {1}.
   unknown-reference.error=Could not find referenced object "{0}".
  -bad-configure-element.error=Could not configure element <{0}>.
  -typed-setter-not-allowed.error=Not allowed to have "typed" setters as found in class {0}.
  -typed-adder-duplicates.error=Multiple typed adders found in class {0}.
  \ No newline at end of file
  +bad-configure-element.error=Could not configure element <{0}>.
  \ No newline at end of file
  
  
  
  1.2       +48 -14    jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java
  
  Index: DefaultConfigurerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultConfigurerTestCase.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ DefaultConfigurerTestCase.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -38,6 +38,7 @@
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderRole;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedConfigAdder;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestUnknownReference;
  +import org.apache.myrmidon.components.configurer.test.data.ConfigTestSetAndAdd;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.framework.DataType;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
  @@ -80,7 +81,7 @@
       }
   
       /**
  -     * Tests setting an attribute, via adder and setter methods.
  +     * Tests setting an attribute, via a setter method.
        */
       public void testSetAttribute()
           throws Exception
  @@ -89,8 +90,6 @@
           final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
           final String value1 = "some value";
           config.setAttribute( "some-prop", value1 );
  -        final String value2 = "some other value";
  -        config.setAttribute( "prop", value2 );
   
           final ConfigTestSetAttribute test = new ConfigTestSetAttribute();
   
  @@ -100,7 +99,6 @@
           // Check result
           final ConfigTestSetAttribute expected = new ConfigTestSetAttribute();
           expected.setSomeProp( value1 );
  -        expected.setProp( value2 );
           assertEquals( expected, test );
       }
   
  @@ -167,7 +165,7 @@
           final String value1 = "some value";
           child1.setAttribute( "some-prop", value1 );
           config.addChild( child1 );
  -        final DefaultConfiguration child2 = new DefaultConfiguration( "another-prop", "test"
);
  +        final DefaultConfiguration child2 = new DefaultConfiguration( "prop", "test" );
           final String value2 = "another value";
           child2.setAttribute( "some-prop", value2 );
           config.addChild( child2 );
  @@ -184,7 +182,7 @@
           expected.addProp( elem );
           elem = new ConfigTestSetElement();
           elem.setSomeProp( value2 );
  -        expected.addAnotherProp( elem );
  +        expected.addProp( elem );
           assertEquals( expected, test );
       }
   
  @@ -465,9 +463,9 @@
               final String[] messages = new String[]
               {
                   REZ.getString( "bad-configure-element.error", "test" ),
  -                REZ.getString( "multiple-adder-methods-for-element.error",
  +                REZ.getString( "multiple-methods-for-element.error",
                                  ConfigTestMultipleTypedAdder.class.getName(),
  -                               "" )
  +                               "add" )
               };
               assertSameMessage( messages, ce );
           }
  @@ -486,8 +484,9 @@
           config.addChild( child1 );
           config.addChild( child2 );
   
  -        registerType( DataType.ROLE, "my-type1", MyType1.class );
  -        registerType( DataType.ROLE, "my-type2", MyType2.class );
  +        registerRole( new RoleInfo( MyRole1.ROLE, "my-role1", MyRole1.class ) );
  +        registerType( MyRole1.ROLE, "my-type1", MyType1.class );
  +        registerType( MyRole1.ROLE, "my-type2", MyType2.class );
   
           final ConfigTestTypedAdder test = new ConfigTestTypedAdder();
   
  @@ -606,7 +605,7 @@
       /**
        * Tests to check that Configurable is handled properly.
        */
  -    public void testConfigable()
  +    public void testConfigurable()
           throws Exception
       {
           // Setup test data
  @@ -773,11 +772,17 @@
       {
           // Setup test data
           final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
  -        DefaultConfiguration elem = new DefaultConfiguration( "prop1", "test" );
  +        config.setAttribute( "prop1", "some-value" );
  +        config.setValue( "99" );
  +        DefaultConfiguration elem = new DefaultConfiguration( "prop2", "test" );
           config.addChild( elem );
  -        elem = new DefaultConfiguration( "prop2", "test" );
  +        elem = new DefaultConfiguration( "my-type1", "test" );
           config.addChild( elem );
   
  +        registerConverter( ObjectToMyRole1Converter.class, String.class, MyRole1.class
);
  +        registerConverter( StringToIntegerConverter.class, String.class, Integer.class
);
  +        registerType( DataType.ROLE, "my-type1", MyType1.class );
  +
           final ConfigTestIgnoreStringMethods test = new ConfigTestIgnoreStringMethods();
   
           // Configure the object
  @@ -785,8 +790,37 @@
   
           // Test expected value
           final ConfigTestIgnoreStringMethods expected = new ConfigTestIgnoreStringMethods();
  -        expected.addProp1( new ConfigTestIgnoreStringMethods() );
  +        expected.setProp1( new MyRole1Adaptor( "some-value" ) );
           expected.addProp2( new ConfigTestIgnoreStringMethods() );
  +        expected.add( new MyType1() );
  +        expected.addContent( 99 );
  +        assertEquals( expected, test );
  +    }
  +
  +    /**
  +     * Tests that a class with a setter and adder with the same property name
  +     * is handled correctly.
  +     */
  +    public void testSetAndAdd() throws Exception
  +    {
  +        // Setup test data
  +        final DefaultConfiguration config = new DefaultConfiguration( "test", "test" );
  +        config.setAttribute( "prop", "some value" );
  +        DefaultConfiguration elem = new DefaultConfiguration( "prop", "test" );
  +        elem.setAttribute( "prop", "another value" );
  +        config.addChild( elem );
  +
  +        final ConfigTestSetAndAdd test = new ConfigTestSetAndAdd();
  +
  +        // Configure the object
  +        configure( test, config );
  +
  +        // Test expected value
  +        final ConfigTestSetAndAdd expected = new ConfigTestSetAndAdd();
  +        expected.setProp( "some value" );
  +        final ConfigTestSetAndAdd nested = new ConfigTestSetAndAdd();
  +        nested.setProp( "another value" );
  +        expected.addProp( nested );
           assertEquals( expected, test );
       }
   
  
  
  
  1.2       +1 -3      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestEmpty.java
  
  Index: ConfigTestEmpty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestEmpty.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestEmpty.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestEmpty.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -7,12 +7,10 @@
    */
   package org.apache.myrmidon.components.configurer.test.data;
   
  -import java.util.ArrayList;
  -import java.util.List;
   import org.apache.myrmidon.framework.DataType;
   
   /**
  - * A simple test class with string properties.
  + * An empty class.
    *
    * @author Adam Murdoch
    */
  
  
  
  1.2       +44 -4     jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestIgnoreStringMethods.java
  
  Index: ConfigTestIgnoreStringMethods.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestIgnoreStringMethods.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestIgnoreStringMethods.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestIgnoreStringMethods.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -10,6 +10,7 @@
   import java.util.ArrayList;
   import junit.framework.AssertionFailedError;
   import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase;
  +import org.apache.myrmidon.components.configurer.test.MyRole1;
   
   /**
    * A test class with multiple setters/adders/creators for a property.
  @@ -18,8 +19,10 @@
    */
   public class ConfigTestIgnoreStringMethods
   {
  -    private ConfigTestIgnoreStringMethods m_prop1;
  +    private MyRole1 m_prop1;
       private ArrayList m_prop2 = new ArrayList();
  +    private int m_content;
  +    private ArrayList m_typed = new ArrayList();
   
       public boolean equals( Object obj )
       {
  @@ -32,19 +35,27 @@
           {
               return false;
           }
  +        if( m_content != test.m_content )
  +        {
  +            return false;
  +        }
  +        if( !m_typed.equals( test.m_typed ) )
  +        {
  +            return false;
  +        }
           return true;
       }
   
       //
  -    // Multiple setters
  +    // Multiple Setters
       //
   
  -    public void addProp1( final String value )
  +    public void setProp1( final String value )
       {
           throw new AssertionFailedError();
       }
   
  -    public void addProp1( final ConfigTestIgnoreStringMethods value )
  +    public void setProp1( final MyRole1 value )
       {
           m_prop1 = value;
       }
  @@ -62,4 +73,33 @@
       {
           m_prop2.add( value );
       }
  +
  +    //
  +    // Multiple typed adders
  +    //
  +
  +    public void add( final String value )
  +    {
  +        throw new AssertionFailedError();
  +    }
  +
  +    public void add( final MyRole1 value )
  +    {
  +        m_typed.add( value );
  +    }
  +
  +    //
  +    // Multiple content setters
  +    //
  +
  +    public void addContent( final int value )
  +    {
  +        m_content = value;
  +    }
  +
  +    public void addContent( final String value )
  +    {
  +        throw new AssertionFailedError();
  +    }
  +
   }
  
  
  
  1.2       +2 -12     jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAttribute.java
  
  Index: ConfigTestSetAttribute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAttribute.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestSetAttribute.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestSetAttribute.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -12,15 +12,14 @@
   import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase;
   
   /**
  - * Simple class to test typed adder.
  + * Simple class to test setter.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/17 08:07:08 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/19 11:19:24 $
    */
   public class ConfigTestSetAttribute
   {
       private String m_someProp;
  -    private List m_propList = new ArrayList();
   
       public boolean equals( final Object obj )
       {
  @@ -29,10 +28,6 @@
           {
               return false;
           }
  -        else if( !m_propList.equals( test.m_propList ) )
  -        {
  -            return false;
  -        }
           else
           {
               return true;
  @@ -42,10 +37,5 @@
       public void setSomeProp( final String value )
       {
           m_someProp = value;
  -    }
  -
  -    public void setProp( final String value )
  -    {
  -        m_propList.add( value );
       }
   }
  
  
  
  1.2       +1 -11     jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetElement.java
  
  Index: ConfigTestSetElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestSetElement.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestSetElement.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -18,18 +18,13 @@
    */
   public class ConfigTestSetElement
   {
  -    private ConfigTestSetElement m_prop;
       private List m_propList = new ArrayList();
       private String m_someProp;
   
       public boolean equals( Object obj )
       {
           ConfigTestSetElement test = (ConfigTestSetElement)obj;
  -        if( !DefaultConfigurerTestCase.equals( m_prop, test.m_prop ) )
  -        {
  -            return false;
  -        }
  -        else if( !m_propList.equals( test.m_propList ) )
  +        if( !m_propList.equals( test.m_propList ) )
           {
               return false;
           }
  @@ -46,11 +41,6 @@
       }
   
       public void addProp( final ConfigTestSetElement test )
  -    {
  -        m_prop = test;
  -    }
  -
  -    public void addAnotherProp( final ConfigTestSetElement test )
       {
           m_propList.add( test );
       }
  
  
  
  1.2       +1 -2      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdder.java
  
  Index: ConfigTestTypedAdder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestTypedAdder.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestTypedAdder.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -8,14 +8,13 @@
   package org.apache.myrmidon.components.configurer.test.data;
   
   import java.util.ArrayList;
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.components.configurer.test.MyRole1;
   
   /**
    * Simple class to test adder for Configurations.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/17 08:07:08 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/19 11:19:24 $
    */
   public class ConfigTestTypedAdder
   {
  
  
  
  1.2       +0 -3      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestUnknownReference.java
  
  Index: ConfigTestUnknownReference.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestUnknownReference.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestUnknownReference.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestUnknownReference.java	19 Mar 2002 11:19:24 -0000	1.2
  @@ -7,10 +7,7 @@
    */
   package org.apache.myrmidon.components.configurer.test.data;
   
  -import java.util.ArrayList;
  -import java.util.List;
   import org.apache.myrmidon.framework.DataType;
  -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase;
   
   /**
    * A simple test class with string properties.
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAndAdd.java
  
  Index: ConfigTestSetAndAdd.java
  ===================================================================
  /*
   * 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.test.data;
  
  import java.util.ArrayList;
  import org.apache.myrmidon.AbstractMyrmidonTest;
  
  /**
   * A test class with a setter and adder with the same property name.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/19 11:19:24 $
   */
  public class ConfigTestSetAndAdd
  {
      private String m_prop;
      private ArrayList m_nested = new ArrayList();
  
      public void setProp( final String prop )
      {
          m_prop = prop;
      }
  
      public void addProp( final ConfigTestSetAndAdd elem )
      {
          m_nested.add( elem );
      }
  
      public boolean equals( final Object obj )
      {
          ConfigTestSetAndAdd test = (ConfigTestSetAndAdd)obj;
          if( ! AbstractMyrmidonTest.equals( m_prop, test.m_prop) )
          {
              return false;
          }
          else if( ! m_nested.equals( test.m_nested ) )
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message