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-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data ConfigTestContent.java ConfigTestIdResolve.java ConfigTestReferenceAttribute.java ConfigTestMismatchedRefType.java ConfigTestNonInterfaceAdder.java ConfigTestUnknownReference.java
Date Tue, 23 Apr 2002 06:24:20 GMT
adammurdoch    02/04/22 23:24:20

  Modified:    container/src/test/org/apache/myrmidon/components/configurer/test
                        DefaultConfigurerTestCase.java
               container/src/test/org/apache/myrmidon/components/configurer/test/data
                        ConfigTestContent.java ConfigTestIdResolve.java
                        ConfigTestReferenceAttribute.java
  Added:       container/src/test/org/apache/myrmidon/components/configurer/test
                        ConfigTestModeller.java
  Removed:     container/src/test/org/apache/myrmidon/components/configurer/test
                        ConfigTestConfigurable.java
               container/src/test/org/apache/myrmidon/components/configurer/test/data
                        ConfigTestMismatchedRefType.java
                        ConfigTestNonInterfaceAdder.java
                        ConfigTestUnknownReference.java
  Log:
  Get configurer tests working.  Resurrected some of the attribute-by-reference tests,
  axed some others.
  
  Revision  Changes    Path
  1.10      +19 -172   jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java
  
  Index: DefaultConfigurerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultConfigurerTestCase.java	21 Apr 2002 02:41:23 -0000	1.9
  +++ DefaultConfigurerTestCase.java	23 Apr 2002 06:24:19 -0000	1.10
  @@ -21,13 +21,10 @@
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestConfigAdder;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestContent;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestEmpty;
  -import org.apache.myrmidon.components.configurer.test.data.ConfigTestIdResolve;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestIgnoreStringMethods;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestInterfaceAdder;
  -import org.apache.myrmidon.components.configurer.test.data.ConfigTestMismatchedRefType;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestMultipleTypedAdder;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestNestedErrors;
  -import org.apache.myrmidon.components.configurer.test.data.ConfigTestNonInterfaceAdder;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestPropResolution;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestReferenceAttribute;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestReferenceConversion;
  @@ -40,7 +37,6 @@
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderReference;
   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.workspace.DefaultTaskContext;
   import org.apache.myrmidon.components.TestDataType;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
  @@ -310,29 +306,20 @@
       {
           // Setup test data
           final ModelElement config = new ModelElement( "test", "test" );
  -        config.setAttribute( "some-prop-ref", "prop-a" );
  +        config.setAttribute( "some-prop", "${prop-a}" );
   
           final ConfigTestReferenceAttribute test = new ConfigTestReferenceAttribute();
   
  -        m_context.setProperty( "prop-a", "some value" );
  +        final Integer value = new Integer( 12 );
  +        m_context.setProperty( "prop-a", value );
   
           // Configure the object
  -        try
  -        {
  -            configure( test, config );
  -        }
  -        catch( ModelException e )
  -        {
  -            //Expected to fail as -ref no longer supported
  -            //pattern for attributes
  -            return;
  -        }
  +        configure( test, config );
   
  -        fail( "-ref pattern on attributes no longer supported" );
           // Check the configured object
  -        //final ConfigTestReferenceAttribute expected = new ConfigTestReferenceAttribute();
  -        //expected.setSomeProp( "some value" );
  -        //assertEquals( expected, test );
  +        final ConfigTestReferenceAttribute expected = new ConfigTestReferenceAttribute();
  +        expected.setSomeProp( value );
  +        assertEquals( expected, test );
       }
   
       /**
  @@ -398,7 +385,7 @@
       {
           // Setup test data
           final ModelElement config = new ModelElement( "test", "test" );
  -        config.setAttribute( "prop-a-ref", "id" );
  +        config.setAttribute( "prop-a", "${id}" );
   
           final Integer refValue = new Integer( 21 );
           m_context.setProperty( "id", refValue );
  @@ -408,22 +395,12 @@
           final ConfigTestReferenceConversion test = new ConfigTestReferenceConversion();
   
           // Configure
  -        try
  -        {
  -            configure( test, config );
  -        }
  -        catch( ModelException e )
  -        {
  -            //Good should no longer work
  -            return;
  -        }
  -
  -        fail( "-ref pattern on attributes no longer supported" );
  +        configure( test, config );
   
           // Check result
  -        //final ConfigTestReferenceConversion expected = new ConfigTestReferenceConversion();
  -        //expected.setPropA( new MyRole1Adaptor( refValue ) );
  -        //assertEquals( expected, test );
  +        final ConfigTestReferenceConversion expected = new ConfigTestReferenceConversion();
  +        expected.setPropA( new MyRole1Adaptor( refValue ) );
  +        assertEquals( expected, test );
       }
   
       /**
  @@ -453,36 +430,6 @@
       }
   
       /**
  -     * Tests whether an object with a non-iterface typed adder causes an
  -     * exception.
  -     */
  -    public void testNonInterfaceTypedAdder()
  -        throws Exception
  -    {
  -        // Setup test data
  -        final ModelElement config = new ModelElement( "test", "test" );
  -
  -        final ConfigTestNonInterfaceAdder test = new ConfigTestNonInterfaceAdder();
  -
  -        try
  -        {
  -            // Configure the object
  -            m_configurer.configureElement( test, config, m_context );
  -            fail();
  -        }
  -        catch( final ModelException ce )
  -        {
  -            final String[] messages = {
  -                REZ.getString( "bad-configure-element.error", "test" ),
  -                REZ.getString( "typed-adder-non-interface.error",
  -                               ConfigTestNonInterfaceAdder.class.getName(),
  -                               Integer.class.getName() )
  -            };
  -            assertSameMessage( messages, ce );
  -        }
  -    }
  -
  -    /**
        * Tests whether an object with multiple typed adders causes an exception.
        */
       public void testMultipleTypedAdder()
  @@ -646,125 +593,25 @@
       }
   
       /**
  -     * Tests to check that Configurable is handled properly.
  +     * Tests to check that Modeller is handled properly.
        */
  -    public void testConfigurable()
  +    public void testModeller()
           throws Exception
       {
           // Setup test data
           final ModelElement config = new ModelElement( "test", "test" );
   
  -        final ConfigTestConfigurable test = new ConfigTestConfigurable();
  +        final ConfigTestModeller test = new ConfigTestModeller();
   
           // Configure the object
           m_configurer.configureElement( test, config, m_context );
   
  -        final ConfigTestConfigurable expected = new ConfigTestConfigurable();
  +        final ConfigTestModeller expected = new ConfigTestModeller();
           expected.model( config );
           assertEquals( expected, test );
       }
   
       /**
  -     * Test resolving properties in an id.
  -     */
  -    public void testIdResolve()
  -        throws Exception
  -    {
  -        // Setup test data
  -        final ModelElement config = new ModelElement( "test", "test" );
  -        config.setAttribute( "some-prop-ref", "${id}" );
  -
  -        final ConfigTestIdResolve test = new ConfigTestIdResolve();
  -
  -        m_context.setProperty( "id", "prop-a" );
  -        m_context.setProperty( "prop-a", "some indirect value" );
  -
  -        // Configure the object
  -        try
  -        {
  -            configure( test, config );
  -        }
  -        catch( ModelException e )
  -        {
  -            return;
  -        }
  -
  -        fail( "-ref pattern on attributes no longer supported" );
  -        // Check the configured object
  -        //final ConfigTestIdResolve expected = new ConfigTestIdResolve();
  -        //expected.setSomeProp( "some indirect value" );
  -        //assertEquals( expected, test );
  -    }
  -
  -    /**
  -     * Tests an unknown reference.
  -     */
  -    public void __testUnknownReference()
  -        throws Exception
  -    {
  -        //Should rework
  -        fail( "-ref pattern on attributes no longer supported" );
  -
  -        // Setup test data
  -        final ModelElement config = new ModelElement( "test", "test" );
  -        config.setAttribute( "some-prop-ref", "unknown-prop" );
  -
  -        final ConfigTestUnknownReference test = new ConfigTestUnknownReference();
  -
  -        // Configure the object
  -        try
  -        {
  -            m_configurer.configureElement( test, config, m_context );
  -            fail();
  -        }
  -        catch( ModelException e )
  -        {
  -            final String[] messages = new String[]
  -            {
  -                REZ.getString( "bad-set-attribute.error", "test", "some-prop-ref" ),
  -                REZ.getString( "unknown-reference.error", "unknown-prop" )
  -            };
  -            assertSameMessage( messages, e );
  -        }
  -    }
  -
  -    /**
  -     * Tests handling of mismatched reference type.
  -     */
  -    public void __testMismatchedRefType()
  -        throws Exception
  -    {
  -        //FIXME: rework testcase
  -        fail( "-ref pattern on attributes no longer supported" );
  -
  -        // Setup test data
  -        final ModelElement config = new ModelElement( "test", "test" );
  -        config.setAttribute( "some-prop-ref", "prop-a" );
  -
  -        final ConfigTestMismatchedRefType test = new ConfigTestMismatchedRefType();
  -
  -        m_context.setProperty( "prop-a", new Integer( 23 ) );
  -
  -        // Configure the object
  -        try
  -        {
  -            m_configurer.configureElement( test, config, m_context );
  -            fail();
  -        }
  -        catch( ModelException e )
  -        {
  -            final String[] messages = new String[]
  -            {
  -                REZ.getString( "bad-set-attribute.error", "test", "some-prop-ref" ),
  -                REZ.getString( "mismatch-ref-types.error",
  -                               "prop-a",
  -                               "some-prop" )
  -            };
  -            assertSameMessage( messages, e );
  -        }
  -    }
  -
  -    /**
        * Tests using a reference with a typed adder.  Tests using an attribute
        * and a nested element.
        */
  @@ -884,15 +731,15 @@
   
       private void configure( final Object test,
                               final ModelElement config )
  -        throws ModelException
  +        throws Exception
       {
           try
           {
               m_configurer.configureElement( test, config, m_context );
           }
  -        catch( final ModelException ce )
  +        catch( final Exception ce )
           {
  -            ExceptionUtil.printStackTrace( ce );
  +            getLogger().error( ExceptionUtil.printStackTrace( ce, 10, true, true ) );
               throw ce;
           }
       }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/ConfigTestModeller.java
  
  Index: ConfigTestModeller.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;
  
  import org.apache.myrmidon.api.metadata.ModelElement;
  import org.apache.myrmidon.api.metadata.ModelException;
  import org.apache.myrmidon.api.metadata.Modeller;
  
  /**
   * Simple class to test {@link org.apache.avalon.framework.configuration.Configurable}.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/23 06:24:19 $
   */
  public class ConfigTestModeller
      implements Modeller
  {
      private ModelElement m_model;
  
      public void model( final ModelElement model )
          throws ModelException
      {
          m_model = model;
      }
  
      public boolean equals( final Object object )
      {
          final ConfigTestModeller other = (ConfigTestModeller)object;
          return m_model == other.m_model;
      }
  }
  
  
  
  1.3       +0 -2      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestContent.java
  
  Index: ConfigTestContent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestContent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConfigTestContent.java	11 Apr 2002 12:58:58 -0000	1.2
  +++ ConfigTestContent.java	23 Apr 2002 06:24:19 -0000	1.3
  @@ -7,8 +7,6 @@
    */
   package org.apache.myrmidon.components.configurer.test.data;
   
  -import java.util.ArrayList;
  -import java.util.List;
   import org.apache.myrmidon.components.TestDataType;
   import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase;
   
  
  
  
  1.3       +0 -2      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIdResolve.java
  
  Index: ConfigTestIdResolve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIdResolve.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConfigTestIdResolve.java	11 Apr 2002 12:58:58 -0000	1.2
  +++ ConfigTestIdResolve.java	23 Apr 2002 06:24:19 -0000	1.3
  @@ -7,8 +7,6 @@
    */
   package org.apache.myrmidon.components.configurer.test.data;
   
  -import java.util.ArrayList;
  -import java.util.List;
   import org.apache.myrmidon.components.TestDataType;
   import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase;
   
  
  
  
  1.2       +4 -15     jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceAttribute.java
  
  Index: ConfigTestReferenceAttribute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceAttribute.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigTestReferenceAttribute.java	17 Mar 2002 08:07:08 -0000	1.1
  +++ ConfigTestReferenceAttribute.java	23 Apr 2002 06:24:20 -0000	1.2
  @@ -7,34 +7,23 @@
    */
   package org.apache.myrmidon.components.configurer.test.data;
   
  -import java.util.List;
  -import java.util.ArrayList;
  -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase;
  -
   /**
    * Simple class to test typed adder.
    *
    * @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/04/23 06:24:20 $
    */
   public class ConfigTestReferenceAttribute
   {
  -    private String m_someProp;
  +    private Integer m_someProp;
   
       public boolean equals( final Object obj )
       {
           final ConfigTestReferenceAttribute test = (ConfigTestReferenceAttribute)obj;
  -        if( !DefaultConfigurerTestCase.equals( m_someProp, test.m_someProp ) )
  -        {
  -            return false;
  -        }
  -        else
  -        {
  -            return true;
  -        }
  +        return m_someProp == test.m_someProp;
       }
   
  -    public void setSomeProp( final String value )
  +    public void setSomeProp( final Integer value )
       {
           m_someProp = value;
       }
  
  
  

--
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