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/antlib/src/test/org/apache/antlib/runtime/test type-available.ant TypeAvailableConditionTestCase.java
Date Sun, 23 Jun 2002 10:45:54 GMT
adammurdoch    2002/06/23 03:45:54

  Modified:    antlib/src/java/org/apache/antlib/runtime
                        TypeAvailableCondition.java
  Added:       antlib/src/test/org/apache/antlib/runtime/test
                        type-available.ant
                        TypeAvailableConditionTestCase.java
  Log:
  <type-available> condition was not mapping role short name to long name.  Added some
tests.
  
  Revision  Changes    Path
  1.4       +13 -2     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java
  
  Index: TypeAvailableCondition.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypeAvailableCondition.java	13 May 2002 09:52:30 -0000	1.3
  +++ TypeAvailableCondition.java	23 Jun 2002 10:45:54 -0000	1.4
  @@ -15,6 +15,8 @@
   import org.apache.myrmidon.framework.conditions.Condition;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.role.RoleInfo;
   
   /**
    * A condition that evaluates to true if a particular type is available.
  @@ -71,9 +73,18 @@
                   m_roleName = DataType.ROLE;
               }
   
  +            // Lookup the role
  +            final RoleManager roleManager = (RoleManager)context.getService( RoleManager.class
);
  +            final RoleInfo role = roleManager.getRoleByShortName( m_roleName );
  +            if( role == null )
  +            {
  +                // No such role
  +                return false;
  +            }
  +
               // Lookup the type
               final TypeManager typeManager = (TypeManager)context.getService( TypeManager.class
);
  -            final TypeFactory typeFactory = typeManager.getFactory( m_roleName );
  +            final TypeFactory typeFactory = typeManager.getFactory( role.getInterfaceName()
);
   
               // Check if the type is available
               return typeFactory.canCreate( m_typeName );
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/type-available.ant
  
  Index: type-available.ant
  ===================================================================
  <project version="2.0">
      <target name="test-self">
          <assert>
              <type-available role="condition" name="type-available"/>
          </assert>
      </target>
  
      <target name="unknown-role">
          <assert expected="false">
              <type-available role="some-unknown-role" name="some-type"/>
          </assert>
      </target>
  
      <target name="unknown-type">
          <assert expected="false">
              <type-available role="task" name="some-unknown-type"/>
          </assert>
      </target>
  
      <target name="validate">
          <expect-error>
              <exc>No type name was specified.</exc>
              <tasks>
                  <assert>
                      <type-available/>
                  </assert>
              </tasks>
          </expect-error>
      </target>
  </project>
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/TypeAvailableConditionTestCase.java
  
  Index: TypeAvailableConditionTestCase.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.antlib.runtime.test;
  
  import org.apache.antlib.AbstractProjectTestCase;
  import java.io.File;
  
  /**
   * Test cases for the <type-available> condition.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/23 10:45:54 $
   */
  public class TypeAvailableConditionTestCase
      extends AbstractProjectTestCase
  {
      public TypeAvailableConditionTestCase( final String name )
      {
          super( name );
      }
  
      public void testEvaluation() throws Exception
      {
          final File projectFile = getTestResource( "type-available.ant" );
          executeTarget( projectFile, "test-self" );
          executeTarget( projectFile, "unknown-role" );
          executeTarget( projectFile, "unknown-type" );
          executeTarget( projectFile, "validate" );
      }
  }
  
  
  

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