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/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test AbstractPropertyResolverTestCase.java ClassicPropertyResolverTestCase.java DefaultPropertyResolverTestCase.java
Date Mon, 08 Apr 2002 10:45:07 GMT
adammurdoch    02/04/08 03:45:06

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/property
                        ClassicPropertyResolver.java
                        DefaultPropertyResolver.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/store
                        DefaultPropertyStore.java Resources.properties
               proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java DefaultWorkspace.java
               proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/property
                        PropertyResolver.java
               proposal/myrmidon/src/test/org/apache/antlib/core/test
                        PropertyTestCase.java
               proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test
                        AbstractPropertyResolverTestCase.java
                        ClassicPropertyResolverTestCase.java
                        DefaultPropertyResolverTestCase.java
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/property
                        PropertyStore.java
  Removed:     proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/store
                        PropertyStore.java
  Log:
  * Moved PropertyStore to interfaces.property.  Left DefaultPropertyStore
    where it was.
  
  * Changed PropertyResolver.resolveProperties() to use a PropertyStore,
    rather than a TaskContext.
  
  * Changed PropertyStore methods to throw a TaskException.
  
  * Changed contract of PropertyStore.getProperty() to throw exception if the
    requested property is not set.
  
  Revision  Changes    Path
  1.43      +5 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- DefaultEmbeddor.java	7 Apr 2002 02:23:19 -0000	1.42
  +++ DefaultEmbeddor.java	8 Apr 2002 10:45:05 -0000	1.43
  @@ -52,7 +52,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.42 $ $Date: 2002/04/07 02:23:19 $
  + * @version $Revision: 1.43 $ $Date: 2002/04/08 10:45:05 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -101,6 +101,7 @@
                   projectType = FileUtil.getExtension( location );
               }
   
  +            // TODO - reuse the project builders, or dispose them
               final ProjectBuilder builder = getProjectBuilder( projectType, parameters );
               return builder.build( location );
           }
  @@ -136,6 +137,8 @@
           // to the workspace
           parameters.setParameter( MYRMIDON_HOME, m_parameters.getParameter( MYRMIDON_HOME
) );
           setupObject( workspace, m_workspaceServiceManager, parameters );
  +
  +        // TODO - should keep track of workspaces, to dispose them later
           return workspace;
       }
   
  @@ -145,7 +148,7 @@
        * @param name The shorthand name of the listener.
        * @return the listener.
        */
  -    public ProjectListener createListener( String name )
  +    public ProjectListener createListener( final String name )
           throws Exception
       {
           final TypeFactory factory = m_typeManager.getFactory( ProjectListener.ROLE );
  
  
  
  1.5       +8 -10     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/property/ClassicPropertyResolver.java
  
  Index: ClassicPropertyResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/property/ClassicPropertyResolver.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClassicPropertyResolver.java	24 Mar 2002 07:53:54 -0000	1.4
  +++ ClassicPropertyResolver.java	8 Apr 2002 10:45:05 -0000	1.5
  @@ -8,14 +8,15 @@
   package org.apache.myrmidon.components.property;
   
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
  -import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
  +import org.apache.myrmidon.api.TaskException;
   
   /**
    * A {@link PropertyResolver} implementation which resolves properties
    * as per Ant1, ignoring undefined properties.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.4 $ $Date: 2002/03/24 07:53:54 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/08 10:45:05 $
    *
    * @ant.type type="property-resolver" name="classic"
    */
  @@ -28,19 +29,16 @@
        * If there is no such value, returns the original property reference.
        *
        * @param propertyName the name of the property to retrieve
  -     * @param context the set of known properties
  +     * @param properties the set of known properties
        */
       protected Object getPropertyValue( final String propertyName,
  -                                       final TaskContext context )
  +                                       final PropertyStore properties )
  +        throws TaskException
       {
  -        Object propertyValue = context.getProperty( propertyName );
  -        if ( propertyValue == null )
  +        if( ! properties.isPropertySet( propertyName ) )
           {
               return "${" + propertyName + "}";
           }
  -        else
  -        {
  -            return propertyValue;
  -        }
  +        return properties.getProperty( propertyName );
       }
   }
  
  
  
  1.7       +18 -27    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/property/DefaultPropertyResolver.java
  
  Index: DefaultPropertyResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/property/DefaultPropertyResolver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultPropertyResolver.java	29 Mar 2002 12:56:04 -0000	1.6
  +++ DefaultPropertyResolver.java	8 Apr 2002 10:45:05 -0000	1.7
  @@ -14,16 +14,16 @@
   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.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * Base class for PropertyResolver implementations.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.6 $ $Date: 2002/03/29 12:56:04 $
  + * @version $Revision: 1.7 $ $Date: 2002/04/08 10:45:05 $
    *
    * @ant.type type="property-resolver" name="default"
    */
  @@ -51,12 +51,12 @@
        * <code>toString()</code> called on the property value.
        *
        * @param content the property to resolve
  -     * @param context the context in which to resolve property
  +     * @param properties the context in which to resolve property
        * @return the reolved property
        * @exception TaskException if an error occurs
        */
       public Object resolveProperties( final String content,
  -                                     final TaskContext context )
  +                                     final PropertyStore properties )
           throws TaskException
       {
           int start = findNextProperty( content, 0 );
  @@ -72,7 +72,7 @@
           if( 0 == start && end == ( length - 1 ) )
           {
               return getPropertyValue( content.substring( start + 2, end ),
  -                                     context );
  +                                     properties );
           }
   
           final StringBuffer sb = new StringBuffer( length * 2 );
  @@ -82,7 +82,7 @@
           {
               final String propertyValue =
                   getPropertyStringValue( content.substring( start + 2, end ),
  -                                        context );
  +                                        properties );
   
               sb.append( content.substring( lastPlace, start ) );
               sb.append( propertyValue );
  @@ -108,12 +108,12 @@
        * substitutions based on specified context.
        *
        * @param content the property to resolve
  -     * @param context the context in which to resolve property
  +     * @param properties the context in which to resolve property
        * @return the reolved property
        * @exception TaskException if an error occurs
        */
       private Object recursiveResolveProperty( final String content,
  -                                             final TaskContext context )
  +                                             final PropertyStore properties )
           throws TaskException
       {
           int start = findNextProperty( content, 0 );
  @@ -129,8 +129,8 @@
           if( 0 == start && end == ( length - 1 ) )
           {
               final String propertyName = content.substring( start + 2, end );
  -            final Object key = recursiveResolveProperty( propertyName, context );
  -            return getPropertyValue( key.toString(), context );
  +            final Object key = recursiveResolveProperty( propertyName, properties );
  +            return getPropertyValue( key.toString(), properties );
           }
   
           final StringBuffer sb = new StringBuffer( length * 2 );
  @@ -140,8 +140,8 @@
           while( true )
           {
               final String propertyName = content.substring( start + 2, end );
  -            final Object key = recursiveResolveProperty( propertyName, context );
  -            final String value = getPropertyStringValue( key.toString(), context );
  +            final Object key = recursiveResolveProperty( propertyName, properties );
  +            final String value = getPropertyStringValue( key.toString(), properties );
   
               sb.append( content.substring( lastPlace, start ) );
               sb.append( value );
  @@ -246,17 +246,17 @@
        * Returns a property's value, converted to a String.
        */
       private String getPropertyStringValue( final String propertyName,
  -                                           final TaskContext context )
  +                                           final PropertyStore properties )
           throws TaskException
       {
  -        final Object value = getPropertyValue( propertyName, context );
  +        final Object value = getPropertyValue( propertyName, properties );
           if( value instanceof String )
           {
               return (String)value;
           }
           try
           {
  -            return (String)m_converter.convert( String.class, value, context );
  +            return (String)m_converter.convert( String.class, value, properties );
           }
           catch( final ConverterException e )
           {
  @@ -268,24 +268,15 @@
        * Retrieve a value from the specified context using the specified key.
        *
        * @param propertyName the key of value in context
  -     * @param context the set of known properties
  +     * @param properties the set of known properties
        * @return the object retrieved from context
        * @exception TaskException if the property is undefined
        */
       protected Object getPropertyValue( final String propertyName,
  -                                       final TaskContext context )
  +                                       final PropertyStore properties )
           throws TaskException
       {
  -        Object propertyValue = context.getProperty( propertyName );
  -        if ( propertyValue == null )
  -        {
  -            final String message = REZ.getString( "prop.missing-value.error", propertyName
);
  -            throw new TaskException( message );
  -        }
  -        else
  -        {
  -            return propertyValue;
  -        }
  +        return properties.getProperty( propertyName );
       }
   }
   
  
  
  
  1.2       +46 -29    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/store/DefaultPropertyStore.java
  
  Index: DefaultPropertyStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/store/DefaultPropertyStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultPropertyStore.java	7 Apr 2002 02:00:54 -0000	1.1
  +++ DefaultPropertyStore.java	8 Apr 2002 10:45:05 -0000	1.2
  @@ -17,7 +17,7 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.model.DefaultNameValidator;
   import org.apache.myrmidon.interfaces.model.NameValidator;
  -import org.apache.myrmidon.interfaces.store.PropertyStore;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * This is the Default implementation of PropertyStore. It follows
  @@ -31,8 +31,8 @@
    * </ul>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/07 02:00:54 $
  - * @see PropertyStore
  + * @version $Revision: 1.2 $ $Date: 2002/04/08 10:45:05 $
  + * @see org.apache.myrmidon.interfaces.property.PropertyStore
    */
   public class DefaultPropertyStore
       implements PropertyStore
  @@ -61,15 +61,17 @@
        */
       public DefaultPropertyStore()
       {
  -        this( null, null );
  +        this( "", null, null );
       }
   
       /**
        * Construct a PropertyStore with specified parent.
        *
  -     * @param parent the parent PropertyStore (may be null)
  +     * @param parent the parent PropertyStore (may be null).
  +     * @param validator the validator to use to check property names (may be null).
        */
  -    public DefaultPropertyStore( final PropertyStore parent,
  +    public DefaultPropertyStore( final String name,
  +                                 final PropertyStore parent,
                                    final NameValidator validator )
       {
           m_parent = parent;
  @@ -82,6 +84,7 @@
   
           m_validator = candidateValidator;
   
  +        m_contextData.put( TaskContext.NAME, name );
       }
   
       /**
  @@ -91,10 +94,10 @@
        *
        * @param name the name of property
        * @param value the value of property
  -     * @throws Exception if property can not be set
  +     * @throws TaskException if property can not be set
        */
       public void setProperty( final String name, final Object value )
  -        throws Exception
  +        throws TaskException
       {
           checkPropertyName( name );
           checkPropertyValid( name, value );
  @@ -118,11 +121,8 @@
       {
           try
           {
  -            final Object value = getProperty( name );
  -            if( null != value )
  -            {
  -                return true;
  -            }
  +            getProperty( name );
  +            return true;
           }
           catch( Exception e )
           {
  @@ -136,18 +136,24 @@
        *
        * @param name the name of the property
        * @return the value of the property, or null if no such property
  -     * @throws Exception if theres an error retrieving property, such
  +     * @throws TaskException if theres an error retrieving property, such
        *         as an invalid property name
        */
  -    public Object getProperty( String name )
  -        throws Exception
  +    public Object getProperty( final String name )
  +        throws TaskException
       {
           Object value = m_contextData.get( name );
  -        if( value == null && m_parent != null )
  +        if( value != null )
  +        {
  +            return value;
  +        }
  +        if( m_parent != null )
           {
  -            value = m_parent.getProperty( name );
  +            return m_parent.getProperty( name );
           }
  -        return value;
  +
  +        final String message = REZ.getString( "unknown-prop.error", name );
  +        throw new TaskException( message );
       }
   
       /**
  @@ -156,10 +162,10 @@
        *
        * @return a copy of all the properties that are "in-scope"
        *         for store.
  -     * @throws Exception if theres an error retrieving propertys
  +     * @throws TaskException if theres an error retrieving propertys
        */
       public Map getProperties()
  -        throws Exception
  +        throws TaskException
       {
           final Map properties = new HashMap();
           if( m_parent != null )
  @@ -178,17 +184,28 @@
        *
        * @param name the name of child store
        * @return the child store
  -     * @throws Exception if theres an error creating child store
  +     * @throws TaskException if theres an error creating child store
        */
       public PropertyStore createChildStore( final String name )
  -        throws Exception
  +        throws TaskException
       {
  -        final DefaultPropertyStore store = new DefaultPropertyStore( this, m_validator
);
  -
  -        final String newName = getProperty( TaskContext.NAME ) + "." + name;
  -        store.setProperty( TaskContext.NAME, newName );
  +        // Build the name for the new store
  +        final String thisName = (String)m_contextData.get( TaskContext.NAME );
  +        final String newName;
  +        if( name == null || name.length() == 0 )
  +        {
  +            newName = thisName;
  +        }
  +        else if( thisName.length() == 0 )
  +        {
  +            newName = name;
  +        }
  +        else
  +        {
  +            newName = thisName + "." + name;
  +        }
   
  -        return store;
  +        return new DefaultPropertyStore( newName, this, m_validator );
       }
   
       /**
  @@ -203,7 +220,7 @@
           }
           catch( Exception e )
           {
  -            String message = REZ.getString( "bad-property-name.error" );
  +            String message = REZ.getString( "bad-property-name.error", name );
               throw new TaskException( message, e );
           }
       }
  
  
  
  1.2       +3 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/store/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/store/Resources.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Resources.properties	7 Apr 2002 02:00:54 -0000	1.1
  +++ Resources.properties	8 Apr 2002 10:45:05 -0000	1.2
  @@ -1,5 +1,5 @@
  -unknown-prop.error=Unknown property {0}.
  -bad-property.error=Property {0} must have a value of type {1}.
  -bad-property-name.error=Invalid property name.
  +unknown-prop.error=Unknown property "{0}".
  +bad-property.error=Property "{0}" must have a value of type {1}.
  +bad-property-name.error=Invalid property name "{0}".
   null-resolved-value.error=Value "{0}" resolved to null.
   bad-resolve.error=Unable to resolve value "{0}".
  
  
  
  1.35      +10 -32    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  
  Index: DefaultTaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- DefaultTaskContext.java	7 Apr 2002 02:00:55 -0000	1.34
  +++ DefaultTaskContext.java	8 Apr 2002 10:45:05 -0000	1.35
  @@ -19,13 +19,13 @@
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
  -import org.apache.myrmidon.interfaces.store.PropertyStore;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * Default implementation of TaskContext.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.34 $ $Date: 2002/04/07 02:00:55 $
  + * @version $Revision: 1.35 $ $Date: 2002/04/08 10:45:05 $
    */
   public class DefaultTaskContext
       implements TaskContext
  @@ -44,7 +44,6 @@
       public DefaultTaskContext( final ServiceManager serviceManager,
                                  final Logger logger,
                                  final PropertyStore store )
  -        throws TaskException
       {
           m_serviceManager = serviceManager;
           m_logger = logger;
  @@ -150,7 +149,7 @@
                   m_propertyResolver = (PropertyResolver)getService( PropertyResolver.class
);
               }
               final Object object =
  -                m_propertyResolver.resolveProperties( value, this );
  +                m_propertyResolver.resolveProperties( value, m_store );
               if( null == object )
               {
                   final String message = REZ.getString( "null-resolved-value.error", value
);
  @@ -192,14 +191,7 @@
       public Map getProperties()
           throws TaskException
       {
  -        try
  -        {
  -            return m_store.getProperties();
  -        }
  -        catch( final Exception e )
  -        {
  -            throw new TaskException( e.getMessage(), e );
  -        }
  +        return m_store.getProperties();
       }
   
       /**
  @@ -211,14 +203,7 @@
       public void setProperty( final String name, final Object value )
           throws TaskException
       {
  -        try
  -        {
  -            m_store.setProperty( name, value );
  -        }
  -        catch( final Exception e )
  -        {
  -            throw new TaskException( e.getMessage(), e );
  -        }
  +        m_store.setProperty( name, value );
       }
   
       /**
  @@ -387,18 +372,11 @@
       public TaskContext createSubContext( final String name )
           throws TaskException
       {
  -        try
  -        {
  -            final PropertyStore store = m_store.createChildStore( name );
  -            final DefaultServiceManager serviceManager =
  -                new DefaultServiceManager( m_serviceManager );
  -            final Logger logger = m_logger.getChildLogger( name );
  +        final PropertyStore store = m_store.createChildStore( name );
  +        final DefaultServiceManager serviceManager =
  +            new DefaultServiceManager( m_serviceManager );
  +        final Logger logger = m_logger.getChildLogger( name );
   
  -            return new DefaultTaskContext( serviceManager, logger, store );
  -        }
  -        catch( final Exception e )
  -        {
  -            throw new TaskException( e.getMessage(), e );
  -        }
  +        return new DefaultTaskContext( serviceManager, logger, store );
       }
   }
  
  
  
  1.39      +5 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
  
  Index: DefaultWorkspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- DefaultWorkspace.java	7 Apr 2002 02:00:55 -0000	1.38
  +++ DefaultWorkspace.java	8 Apr 2002 10:45:05 -0000	1.39
  @@ -37,7 +37,7 @@
   import org.apache.myrmidon.interfaces.model.TypeLib;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  -import org.apache.myrmidon.interfaces.store.PropertyStore;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   import org.apache.myrmidon.listeners.ProjectListener;
   import org.apache.myrmidon.components.store.DefaultPropertyStore;
   
  @@ -45,7 +45,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.38 $ $Date: 2002/04/07 02:00:55 $
  + * @version $Revision: 1.39 $ $Date: 2002/04/08 10:45:05 $
    */
   public class DefaultWorkspace
       extends AbstractLogEnabled
  @@ -227,6 +227,8 @@
           final TypeManager typeManager = m_typeManager.createChildTypeManager();
           serviceManager.put( TypeManager.ROLE, typeManager );
   
  +        // TODO - Add child role manager
  +
           //We need to create a new deployer so that it deploys
           //to project specific TypeManager
           final Deployer deployer = m_deployer.createChildDeployer( serviceManager );
  @@ -427,6 +429,7 @@
               getLogger().debug( message );
           }
   
  +        //TODO - put this back in
           //frame.getContext().setProperty( Project.TARGET, target );
   
           // Execute all tasks assciated with target
  
  
  
  1.6       +3 -4      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/property/PropertyResolver.java
  
  Index: PropertyResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/property/PropertyResolver.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PropertyResolver.java	1 Apr 2002 09:56:27 -0000	1.5
  +++ PropertyResolver.java	8 Apr 2002 10:45:06 -0000	1.6
  @@ -8,7 +8,6 @@
   package org.apache.myrmidon.interfaces.property;
   
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.api.TaskContext;
   
   /**
    *
  @@ -16,7 +15,7 @@
    * String content.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.5 $ $Date: 2002/04/01 09:56:27 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/08 10:45:06 $
    *
    * @ant:role shorthand="property-resolver"
    */
  @@ -31,11 +30,11 @@
        * Rules used for property resolution are implementation dependent.
        *
        * @param value the value to resolve, which may contain property identifiers
  -     * @param context the set of properties to resolve against.
  +     * @param properties the set of properties to resolve against.
        * @return the resolved content
        * @exception TaskException if an error occurs
        */
       Object resolveProperties( final String value,
  -                              final TaskContext context )
  +                              final PropertyStore properties )
           throws TaskException;
   }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/property/PropertyStore.java
  
  Index: PropertyStore.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;
  
  import java.util.Map;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * This component stores and manages properties. It is also
   * responsible for instituting the various policies regarding
   * propertys. ie It will enforce rules regarding
   *
   * <ul>
   *   <li>Valid property names?</li>
   *   <li>Are propertys mutable?</li>
   *   <li>Are propertys scoped?</li>
   *   <li>Is mapping between name and value correct?</li>
   * </ul>
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/08 10:45:06 $
   */
  public interface PropertyStore
  {
      /** Role name for this interface. */
      String ROLE = PropertyStore.class.getName();
  
      /**
       * Set the property with specified name to specified value.
       * The specific implementation will apply various rules
       * before setting the property.
       *
       * @param name the name of property
       * @param value the value of property
       * @throws TaskException if property can not be set
       */
      void setProperty( String name, Object value )
          throws TaskException;
  
      /**
       * Return <code>true</code> if the specified property is set.
       *
       * @param name the name of property
       */
      boolean isPropertySet( String name );
  
      /**
       * Retrieve the value of specified property.
       *
       * @param name the name of the property
       * @return the value of the property.  Never returns null.
       * @throws TaskException if there is no such property, or on error
       *         retrieving property, such as an invalid property name.
       */
      Object getProperty( String name )
          throws TaskException;
  
      /**
       * Retrieve a copy of all the properties that are "in-scope"
       * for store.
       *
       * @return a copy of all the properties that are "in-scope"
       *         for store.
       * @throws TaskException if theres an error retrieving propertys
       */
      Map getProperties()
          throws TaskException;
  
      /**
       * Return a child PropertyStore with specified name.
       * This is to allow support for scoped stores. However a
       * store may choose to be unscoped and just return a
       * reference to itself.
       *
       * @param name the name of child store
       * @return the child store
       * @throws TaskException if theres an error creating child store
       */
      PropertyStore createChildStore( String name )
          throws TaskException;
  }
  
  
  
  1.2       +17 -5     jakarta-ant/proposal/myrmidon/src/test/org/apache/antlib/core/test/PropertyTestCase.java
  
  Index: PropertyTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/test/org/apache/antlib/core/test/PropertyTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyTestCase.java	17 Mar 2002 08:06:37 -0000	1.1
  +++ PropertyTestCase.java	8 Apr 2002 10:45:06 -0000	1.2
  @@ -13,12 +13,13 @@
   import org.apache.myrmidon.AbstractProjectTest;
   import org.apache.myrmidon.LogMessageTracker;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  +import org.apache.myrmidon.components.store.DefaultPropertyStore;
   
   /**
    * Test cases for <property> task.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/17 08:06:37 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/08 10:45:06 $
    */
   public class PropertyTestCase
       extends AbstractProjectTest
  @@ -98,18 +99,29 @@
       {
           final File projectFile = getTestResource( "property.ant" );
   
  -        final Resources contextResources
  -            = ResourceManager.getPackageResources( DefaultTaskContext.class );
  +        final Resources rez
  +            = ResourceManager.getPackageResources( DefaultPropertyStore.class );
   
           // Invalid names
           String[] messages = new String[]
           {
               null,
  -            contextResources.getString( "bad-property-name.error" ),
  -            null
  +            rez.getString( "bad-property-name.error", "badname!" )
           };
           executeTargetExpectError( projectFile, "bad-prop-name1", messages );
  +
  +        messages = new String[]
  +        {
  +            null,
  +            rez.getString( "bad-property-name.error", "bad name" )
  +        };
           executeTargetExpectError( projectFile, "bad-prop-name2", messages );
  +
  +        messages = new String[]
  +        {
  +            null,
  +            rez.getString( "bad-property-name.error", "" )
  +        };
           executeTargetExpectError( projectFile, "bad-prop-name3", messages );
       }
   
  
  
  
  1.6       +27 -32    jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java
  
  Index: AbstractPropertyResolverTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractPropertyResolverTestCase.java	7 Apr 2002 02:00:55 -0000	1.5
  +++ AbstractPropertyResolverTestCase.java	8 Apr 2002 10:45:06 -0000	1.6
  @@ -11,27 +11,24 @@
   import java.util.Date;
   import org.apache.aut.converter.lib.ObjectToStringConverter;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.components.AbstractComponentTest;
  +import org.apache.myrmidon.components.property.DefaultPropertyResolver;
   import org.apache.myrmidon.components.store.DefaultPropertyStore;
  -import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
  +import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * General-purpose property resolver test cases.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/04/07 02:00:55 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/08 10:45:06 $
    */
   public abstract class AbstractPropertyResolverTestCase
       extends AbstractComponentTest
   {
  -    protected final static Resources REZ = getResourcesForTested( AbstractPropertyResolverTestCase.class
);
  -
       protected PropertyResolver m_resolver;
  -    protected DefaultTaskContext m_context;
  +    protected PropertyStore m_store;
   
       public AbstractPropertyResolverTestCase( final String name )
       {
  @@ -42,11 +39,9 @@
       {
           m_resolver = (PropertyResolver)getServiceManager().lookup( PropertyResolver.ROLE
);
   
  -        final DefaultPropertyStore store = new DefaultPropertyStore();
  -        final DefaultServiceManager serviceManager = new DefaultServiceManager();
  -        m_context = new DefaultTaskContext( serviceManager, getLogger(), store );
  -        m_context.setProperty( "intProp", new Integer( 333 ) );
  -        m_context.setProperty( "stringProp", "String property" );
  +        m_store = new DefaultPropertyStore();
  +        m_store.setProperty( "intProp", new Integer( 333 ) );
  +        m_store.setProperty( "stringProp", "String property" );
   
           registerConverter( ObjectToStringConverter.class, Object.class, String.class );
       }
  @@ -92,14 +87,14 @@
       private void testPropertyValue( final Object propObject )
           throws Exception
       {
  -        m_context.setProperty( "typedProp", propObject );
  +        m_store.setProperty( "typedProp", propObject );
           final String propString = propObject.toString();
   
  -        doTestResolution( "${typedProp}", propObject, m_context );
  +        doTestResolution( "${typedProp}", propObject, m_store );
           doTestResolution( "${typedProp} with following text",
  -                          propString + " with following text", m_context );
  +                          propString + " with following text", m_store );
           doTestResolution( "Preceding text with ${typedProp}",
  -                          "Preceding text with " + propString, m_context );
  +                          "Preceding text with " + propString, m_store );
       }
   
       /**
  @@ -107,15 +102,15 @@
        */
       public void testMultipleProperties() throws Exception
       {
  -        m_context.setProperty( "prop1", "value1" );
  -        m_context.setProperty( "prop2", "value2" );
  -        m_context.setProperty( "int1", new Integer( 123 ) );
  +        m_store.setProperty( "prop1", "value1" );
  +        m_store.setProperty( "prop2", "value2" );
  +        m_store.setProperty( "int1", new Integer( 123 ) );
   
  -        doTestResolution( "${prop1}${prop2}", "value1value2", m_context );
  -        doTestResolution( "${prop1}${prop1}${prop1}", "value1value1value1", m_context );
  +        doTestResolution( "${prop1}${prop2}", "value1value2", m_store );
  +        doTestResolution( "${prop1}${prop1}${prop1}", "value1value1value1", m_store );
           doTestResolution( "before ${prop2} between ${prop1} after",
  -                          "before value2 between value1 after", m_context );
  -        doTestResolution( "${prop1}-${int1}-${prop2}", "value1-123-value2", m_context );
  +                          "before value2 between value1 after", m_store );
  +        doTestResolution( "${prop1}-${int1}-${prop2}", "value1-123-value2", m_store );
       }
   
       /**
  @@ -123,13 +118,13 @@
        */
       public void testInvalidTypeDeclarations() throws Exception
       {
  -
  +        final Resources rez = getResourcesForTested( DefaultPropertyResolver.class );
           doTestFailure( "${unclosed",
  -                       REZ.getString( "prop.mismatched-braces.error" ),
  -                       m_context );
  +                       rez.getString( "prop.mismatched-braces.error" ),
  +                       m_store );
           doTestFailure( "${",
  -                       REZ.getString( "prop.mismatched-braces.error" ),
  -                       m_context );
  +                       rez.getString( "prop.mismatched-braces.error" ),
  +                       m_store );
   
           /* TODO - need to handle these cases. */
           //        testFailure( "${bad${}", "", m_context );
  @@ -141,10 +136,10 @@
        */
       protected void doTestResolution( final String value,
                                        final Object expected,
  -                                     final TaskContext context )
  +                                     final PropertyStore properties )
           throws Exception
       {
  -        final Object resolved = m_resolver.resolveProperties( value, context );
  +        final Object resolved = m_resolver.resolveProperties( value, properties );
   
           assertEquals( expected, resolved );
       }
  @@ -155,11 +150,11 @@
        */
       protected void doTestFailure( final String value,
                                     final String expectedErrorMessage,
  -                                  final TaskContext context )
  +                                  final PropertyStore properties )
       {
           try
           {
  -            m_resolver.resolveProperties( value, context );
  +            m_resolver.resolveProperties( value, properties );
               fail( "Unexpected sucess - test should have failed." );
           }
           catch( TaskException e )
  
  
  
  1.2       +2 -2      jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/ClassicPropertyResolverTestCase.java
  
  Index: ClassicPropertyResolverTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/ClassicPropertyResolverTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClassicPropertyResolverTestCase.java	17 Mar 2002 08:07:09 -0000	1.1
  +++ ClassicPropertyResolverTestCase.java	8 Apr 2002 10:45:06 -0000	1.2
  @@ -15,7 +15,7 @@
    * A test for {@link org.apache.myrmidon.components.property.ClassicPropertyResolver}.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/17 08:07:09 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/08 10:45:06 $
    */
   public class ClassicPropertyResolverTestCase
       extends AbstractPropertyResolverTestCase
  @@ -37,6 +37,6 @@
       {
           final String undefinedProp = "undefinedProperty";
           final String propRef = "${" + undefinedProp + "}";
  -        doTestResolution( propRef, propRef, m_context );
  +        doTestResolution( propRef, propRef, m_store );
       }
   }
  
  
  
  1.2       +8 -5      jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/DefaultPropertyResolverTestCase.java
  
  Index: DefaultPropertyResolverTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/DefaultPropertyResolverTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultPropertyResolverTestCase.java	17 Mar 2002 08:07:09 -0000	1.1
  +++ DefaultPropertyResolverTestCase.java	8 Apr 2002 10:45:06 -0000	1.2
  @@ -10,12 +10,14 @@
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.components.property.test.AbstractPropertyResolverTestCase;
   import org.apache.myrmidon.components.property.DefaultPropertyResolver;
  +import org.apache.myrmidon.components.store.DefaultPropertyStore;
  +import org.apache.avalon.excalibur.i18n.Resources;
   
   /**
    * Functional tests for {@link org.apache.myrmidon.components.property.DefaultPropertyResolver}.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/17 08:07:09 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/08 10:45:06 $
    */
   public class DefaultPropertyResolverTestCase
       extends AbstractPropertyResolverTestCase
  @@ -35,14 +37,15 @@
        */
       public void testUndefinedProp() throws Exception
       {
  +        final Resources rez = getResourcesForTested( DefaultPropertyStore.class );
           final String undefinedProp = "undefinedProperty";
           doTestFailure( "${" + undefinedProp + "}",
  -                       REZ.getString( "prop.missing-value.error", undefinedProp ),
  -                       m_context );
  +                       rez.getString( "unknown-prop.error", undefinedProp ),
  +                       m_store );
   
           //TODO - "" should be disallowed as a property name
           doTestFailure( "${}",
  -                       REZ.getString( "prop.missing-value.error", "" ),
  -                       m_context );
  +                       rez.getString( "unknown-prop.error", "" ),
  +                       m_store );
       }
   }
  
  
  

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