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/file/test PathTestCase.java
Date Tue, 04 Jun 2002 12:44:55 GMT
adammurdoch    2002/06/04 05:44:55

  Modified:    framework/src/test/org/apache/myrmidon/framework
                        DataTypeTestCase.java data-type.ant
               framework/src/test/org/apache/myrmidon/framework/conditions/test
                        IsSetConditionTestCase.java
                        IsTrueConditionTestCase.java
               framework/src/test/org/apache/myrmidon/framework/file/test
                        PathTestCase.java
  Added:       framework/src/test/org/apache/myrmidon/framework
                        AssertTask.java
  Removed:     framework/src/test/org/apache/myrmidon/framework/conditions/test
                        ConditionTestTask.java
  Log:
  * Reimplemented AbstractTaskTestCase so that it uses EmbeddedAnt
    and a simplified project builder.
  
  * Moved the <assert> test task, so that it can be used by any of
    the unit tests.
  
  Revision  Changes    Path
  1.3       +7 -9      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/DataTypeTestCase.java
  
  Index: DataTypeTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/DataTypeTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DataTypeTestCase.java	29 May 2002 06:42:26 -0000	1.2
  +++ DataTypeTestCase.java	4 Jun 2002 12:44:54 -0000	1.3
  @@ -8,14 +8,15 @@
   package org.apache.myrmidon.framework;
   
   import java.io.File;
  +import java.util.HashMap;
  +import java.util.Map;
   import org.apache.myrmidon.AbstractTaskTestCase;
  -import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * Test cases for the data-type role and TypeInstanceTask.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/29 06:42:26 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/04 12:44:54 $
    */
   public class DataTypeTestCase
       extends AbstractTaskTestCase
  @@ -30,15 +31,12 @@
        */
       public void testDeploy() throws Exception
       {
  -        final File projectFile = getTestResource( "data-type.ant" );
  -        final PropertyStore props = createPropertyStore();
  -        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 );
  +        final File projectFile = getTestResource( "data-type.ant" );
  +        final Map props = new HashMap();
  +        props.put( "expected-prop", expected );
  +        executeTarget( projectFile, "type-instance-task", props );
       }
   }
  
  
  
  1.2       +4 -1      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/data-type.ant
  
  Index: data-type.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/data-type.ant,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- data-type.ant	18 May 2002 04:17:04 -0000	1.1
  +++ data-type.ant	4 Jun 2002 12:44:54 -0000	1.2
  @@ -1,5 +1,8 @@
  -<project>
  +<project version="2.0">
       <target name="type-instance-task">
           <test-type id="test-prop" prop1="some value"/>
  +        <assert>
  +            <equals arg1="${expected-prop}" arg2="${test-prop}"/>
  +        </assert>
       </target>
   </project>
  
  
  
  1.1                  jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/AssertTask.java
  
  Index: AssertTask.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.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.conditions.Condition;
  
  /**
   * A simple assert task.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 12:44:54 $
   *
   * @ant.task name="assert"
   */
  public class AssertTask
      extends AbstractTask
  {
      private boolean m_expected = true;
      private Condition m_condition;
  
      public void setExpected( final boolean expected )
      {
          m_expected = expected;
      }
  
      public void add( final Condition condition )
      {
          m_condition = condition;
      }
  
      /**
       * Execute task.
       */
      public void execute()
          throws TaskException
      {
          if( m_condition == null )
          {
              throw new TaskException( "No condition specified." );
          }
  
          final boolean result = m_condition.evaluate( getContext() );
          if( result != m_expected )
          {
              throw new TaskException( "Expected " + m_expected + ", got " + result );
          }
      }
  }
  
  
  
  1.3       +1 -2      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/conditions/test/IsSetConditionTestCase.java
  
  Index: IsSetConditionTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/conditions/test/IsSetConditionTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IsSetConditionTestCase.java	11 May 2002 12:44:01 -0000	1.2
  +++ IsSetConditionTestCase.java	4 Jun 2002 12:44:54 -0000	1.3
  @@ -16,7 +16,7 @@
    * Test cases for the <is-set> condition.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/11 12:44:01 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/04 12:44:54 $
    */
   public class IsSetConditionTestCase
       extends AbstractTaskTestCase
  @@ -39,7 +39,6 @@
   
           Resources res = getResourcesForTested( IsSetCondition.class );
           final String[] messages = {
  -            null,
               res.getString( "isset.no-property.error" )
           };
           executeTargetExpectError( projectFile, "no-prop-name", messages );
  
  
  
  1.3       +1 -2      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/conditions/test/IsTrueConditionTestCase.java
  
  Index: IsTrueConditionTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/conditions/test/IsTrueConditionTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IsTrueConditionTestCase.java	11 May 2002 12:44:01 -0000	1.2
  +++ IsTrueConditionTestCase.java	4 Jun 2002 12:44:54 -0000	1.3
  @@ -16,7 +16,7 @@
    * Test cases for the <is-true> condition.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/11 12:44:01 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/04 12:44:54 $
    */
   public class IsTrueConditionTestCase
       extends AbstractTaskTestCase
  @@ -42,7 +42,6 @@
   
           final Resources res = getResourcesForTested( IsTrueCondition.class );
           messages = new String[] {
  -            null,
               res.getString( "istrue.no-property.error" )
           };
           executeTargetExpectError( projectFile, "no-prop-name", messages );
  
  
  
  1.4       +4 -3      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/file/test/PathTestCase.java
  
  Index: PathTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/file/test/PathTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PathTestCase.java	27 May 2002 13:06:07 -0000	1.3
  +++ PathTestCase.java	4 Jun 2002 12:44:54 -0000	1.4
  @@ -17,7 +17,7 @@
    * Test-cases for the <path> data type.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/27 13:06:07 $
  + * @version $Revision: 1.4 $ $Date: 2002/06/04 12:44:54 $
    */
   public class PathTestCase
       extends AbstractTaskTestCase
  @@ -89,7 +89,7 @@
           };
           final String path = PathUtil.formatPath( files );
           final LogMessageTracker listener = new LogMessageTracker();
  -        listener.addExpectedMessage( "/unit-test-log", "test-path = " + path );
  +        listener.addExpectedMessage( "/path/convert-path-to-string/unit-test-log", "test-path
= " + path );
   
           final File projectFile = getTestResource( "path.ant" );
           executeTarget( projectFile, "convert-path-to-string", listener );
  @@ -111,7 +111,8 @@
           {
               final String fileName = files[ i ];
               final File file = FileUtil.resolveFile( baseDir, fileName );
  -            listener.addExpectedMessage( "/list-path", file.getAbsolutePath() );
  +            listener.addExpectedMessage( "/path/" + targetName + "/list-path",
  +                                         file.getAbsolutePath() );
           }
   
           // Execute the target
  
  
  

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