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
Date Wed, 29 May 2002 06:42:26 GMT
adammurdoch    02/05/28 23:42:26

  Modified:    antlib/src/java/org/apache/antlib/project TargetTask.java
               container/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java
               container/src/java/org/apache/myrmidon/components/executor
                        DefaultExecutor.java
               container/src/java/org/apache/myrmidon/components/property
                        DefaultNameValidator.java DefaultPropertyStore.java
                        Resources.properties
               container/src/java/org/apache/myrmidon/interfaces/embeddor
                        Embeddor.java
               container/src/java/org/apache/myrmidon/interfaces/property
                        NameValidator.java
               container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/test/org/apache/myrmidon/components/builder/test
                        DefaultProjectBuilderTestCase.java
               container/src/test/org/apache/myrmidon/interfaces/model/test
                        DefaultNameValidatorTestCase.java
               framework/src/test/org/apache/myrmidon/framework
                        DataTypeTestCase.java
  Added:       container/src/java/org/apache/myrmidon/components/property
                        DefaultNameValidatorManager.java
               container/src/java/org/apache/myrmidon/interfaces/property
                        NameValidatorManager.java
  Log:
  Made NameValidator into a proper service:
  
  * Added NameValidator.makeValidName().
  
  * Added NameValidatorManager, which is the service responsible for handing
    out NameValidator instances.  Changed DefaultProjectBuilder and
    DefaultPropertyStore to use this service, rather than instantiating a
    NameValidator directly.
  
  * Changed the validation rules for target names, to allow them to start with '-'.
  
  Revision  Changes    Path
  1.10      +13 -3     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TargetTask.java
  
  Index: TargetTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TargetTask.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TargetTask.java	28 May 2002 03:51:07 -0000	1.9
  +++ TargetTask.java	29 May 2002 06:42:25 -0000	1.10
  @@ -14,12 +14,14 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.property.NameValidator;
  +import org.apache.myrmidon.interfaces.property.NameValidatorManager;
  +import org.apache.myrmidon.interfaces.oldmodel.Project;
   
   /**
    * A simple task to task to execute a group of tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.9 $ $Date: 2002/05/28 03:51:07 $
  + * @version $Revision: 1.10 $ $Date: 2002/05/29 06:42:25 $
    * @ant.task name="target"
    */
   public class TargetTask
  @@ -115,10 +117,18 @@
               throw new TaskException( message );
           }
   
  -        final NameValidator validator =
  -            (NameValidator)getService( NameValidator.class );
  +        //Add in special case for "init" target.
  +        if( Project.IMPLICIT_TARGET_NAME.equals( m_name ) )
  +        {
  +            return;
  +        }
  +
  +        final NameValidatorManager validatorManager =
  +            (NameValidatorManager)getService( NameValidatorManager.class );
           try
           {
  +            final NameValidator validator =
  +                validatorManager.getValidator( NameValidatorManager.TARGET_STYLE );
               validator.validate( m_name );
           }
           catch( final Exception e )
  
  
  
  1.64      +16 -5     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- DefaultProjectBuilder.java	23 May 2002 06:08:58 -0000	1.63
  +++ DefaultProjectBuilder.java	29 May 2002 06:42:26 -0000	1.64
  @@ -21,19 +21,20 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.api.metadata.ModelElement;
  -import org.apache.myrmidon.components.property.DefaultNameValidator;
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectException;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
   import org.apache.myrmidon.interfaces.oldmodel.Target;
  +import org.apache.myrmidon.interfaces.property.NameValidator;
  +import org.apache.myrmidon.interfaces.property.NameValidatorManager;
   
   /**
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.63 $ $Date: 2002/05/23 06:08:58 $
  + * @version $Revision: 1.64 $ $Date: 2002/05/29 06:42:26 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -52,13 +53,23 @@
       private static final int TARGETS = 2;
   
       // Use a name validator with the default rules.
  -    private DefaultNameValidator m_nameValidator = new DefaultNameValidator();
  +    private NameValidator m_nameValidator;
       private ModelBuilder m_modelBuilder;
   
       public void service( final ServiceManager manager )
           throws ServiceException
       {
           m_modelBuilder = (ModelBuilder)manager.lookup( ModelBuilder.ROLE );
  +        final NameValidatorManager validatorManager =
  +            (NameValidatorManager)manager.lookup( NameValidatorManager.ROLE );
  +        try
  +        {
  +            m_nameValidator = validatorManager.getValidator( NameValidatorManager.PROJECT_STYLE
);
  +        }
  +        catch( final Exception e )
  +        {
  +            throw new ServiceException( e.getMessage(), e );
  +        }
       }
   
       /**
  @@ -340,7 +351,7 @@
           throws Exception
       {
           final ModelElement implicit = new ModelElement( "target", model.getLocation() );
  -        implicit.setAttribute( "name", "<init>" );
  +        implicit.setAttribute( "name", Project.IMPLICIT_TARGET_NAME );
   
           final ModelElement[] children = model.getChildren();
   
  @@ -392,7 +403,7 @@
                   throw new ProjectException( message );
               }
           }
  -        targets.put( "<init>", new Target( implicit ) );
  +        targets.put( Project.IMPLICIT_TARGET_NAME, new Target( implicit ) );
       }
   
       private ProjectRef buildProjectRef( final File baseDirectory,
  
  
  
  1.43      +2 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- DefaultExecutor.java	28 May 2002 03:55:42 -0000	1.42
  +++ DefaultExecutor.java	29 May 2002 06:42:26 -0000	1.43
  @@ -26,7 +26,7 @@
    * The basic executor that just executes the tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.42 $ $Date: 2002/05/28 03:55:42 $
  + * @version $Revision: 1.43 $ $Date: 2002/05/29 06:42:26 $
    */
   public class DefaultExecutor
       extends AbstractLogEnabled
  @@ -90,7 +90,7 @@
               // without wrapping it
               throw e;
           }
  -        catch( final Exception e )
  +        catch( final Throwable e )
           {
               // Wrap exception in generic error message
               final String message = REZ.getString( "execute.error",
  
  
  
  1.3       +28 -38    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultNameValidator.java
  
  Index: DefaultNameValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultNameValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultNameValidator.java	5 May 2002 13:51:51 -0000	1.2
  +++ DefaultNameValidator.java	29 May 2002 06:42:26 -0000	1.3
  @@ -16,7 +16,7 @@
    * in ant projects.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/05 13:51:51 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/29 06:42:26 $
    */
   public class DefaultNameValidator
       implements NameValidator
  @@ -46,37 +46,12 @@
        */
       public DefaultNameValidator()
       {
  -        this( false, true, "_", true, true, "_-." );
  -    }
  -
  -    /**
  -     * Contstruct a NameValidator with the specified rules.
  -     * @param allowSurroundingWhitespace
  -     *          specified if names are trimmed before checking
  -     * @param allowInitialDigit
  -     *          specifies if digits are permitted as intial characters
  -     * @param additionalInitialCharacters
  -     *          extra characters to allow as initial characters.
  -     * @param allowInternalDigits
  -     *          specifies if digits are permitted as internal characters
  -     * @param allowInternalWhitespace
  -     *          specifies if whitespace is permitted internally in names
  -     * @param additionalInternalCharacters
  -     *          extra characters permitted in names
  -     */
  -    public DefaultNameValidator( final boolean allowSurroundingWhitespace,
  -                                 final boolean allowInitialDigit,
  -                                 final String additionalInitialCharacters,
  -                                 final boolean allowInternalDigits,
  -                                 final boolean allowInternalWhitespace,
  -                                 final String additionalInternalCharacters )
  -    {
  -        setAllowSurroundingWhitespace( allowSurroundingWhitespace );
  -        setAllowInitialDigit( allowInitialDigit );
  -        setAdditionalInitialCharacters( additionalInitialCharacters );
  -        setAllowInternalDigits( allowInternalDigits );
  -        setAllowInternalWhitespace( allowInternalWhitespace );
  -        setAdditionalInternalCharacters( additionalInternalCharacters );
  +        setAllowSurroundingWhitespace( false );
  +        setAllowInternalWhitespace( true );
  +        setAllowInitialDigit( true );
  +        setAllowInternalDigits( true );
  +        setAdditionalInitialCharacters( "_" );
  +        setAdditionalInternalCharacters( "_-." );
       }
   
       /**
  @@ -122,12 +97,6 @@
       public void validate( final String name )
           throws Exception
       {
  -        //Add in special case for "init" target.
  -        if( "<init>".equals( name ) )
  -        {
  -            return;
  -        }
  -
           String testName = name;
   
           // If surrounding whitespace is allowed, trim it. Otherwise, check.
  @@ -330,6 +299,9 @@
       }
   
       /**
  +     * Sets the valid initial characters.  Does not include letters, digits and
  +     * whitespace, which are enabled separately.
  +     *
        * @param additionalInitialCharacters
        *          extra characters to allow as initial characters.
        */
  @@ -339,6 +311,14 @@
       }
   
       /**
  +     * Adds valid initial characters.
  +     */
  +    public void addInitialCharacters( String initialCharacters )
  +    {
  +        m_additionalInitialCharacters += initialCharacters;
  +    }
  +
  +    /**
        * @param allowInternalDigits
        *          specifies if digits are permitted as internal characters
        */
  @@ -357,6 +337,9 @@
       }
   
       /**
  +     * Sets the valid internal characters.  Does not include letters, digits,
  +     * and whitespace, which are enabled separately.
  +     *
        * @param additionalInternalCharacters
        *          extra characters permitted in names
        */
  @@ -365,4 +348,11 @@
           m_additionalInternalCharacters = additionalInternalCharacters;
       }
   
  +    /**
  +     * Adds valid internal characters.
  +     */
  +    public void addInternalCharacters( String internalCharacters )
  +    {
  +        m_additionalInternalCharacters += internalCharacters;
  +    }
   }
  
  
  
  1.7       +24 -23    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultPropertyStore.java
  
  Index: DefaultPropertyStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultPropertyStore.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultPropertyStore.java	6 May 2002 09:29:44 -0000	1.6
  +++ DefaultPropertyStore.java	29 May 2002 06:42:26 -0000	1.7
  @@ -12,26 +12,29 @@
   import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.property.NameValidator;
  +import org.apache.myrmidon.interfaces.property.NameValidatorManager;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * This is the Default implementation of PropertyStore. It follows
  - * the following rules;
  + * the following rules:
    *
    * <ul>
    *   <li>The property names must pass DefaultNameValidator checks</li>
    *   <li>The store is mutable</li>
  - *   <li>If the key is TaskContext.BASE_DIRECTORY then value must be a key.</li>
    * </ul>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/06 09:29:44 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/29 06:42:26 $
    * @see org.apache.myrmidon.interfaces.property.PropertyStore
    */
   public class DefaultPropertyStore
  -    implements PropertyStore
  +    implements PropertyStore, Serviceable
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultPropertyStore.class );
  @@ -44,7 +47,7 @@
       /**
        * The name validator to check property names against.
        */
  -    private final NameValidator m_validator;
  +    private NameValidator m_validator;
   
       /**
        * The underlying map where propertys are actually stored.
  @@ -70,14 +73,25 @@
                                    final NameValidator validator )
       {
           m_parent = parent;
  +        m_validator = validator;
  +    }
   
  -        NameValidator candidateValidator = validator;
  -        if( null == candidateValidator )
  +    public void service( final ServiceManager serviceManager )
  +        throws ServiceException
  +    {
  +        if( m_validator == null )
           {
  -            candidateValidator = createDefaultNameValidator();
  +            final NameValidatorManager validatorManager =
  +                (NameValidatorManager)serviceManager.lookup( NameValidatorManager.ROLE
);
  +            try
  +            {
  +                m_validator = validatorManager.getValidator( NameValidatorManager.PROPERTY_STYLE
);
  +            }
  +            catch( final Exception e )
  +            {
  +                throw new ServiceException( e.getMessage(), e );
  +            }
           }
  -
  -        m_validator = candidateValidator;
       }
   
       /**
  @@ -196,18 +210,5 @@
               String message = REZ.getString( "bad-property-name.error", name );
               throw new TaskException( message, e );
           }
  -    }
  -
  -    /**
  -     * Create an instance of the default the name validator.
  -     *
  -     * @return the default NameValidator
  -     */
  -    private static NameValidator createDefaultNameValidator()
  -    {
  -        final DefaultNameValidator defaultValidator = new DefaultNameValidator();
  -        defaultValidator.setAllowInternalWhitespace( false );
  -        defaultValidator.setAdditionalInternalCharacters( "_-.+" );
  -        return defaultValidator;
       }
   }
  
  
  
  1.5       +1 -0      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/Resources.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Resources.properties	5 May 2002 13:48:37 -0000	1.4
  +++ Resources.properties	29 May 2002 06:42:26 -0000	1.5
  @@ -10,6 +10,7 @@
   bad-resolve.error=Unable to resolve value "{0}".
   
   # Name validation
  +unknown-name-style.error=Unknown name style "{0}".
   name.zero-char-name.error=Name "" is invalid, as it contains no characters.
   name.enclosing-whitespace.error=Name "{0}" is invalid, as it contains enclosing whitespace.
   name.invalid-initial-char.error=Name "{0}" is invalid, as it begins with an illegal character.
