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/framework/src/test/org/apache/myrmidon/framework DataTypeTestCase.java TestType.java data-type.ant
Date Sat, 18 May 2002 04:17:04 GMT
adammurdoch    02/05/17 21:17:04

  Modified:    container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               framework/src/test/org/apache/myrmidon
                        AbstractTaskTestCase.java
  Added:       framework/src/test/org/apache/myrmidon/framework
                        DataTypeTestCase.java TestType.java data-type.ant
  Log:
  Added a test for the DataType and TypeInstanceTask combo.
  
  Revision  Changes    Path
  1.38      +11 -5     jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- AbstractComponentTest.java	17 May 2002 07:43:47 -0000	1.37
  +++ AbstractComponentTest.java	18 May 2002 04:17:03 -0000	1.38
  @@ -47,6 +47,7 @@
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
   import org.apache.myrmidon.interfaces.library.LibraryManager;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
  @@ -58,7 +59,7 @@
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.37 $ $Date: 2002/05/17 07:43:47 $
  + * @version $Revision: 1.38 $ $Date: 2002/05/18 04:17:03 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -220,7 +221,7 @@
       protected TaskContext createContext()
           throws Exception
       {
  -        ExecutionFrame frame = createExecutionFrame();
  +        ExecutionFrame frame = createExecutionFrame( null );
   
           final TaskContext context =
               new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
  @@ -230,15 +231,20 @@
       /**
        * Utility method to create an execution frame.
        */
  -    protected ExecutionFrame createExecutionFrame() throws Exception
  +    protected ExecutionFrame createExecutionFrame( PropertyStore props )
  +        throws Exception
       {
           final ServiceManager serviceManager = getServiceManager();
           final TaskEventManager eventManager = (TaskEventManager)serviceManager.lookup(
TaskEventManager.ROLE );
   
  -        final DefaultPropertyStore store = new DefaultPropertyStore();
  +        if( props == null )
  +        {
  +            props = new DefaultPropertyStore();
  +        }
  +
           final File baseDir = getTestDirectory();
           final ExecutionFrame frame =
  -            new DefaultExecutionFrame( "", baseDir, getLogger(), store, serviceManager,
eventManager );
  +            new DefaultExecutionFrame( "", baseDir, getLogger(), props, serviceManager,
eventManager );
           return frame;
       }
   
  
  
  
  1.3       +19 -5     jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/AbstractTaskTestCase.java
  
  Index: AbstractTaskTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/AbstractTaskTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractTaskTestCase.java	17 May 2002 07:48:10 -0000	1.2
  +++ AbstractTaskTestCase.java	18 May 2002 04:17:04 -0000	1.3
  @@ -11,7 +11,7 @@
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.AbstractComponentTest;
  -import org.apache.myrmidon.components.builder.ModelElementUtil;
  +import org.apache.myrmidon.interfaces.model.ModelElementUtil;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
  @@ -19,13 +19,14 @@
   import org.apache.myrmidon.interfaces.library.LibraryManager;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.avalon.framework.ExceptionUtil;
   
   /**
    * A base class for test cases which need to execute tasks.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/17 07:48:10 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/18 04:17:04 $
    *
    * @todo - Move the guts of AbstractProjectTestCase back to this class,
    *         and add a specialised project builder.
  @@ -74,7 +75,7 @@
       protected void executeTarget( final File projectFile, final String targetName )
           throws Exception
       {
  -        executeTarget( projectFile, targetName, null );
  +        executeTarget( projectFile, targetName, null, null );
       }
   
       /**
  @@ -82,6 +83,18 @@
        */
       protected void executeTarget( final File projectFile,
                                     final String targetName,
  +                                  final PropertyStore props )
  +        throws Exception
  +    {
  +        executeTarget( projectFile, targetName, props, null );
  +    }
  +
  +    /**
  +     * Executes a target in a project, and asserts that it does not fail.
  +     */
  +    protected void executeTarget( final File projectFile,
  +                                  final String targetName,
  +                                  final PropertyStore props,
                                     final TaskListener listener )
           throws Exception
       {
  @@ -101,7 +114,7 @@
               {
                   try
                   {
  -                    executeTarget( target, listener );
  +                    executeTarget( target, props, listener );
                       return;
                   }
                   catch( Exception e )
  @@ -120,6 +133,7 @@
        * Executes a target.
        */
       private void executeTarget( final ModelElement target,
  +                                final PropertyStore props,
                                   final TaskListener listener )
           throws Exception
       {
  @@ -132,7 +146,7 @@
   
           final TaskEventManager eventManager = (TaskEventManager)getServiceManager().lookup(
TaskEventManager.ROLE );
           final Executor executor = (Executor)getServiceManager().lookup( Executor.ROLE );
  -        final ExecutionFrame frame = createExecutionFrame();
  +        final ExecutionFrame frame = createExecutionFrame( props );
   
           // Install listener
           if( listener != null )
  
  
  
  1.1                  jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/DataTypeTestCase.java
  
  Index: DataTypeTestCase.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.framework;
  
  import org.apache.myrmidon.AbstractTaskTestCase;
  import org.apache.myrmidon.components.property.DefaultPropertyStore;
  import java.io.File;
  
  /**
   * Test cases for the data-type role and TypeInstanceTask.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/18 04:17:04 $
   */
  public class DataTypeTestCase
      extends AbstractTaskTestCase
  {
      public DataTypeTestCase( final String name )
      {
          super( name );
      }
  
      /**
       * Tests that a data-type is correctly deployed as an instantiating task.
       */
      public void testDeploy() throws Exception
      {
          final File projectFile = getTestResource( "data-type.ant" );
          final DefaultPropertyStore props = new DefaultPropertyStore();
          executeTarget( projectFile, "type-instance-task", props );
  
          final Object obj = props.getProperty( "test-prop" );
  
          final TestType expected = new TestType();
          expected.setProp1( "some value" );
  
          assertEquals( expected, obj );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/TestType.java
  
  Index: TestType.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.framework;
  
  import org.apache.aut.AbstractAutTestCase;
  
  /**
   * A test data-type.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/18 04:17:04 $
   *
   * @ant.data-type name="test-type"
   */
  public class TestType implements DataType
  {
      private String m_prop1;
  
      public void setProp1( final String prop1 )
      {
          m_prop1 = prop1;
      }
  
      public boolean equals( final Object obj )
      {
          final TestType test = (TestType)obj;
          if( !AbstractAutTestCase.equals( m_prop1, test.m_prop1 ) )
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/data-type.ant
  
  Index: data-type.ant
  ===================================================================
  <project>
      <target name="type-instance-task">
          <test-type id="test-prop" prop1="some value"/>
      </target>
  </project>
  
  

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