Names can start with {1}.
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/DefaultNameValidatorManager.java
  
  Index: DefaultNameValidatorManager.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.property;
  
  import java.util.HashMap;
  import java.util.Map;
  import org.apache.myrmidon.interfaces.property.NameValidator;
  import org.apache.myrmidon.interfaces.property.NameValidatorManager;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * The default name validator manager.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/29 06:42:26 $
   */
  public class DefaultNameValidatorManager
      implements NameValidatorManager
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( DefaultNameValidatorManager.class );
  
      private Map m_validators = new HashMap();
  
      public DefaultNameValidatorManager()
      {
          // Property validator
          DefaultNameValidator validator = new DefaultNameValidator();
          validator.setAllowInternalWhitespace( false );
          validator.addInternalCharacters( "+" );
          m_validators.put( PROPERTY_STYLE, validator );
  
          // Project validator
          validator = new DefaultNameValidator();
          m_validators.put( PROJECT_STYLE, validator );
  
          // Target validator
          validator = new DefaultNameValidator();
          validator.addInitialCharacters( "-" );
          m_validators.put( TARGET_STYLE, validator );
      }
  
      /**
       * Locates a name validator for a particular style.
       */
      public NameValidator getValidator( final String style ) throws Exception
      {
          final NameValidator validator = (NameValidator)m_validators.get( style );
          if( validator == null )
          {
              final String message = REZ.getString( "unknown-name-style.error", style );
              throw new Exception( message );
          }
          return validator;
      }
  }
  
  
  
  1.17      +2 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java
  
  Index: Embeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Embeddor.java	21 May 2002 05:57:14 -0000	1.16
  +++ Embeddor.java	29 May 2002 06:42:26 -0000	1.17
  @@ -18,7 +18,7 @@
    * Interface through which you embed Myrmidon into applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.16 $ $Date: 2002/05/21 05:57:14 $
  + * @version $Revision: 1.17 $ $Date: 2002/05/29 06:42:26 $
    */
   public interface Embeddor
   {
  @@ -62,7 +62,7 @@
           throws Exception;
   
       /**
  -     * Creates a {@link ExecutionFrame} that can be used to execute projects.
  +     * Creates an {@link ExecutionFrame} that can be used to execute projects.
        *
        * @param properties The properties to define in the frame.  These
        *                   are added to the properties in the embeddor's
  
  
  
  1.3       +10 -1     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/property/NameValidator.java
  
  Index: NameValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/property/NameValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NameValidator.java	3 May 2002 09:26:13 -0000	1.2
  +++ NameValidator.java	29 May 2002 06:42:26 -0000	1.3
  @@ -11,7 +11,7 @@
    * Determines the validity of names used in projects.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/03 09:26:13 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/29 06:42:26 $
    */
   public interface NameValidator
   {
  @@ -24,5 +24,14 @@
        * @throws java.lang.Exception is the supplied name is not valid.
        */
       void validate( String name )
  +        throws Exception;
  +
  +    /**
  +     * Transforms a name into a valid name.
  +     *
  +     * @param name The name to be transformed.
  +     * @return The name, transformed into a valid name
  +     */
  +    String makeValidName( String name )
           throws Exception;
   }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/property/NameValidatorManager.java
  
  Index: NameValidatorManager.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.interfaces.property;
  
  /**
   * Manages a set of {@link NameValidator}.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/29 06:42:26 $
   */
  public interface NameValidatorManager
  {
      String ROLE = NameValidatorManager.class.getName();
  
      /** The validation style for property names. */
      String PROPERTY_STYLE = "property";
  
      /** The validation style for target names. */
      String TARGET_STYLE = "target";
  
      /** The validation style for project names. */
      String PROJECT_STYLE = "target";
  
      /**
       * Locates a name validator for a particular style.
       *
       * @param style The style of name validation to use.
       * @return the validator.  Does not return null.
       * @throws Exception if the requested validator is not found.
       */
      NameValidator getValidator( String style ) throws Exception;
  }
  
  
  
  1.44      +30 -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.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- AbstractComponentTest.java	28 May 2002 03:29:56 -0000	1.43
  +++ AbstractComponentTest.java	29 May 2002 06:42:26 -0000	1.44
  @@ -17,6 +17,7 @@
   import org.apache.aut.converter.ConverterFactory;
   import org.apache.aut.converter.lib.SimpleConverterFactory;
   import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.DefaultContext;
  @@ -33,11 +34,13 @@
   import org.apache.myrmidon.components.executor.DefaultExecutor;
   import org.apache.myrmidon.components.extensions.DefaultExtensionManager;
   import org.apache.myrmidon.components.library.DefaultLibraryManager;
  +import org.apache.myrmidon.components.property.DefaultNameValidatorManager;
   import org.apache.myrmidon.components.property.DefaultPropertyResolver;
   import org.apache.myrmidon.components.property.DefaultPropertyStore;
   import org.apache.myrmidon.components.role.DefaultRoleManager;
   import org.apache.myrmidon.components.type.DefaultTypeManager;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  +import org.apache.myrmidon.components.builder.DefaultModelBuilder;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
  @@ -47,6 +50,7 @@
   import org.apache.myrmidon.interfaces.executor.Executor;
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
   import org.apache.myrmidon.interfaces.library.LibraryManager;
  +import org.apache.myrmidon.interfaces.property.NameValidatorManager;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
  @@ -56,12 +60,13 @@
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.type.TypeRegistry;
  +import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   
   /**
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.43 $ $Date: 2002/05/28 03:29:56 $
  + * @version $Revision: 1.44 $ $Date: 2002/05/29 06:42:26 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -129,6 +134,14 @@
               m_serviceManager.put( TaskEventManager.ROLE, component );
               components.add( component );
   
  +            component = createComponent( NameValidatorManager.ROLE, DefaultNameValidatorManager.class
);
  +            m_serviceManager.put( NameValidatorManager.ROLE, component );
  +            components.add( component );
  +
  +            component = createComponent( ModelBuilder.ROLE, DefaultModelBuilder.class );
  +            m_serviceManager.put( ModelBuilder.ROLE, component );
  +            components.add( component );
  +
               // Log enable the components
               for( Iterator iterator = components.iterator(); iterator.hasNext(); )
               {
  @@ -232,19 +245,31 @@
       /**
        * Utility method to create an execution frame.
        */
  -    protected ExecutionFrame createExecutionFrame( PropertyStore props )
  +    protected ExecutionFrame createExecutionFrame( final PropertyStore props )
           throws Exception
       {
           final DefaultServiceManager serviceManager = getServiceManager();
   
  -        if( props == null )
  +        PropertyStore propStore = props;
  +        if( propStore == null )
           {
  -            props = new DefaultPropertyStore();
  +            propStore = createPropertyStore();
           }
  -        serviceManager.put( PropertyStore.ROLE, props );
  +        serviceManager.put( PropertyStore.ROLE, propStore );
   
           final File baseDir = getTestDirectory();
           return new DefaultExecutionFrame( "", baseDir, serviceManager );
  +    }
  +
  +    /**
  +     * Utility method to create an empty property store.
  +     */
  +    protected PropertyStore createPropertyStore()
  +        throws Exception
  +    {
  +        final PropertyStore props = new DefaultPropertyStore();
  +        ContainerUtil.service( props, getServiceManager() );
  +        return props;
       }
   
       /**
  
  
  
  1.11      +4 -5      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java
  
  Index: DefaultProjectBuilderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultProjectBuilderTestCase.java	27 May 2002 13:42:30 -0000	1.10
  +++ DefaultProjectBuilderTestCase.java	29 May 2002 06:42:26 -0000	1.11
  @@ -18,6 +18,7 @@
   import org.apache.myrmidon.components.builder.DefaultModelBuilder;
   import org.apache.myrmidon.components.builder.DefaultProject;
   import org.apache.myrmidon.components.builder.DefaultProjectBuilder;
  +import org.apache.myrmidon.components.AbstractComponentTest;
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectException;
  @@ -27,10 +28,10 @@
    * Test cases for {@link DefaultProjectBuilder}.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.10 $ $Date: 2002/05/27 13:42:30 $
  + * @version $Revision: 1.11 $ $Date: 2002/05/29 06:42:26 $
    */
   public class DefaultProjectBuilderTestCase
  -    extends AbstractContainerTestCase
  +    extends AbstractComponentTest
   {
       private static final Resources REZ = getResourcesForTested( DefaultProjectBuilderTestCase.class
);
   
  @@ -44,11 +45,9 @@
       protected void setUp() throws Exception
       {
           super.setUp();
  -        final DefaultServiceManager serviceManager = new DefaultServiceManager();
  -        serviceManager.put( ModelBuilder.ROLE, new DefaultModelBuilder() );
           m_builder = new DefaultProjectBuilder();
           ContainerUtil.enableLogging( m_builder, getLogger() );
  -        ContainerUtil.service( m_builder, serviceManager );
  +        ContainerUtil.service( m_builder, getServiceManager() );
       }
   
       private String getURIFor( final File projFile ) throws IOException
  
  
  
  1.5       +9 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/interfaces/model/test/DefaultNameValidatorTestCase.java
  
  Index: DefaultNameValidatorTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/interfaces/model/test/DefaultNameValidatorTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultNameValidatorTestCase.java	2 May 2002 10:52:19 -0000	1.4
  +++ DefaultNameValidatorTestCase.java	29 May 2002 06:42:26 -0000	1.5
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included  with this distribution in
    * the LICENSE.txt file.
    */
  -package org.apache.myrmidon.interfaces.oldmodel.test;
  +package org.apache.myrmidon.interfaces.model.test;
   
   import org.apache.myrmidon.AbstractContainerTestCase;
   import org.apache.myrmidon.components.property.DefaultNameValidator;
  @@ -14,7 +14,7 @@
    * TestCases for {@link org.apache.myrmidon.components.property.DefaultNameValidator}.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.4 $ $Date: 2002/05/02 10:52:19 $
  + * @version $Revision: 1.5 $ $Date: 2002/05/29 06:42:26 $
    */
   public class DefaultNameValidatorTestCase
       extends AbstractContainerTestCase
  @@ -84,7 +84,13 @@
        */
       public void testStrictNames() throws Exception
       {
  -        m_validator = new DefaultNameValidator( false, false, "", false, false, "." );
  +        m_validator = new DefaultNameValidator();
  +        m_validator.setAllowSurroundingWhitespace( false );
  +        m_validator.setAllowInternalWhitespace( false );
  +        m_validator.setAllowInitialDigit( false );
  +        m_validator.setAllowInternalDigits( false );
  +        m_validator.setAdditionalInitialCharacters( "" );
  +        m_validator.setAdditionalInternalCharacters( "." );
   
           testValid( "name" );
           testValid( "a" );
  
  
  
  1.2       +4 -4      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DataTypeTestCase.java	18 May 2002 04:17:04 -0000	1.1
  +++ DataTypeTestCase.java	29 May 2002 06:42:26 -0000	1.2
  @@ -7,15 +7,15 @@
    */
   package org.apache.myrmidon.framework;
   
  -import org.apache.myrmidon.AbstractTaskTestCase;
  -import org.apache.myrmidon.components.property.DefaultPropertyStore;
   import java.io.File;
  +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.1 $ $Date: 2002/05/18 04:17:04 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/29 06:42:26 $
    */
   public class DataTypeTestCase
       extends AbstractTaskTestCase
  @@ -31,7 +31,7 @@
       public void testDeploy() throws Exception
       {
           final File projectFile = getTestResource( "data-type.ant" );
  -        final DefaultPropertyStore props = new DefaultPropertyStore();
  +        final PropertyStore props = createPropertyStore();
           executeTarget( projectFile, "type-instance-task", props );
   
           final Object obj = props.getProperty( "test-prop" );
  
  
  

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