diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml index 970bffb94..e882242c8 100644 --- a/proposal/myrmidon/build.xml +++ b/proposal/myrmidon/build.xml @@ -455,11 +455,11 @@ Legal: + fork="false"> - + diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java index a68eefb7d..7d700e39e 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/api/AbstractTask.java @@ -37,8 +37,7 @@ public abstract class AbstractTask /** * Execute task. * This method is called to perform actual work associated with task. - * It is called after Task has been Configured and Initialized and before - * beig Disposed (If task implements appropriate interfaces). + * It is called after Task has been configured. * * @exception TaskException if an error occurs */ diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/Context.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/Context.java new file mode 100644 index 000000000..6ec4b8a09 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/api/Context.java @@ -0,0 +1,47 @@ +/* + * 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.api; + +import java.util.Map; + +/** + * A context - a set of named properties. + * + * @author Peter Donald + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public interface Context +{ + /** + * Resolve a value according to the context. + * This involves evaluating the string and replacing + * ${} sequences with property values. + * + * @param value the value to resolve + * @return the resolved value + */ + Object resolveValue( String value ) + throws TaskException; + + /** + * Retrieve property for name. + * + * @param name the name of property + * @return the value of property, or null if the property has no value. + */ + Object getProperty( String name ); + + /** + * Retrieve a copy of all the properties accessible via context. + * + * @return the map of all property names to values + */ + Map getProperties(); + +} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java index e4eb92e9f..6e8b537fa 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java @@ -8,7 +8,6 @@ package org.apache.myrmidon.api; import java.io.File; -import java.util.Map; import org.apache.avalon.framework.Enum; /** @@ -21,6 +20,7 @@ import org.apache.avalon.framework.Enum; * @version $Revision$ $Date$ */ public interface TaskContext + extends Context { //these values are used when setting properties to indicate the scope at //which properties are set @@ -72,33 +72,6 @@ public interface TaskContext File resolveFile( String filename ) throws TaskException; - /** - * Resolve a value according to the context. - * This involves evaluating the string and thus removing - * ${} sequences according to the rules specified at - * ............ - * - * @param value the value to resolve - * @return the resolved value - */ - Object resolveValue( String value ) - throws TaskException; - - /** - * Retrieve property for name. - * - * @param name the name of property - * @return the value of property - */ - Object getProperty( String name ); - - /** - * Retrieve a copy of all the properties accessible via context. - * - * @return the map of all property names to values - */ - Map getPropertys(); - /** * Set property value in current context. * diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/ClassicConfigurer.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/ClassicConfigurer.java index b87f0c707..bc7c5152c 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/ClassicConfigurer.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/ClassicConfigurer.java @@ -10,20 +10,21 @@ package org.apache.myrmidon.components.configurer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; +import org.apache.aut.converter.Converter; +import org.apache.aut.converter.ConverterException; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.LogEnabled; -import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; -import org.apache.aut.converter.ConverterException; +import org.apache.avalon.framework.service.Serviceable; +import org.apache.myrmidon.api.Context; +import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.converter.MasterConverter; /** * Class used to configure tasks. @@ -41,12 +42,12 @@ public class ClassicConfigurer private static final boolean DEBUG = false; ///Converter to use for converting between values - private MasterConverter m_converter; + private Converter m_converter; public void service( final ServiceManager serviceManager ) throws ServiceException { - m_converter = (MasterConverter)serviceManager.lookup( MasterConverter.ROLE ); + m_converter = (Converter)serviceManager.lookup( Converter.ROLE ); } /** @@ -216,16 +217,14 @@ public class ClassicConfigurer { try { - final Object objectValue = - PropertyUtil.resolveProperty( value, context, false ); - + final Object objectValue = context.resolveValue( value ); setValue( object, objectValue, methods, context ); } - catch( final PropertyException pe ) + catch( final TaskException te ) { final String message = REZ.getString( "bad-property-resolve.error", value ); - throw new ConfigurationException( message, pe ); + throw new ConfigurationException( message, te ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java index 3820c09a8..2f12f2538 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java @@ -9,22 +9,21 @@ package org.apache.myrmidon.components.configurer; import java.util.HashMap; import java.util.Map; +import org.apache.aut.converter.Converter; +import org.apache.aut.converter.ConverterException; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.context.Context; -import org.apache.avalon.framework.context.ContextException; -import org.apache.avalon.framework.context.Resolvable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.LogEnabled; 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.Context; import org.apache.myrmidon.framework.DataType; import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.role.RoleInfo; import org.apache.myrmidon.interfaces.role.RoleManager; import org.apache.myrmidon.interfaces.type.TypeFactory; @@ -44,7 +43,7 @@ public class DefaultConfigurer ResourceManager.getPackageResources( DefaultConfigurer.class ); ///Converter to use for converting between values - private MasterConverter m_converter; + private Converter m_converter; //TypeManager to use to create types in typed adders private TypeManager m_typeManager; @@ -59,7 +58,7 @@ public class DefaultConfigurer public void service( final ServiceManager serviceManager ) throws ServiceException { - m_converter = (MasterConverter)serviceManager.lookup( MasterConverter.ROLE ); + m_converter = (Converter)serviceManager.lookup( Converter.ROLE ); m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE ); m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE ); } @@ -140,7 +139,7 @@ public class DefaultConfigurer { final String message = REZ.getString( "no-such-attribute.error", elemName, name ); - throw new ReportableConfigurationException( message, nspe ); + throw new ReportableConfigurationException( message ); } catch( final Exception ce ) { @@ -187,7 +186,7 @@ public class DefaultConfigurer { final String message = REZ.getString( "no-such-element.error", elemName, name ); - throw new ReportableConfigurationException( message, nspe ); + throw new ReportableConfigurationException( message ); } catch( final ReportableConfigurationException ce ) { @@ -349,26 +348,29 @@ public class DefaultConfigurer = getConfigurerFromName( state.getConfigurer(), name, false ); // Resolve any props in the id - Object id = PropertyUtil.resolveProperty( unresolvedId, context, false ); + String id = context.resolveValue( unresolvedId ).toString(); // Locate the referenced object - Object ref = null; - try - { - ref = context.get( id ); - } - catch( final ContextException e ) + Object ref = context.getProperty( id ); + if( ref == null ) { final String message = REZ.getString( "unknown-reference.error", id ); - throw new ConfigurationException( message, e ); + throw new ConfigurationException( message ); } - // Check the types + // Convert the object, if necessary final Class type = childConfigurer.getType(); if( !type.isInstance( ref ) ) { - final String message = REZ.getString( "mismatch-ref-types.error", id, type.getName(), ref.getClass().getName() ); - throw new ConfigurationException( message ); + try + { + ref = m_converter.convert( type, ref, context ); + } + catch( ConverterException e ) + { + final String message = REZ.getString( "mismatch-ref-types.error", id, name ); + throw new ConfigurationException( message, e ); + } } // Set the child element @@ -408,17 +410,14 @@ public class DefaultConfigurer throws Exception { // Resolve property references in the attribute value - Object objValue = PropertyUtil.resolveProperty( value, context, false ); + Object objValue = context.resolveValue( value ); // Convert the value to the appropriate type - - Object converterContext = context; - if( context instanceof Resolvable ) + final Class type = setter.getType(); + if( ! type.isInstance( objValue ) ) { - converterContext = ( (Resolvable)context ).resolve( context ); + objValue = m_converter.convert( type, objValue, context ); } - final Class clazz = setter.getType(); - objValue = m_converter.convert( clazz, objValue, converterContext ); // Set the value setter.addValue( state, objValue ); @@ -451,27 +450,38 @@ public class DefaultConfigurer { final String name = element.getName(); final Class type = childConfigurer.getType(); - Object child = childConfigurer.createValue( state ); - if( null == child && Configuration.class == type ) + if( Configuration.class == type ) { //special case where you have add...(Configuration) return element; } - else if( null == child ) + + // Create an instance + Object child = childConfigurer.createValue( state ); + if( null == child ) { - // Create an instance - if( type.isInterface() ) + if( childConfigurer == state.getConfigurer().getTypedProperty() ) { - child = createdTypedObject( name, type ); + // Typed property + child = createTypedObject( name, type ); } else { - child = createObject( type ); + // Named property + child = createNamedObject( type ); } } + // Configure the object configureObject( child, element, context ); + + // Convert the object, if necessary + if( ! type.isInstance( child ) ) + { + child = m_converter.convert( type, child, context ); + } + return child; } @@ -521,38 +531,61 @@ public class DefaultConfigurer } /** - * Utility method to create an instance of the - * specified type that satisfies supplied interface. + * Creates an instance for a named property. */ - private Object createdTypedObject( final String name, - final Class type ) + private Object createNamedObject( final Class type ) throws Exception { - // Attempt to create the object - final Object obj; - try - { - final TypeFactory factory = m_typeManager.getFactory( DataType.class ); - obj = factory.create( name ); + // Map the expected type to a role. If found, instantiate the default + // type for that role + final RoleInfo roleInfo = m_roleManager.getRoleByType( type ); + if( roleInfo != null ) { + final String typeName = roleInfo.getDefaultType(); + if( typeName != null ) + { + // Create the instance + final TypeFactory factory = m_typeManager.getFactory( roleInfo.getType() ); + return factory.create( typeName ); + } } - catch( final Exception e ) + + if( type.isInterface() ) { - final String message = - REZ.getString( "create-typed-object.error", - name, - type.getName() ); - throw new ConfigurationException( message, e ); + // An interface - don't know how to instantiate it + final String message = REZ.getString( "instantiate-interface.error", type.getName() ); + throw new ConfigurationException( message ); } - // Check the types - if( !type.isInstance( obj ) ) + // Use the no-args constructor + return createObject( type ); + } + + /** + * Creates an instance of the typed property. + */ + private Object createTypedObject( final String name, + final Class type ) + throws Exception + { + // Map the expected type to a role. If found, attempt to create + // an instance + final RoleInfo roleInfo = m_roleManager.getRoleByType( type ); + if( roleInfo != null ) { - final String message = - REZ.getString( "mismatched-typed-object.error", name, type.getName() ); - throw new ConfigurationException( message ); + final TypeFactory factory = m_typeManager.getFactory( roleInfo.getType() ); + if( factory.canCreate( name ) ) + { + return factory.create( name ); + } } - return obj; + // Use the generic 'data-type' role. + final TypeFactory factory = m_typeManager.getFactory( DataType.class ); + if( ! factory.canCreate( name ) ) + { + throw new NoSuchPropertyException(); + } + return factory.create( name ); } /** diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyException.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyException.java deleted file mode 100644 index 4c041f8b2..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.configurer; - -/** - * Exception thrown when evaluating a property. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class PropertyException - extends Exception -{ - /** - * Basic constructor for exception that does not specify a message - */ - public PropertyException() - { - this( "" ); - } - - /** - * Basic constructor with a message - * - * @param message the message - */ - public PropertyException( final String message ) - { - super( message ); - } -} - diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties index 9e239fc44..4e6957ecd 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties @@ -1,6 +1,6 @@ create-object.error=Could not create an object of class {0}. extra-config-for-ref.error=A reference element can only include an "id" attribute. -mismatch-ref-types.error=Mismatched type for reference "{0}". Was expecting an object of type {1}, instead found an object of type {2}. +mismatch-ref-types.error=Could not convert reference "{0}" to the type expected for property "{1}". incompatible-element-types.error=Incompatible creator and adder/setter methods found in class {0} for property "{1}". multiple-adder-methods-for-element.error=Multiple add{1}() or set{1}() methods found in class {0}. multiple-creator-methods-for-element.error=Multiple {1}() methods found in class {0}. @@ -9,16 +9,13 @@ pending-property-value.error=An object created using the creator method has not must-be-element.error=This property must be configured using a nested element. too-many-values.error=Too many values for this property. no-complex-type.error=Can not get complex type for non-primitive type {0}. -no-such-attribute.error=Attribute "{1}" is not allowed for element <{0}>. +no-such-attribute.error=Attribute "{1}" is not supported for element <{0}>. bad-set-attribute.error=Could not set attribute "{1}" for element <{0}>. bad-set-class-attribute.error=Could not set attribute "{0}" for object of class {1}. -no-such-element.error=Nested <{1}> elements are not allowed for element <{0}>. -no-content.error=Text content is not allowed in element <{0}>. +no-such-element.error=Nested <{1}> elements are not supported for element <{0}>. +no-content.error=Text content is not supported in element <{0}>. bad-set-content.error=Could not set text content for element <{0}>. typed-adder-non-interface.error=The typed adder for class "{0}" must have a single parameter that is an interface rather than {1} which defines a class. create-typed-object.error=Could not create an object of type "{0}" of class {1}. unknown-reference.error=Could not find referenced object "{0}". bad-configure-element.error=Could not configure element <{0}>. - -prop.mismatched-braces.error=Malformed property with mismatched }'s. -prop.missing-value.error=Unable to find "{0}" to expand during property resolution. diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/DefaultMasterConverter.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/DefaultMasterConverter.java index 5995a466f..c4c79f6e6 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/DefaultMasterConverter.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/DefaultMasterConverter.java @@ -7,6 +7,9 @@ */ package org.apache.myrmidon.components.converter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import org.apache.aut.converter.Converter; import org.apache.aut.converter.ConverterException; import org.apache.avalon.excalibur.i18n.ResourceManager; @@ -16,7 +19,6 @@ 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.interfaces.converter.ConverterRegistry; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.type.TypeException; import org.apache.myrmidon.interfaces.type.TypeFactory; import org.apache.myrmidon.interfaces.type.TypeManager; @@ -29,16 +31,17 @@ import org.apache.myrmidon.interfaces.type.TypeManager; */ public class DefaultMasterConverter extends AbstractLogEnabled - implements MasterConverter, Serviceable + implements Converter, Serviceable { private final static Resources REZ = ResourceManager.getPackageResources( DefaultMasterConverter.class ); - private final static boolean DEBUG = false; - private ConverterRegistry m_registry; private TypeFactory m_factory; + /** Map from converter name to Converter. */ + private Map m_converters = new HashMap(); + /** * Retrieve relevent services needed to deploy. * @@ -83,73 +86,109 @@ public class DefaultMasterConverter return original; } - if( DEBUG ) - { - final String message = - REZ.getString( "converter-lookup.notice", - originalClass.getName(), - destination.getName() ); - getLogger().debug( message ); - } - - //Searching inheritance hierarchy for converter - final String name = getConverterName( originalClass, destination ); - try { - //TODO: Start caching converters instead of repeatedly instantiating em. - final Converter converter = (Converter)m_factory.create( name ); + // Search inheritance hierarchy for converter + final String name = getConverterName( originalClass, destination ); - if( DEBUG ) + // Create the converter + Converter converter = (Converter)m_converters.get( name ); + if( converter == null ) { - final String message = REZ.getString( "found-converter.notice", converter ); - getLogger().debug( message ); + converter = (Converter)m_factory.create( name ); + m_converters.put( name, converter ); } + // Convert final Object object = converter.convert( destination, original, context ); if( destination.isInstance( object ) ) { return object; } - else - { - final String message = - REZ.getString( "bad-return-type.error", - name, - object, - destination.getName() ); - throw new ConverterException( message ); - } + + final String message = + REZ.getString( "bad-return-type.error", + object.getClass().getName(), + destination.getName() ); + throw new ConverterException( message ); } - catch( final TypeException te ) + catch( final Exception e ) { - final String message = REZ.getString( "bad-typemanager.error" ); - throw new ConverterException( message, te ); + final String message = REZ.getString( "convert.error", + originalClass.getName(), + destination.getName() ); + throw new ConverterException( message, e ); } } + /** + * Determine the name of the converter to use to convert between + * original and destination classes. + */ private String getConverterName( final Class originalClass, final Class destination ) throws ConverterException { - //TODO: Maybe we should search the source classes hierarchy aswell - for( Class clazz = destination; - clazz != null; - clazz = clazz.getSuperclass() ) + //TODO: Maybe we should search the destination classes hierarchy as well + + // Recursively iterate over the super-types of the original class, + // looking for a converter from source type -> destination type. + // If more than one is found, choose the most specialised. + + Class match = null; + String converterName = null; + ArrayList queue = new ArrayList(); + queue.add( originalClass ); + + while( ! queue.isEmpty() ) { - final String name = - m_registry.getConverterName( originalClass.getName(), - clazz.getName() ); - if( name != null ) + Class clazz = (Class)queue.remove( 0 ); + + // Add superclass and all interfaces + if( clazz.getSuperclass() != null ) + { + queue.add( clazz.getSuperclass() ); + } + final Class[] interfaces = clazz.getInterfaces(); + for( int i = 0; i < interfaces.length; i++ ) + { + queue.add( interfaces[i ] ); + } + + // Check if we can convert from current class to destination + final String name = m_registry.getConverterName( clazz.getName(), + destination.getName() ); + if( name == null ) + { + continue; + } + + // Choose the more specialised source class + if( match == null || match.isAssignableFrom( clazz ) ) { - return name; + match = clazz; + converterName = name; } + else if( clazz.isAssignableFrom( clazz ) ) + { + continue; + } + else + { + // Duplicate + final String message = REZ.getString( "ambiguous-converter.error" ); + throw new ConverterException( message ); + } + } + + // TODO - should cache the (src, dest) -> converter mapping + if( match != null ) + { + return converterName; } - final String message = - REZ.getString( "no-converter.error", - originalClass.getName(), - destination.getName() ); + // Could not find a converter + final String message = REZ.getString( "no-converter.error" ); throw new ConverterException( message ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/Resources.properties index 7848babff..95b7b7f69 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/Resources.properties +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter/Resources.properties @@ -1,7 +1,5 @@ -converter-lookup.notice=Looking for converter from {0} to {1}. -found-converter.notice=Found Converter: {0}. - -no-converter-factory.error=Unable to retrieve Converter factory from TypeManager. -no-converter.error=Unable to find converter for {0} to {1} conversion. +convert.error=Could not convert from {0} to {1}. +no-converter.error=Could not find an appropriate converter. bad-typemanager.error=Badly configured TypeManager missing converter definition. -bad-return-type.error=The TypeManager for {0} returned "{1}" which is not of the expected type {2}. +bad-return-type.error=Converter {0} returned an object of type {1} which is assignable to the expected type {2}. +ambiguous-converter.error=More than one converter available for this conversion. diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java index 861580d11..08f0afd66 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java @@ -261,7 +261,7 @@ public class DefaultDeployer final String name = roleDef.getShortHand(); final String role = roleDef.getRoleName(); final Class type = deployment.getClassLoader().loadClass( role ); - final RoleInfo roleInfo = new RoleInfo( role, name, type ); + final RoleInfo roleInfo = new RoleInfo( role, name, type, null ); m_roleManager.addRole( roleInfo ); if( getLogger().isDebugEnabled() ) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java index b6929f6e1..1882401c2 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java @@ -12,6 +12,7 @@ import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.apache.aut.converter.Converter; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.excalibur.io.ExtensionFileFilter; @@ -29,7 +30,6 @@ import org.apache.myrmidon.interfaces.aspect.AspectManager; import org.apache.myrmidon.interfaces.builder.ProjectBuilder; import org.apache.myrmidon.interfaces.configurer.Configurer; import org.apache.myrmidon.interfaces.converter.ConverterRegistry; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.deployer.Deployer; import org.apache.myrmidon.interfaces.deployer.DeploymentException; import org.apache.myrmidon.interfaces.deployer.TypeDeployer; @@ -246,7 +246,7 @@ public class DefaultEmbeddor // Create the components createComponent( ConverterRegistry.class, PREFIX + "converter.DefaultConverterRegistry" ); createComponent( ExtensionManager.class, PREFIX + "extensions.DefaultExtensionManager" ); - createComponent( MasterConverter.class, PREFIX + "converter.DefaultMasterConverter" ); + createComponent( Converter.class, PREFIX + "converter.DefaultMasterConverter" ); createComponent( Configurer.class, PREFIX + "configurer.DefaultConfigurer" ); createComponent( TypeManager.class, PREFIX + "type.DefaultTypeManager" ); createComponent( RoleManager.class, PREFIX + "role.DefaultRoleManager" ); diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java index 23c80f910..5f0d44309 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java @@ -13,9 +13,9 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; -import org.apache.avalon.framework.service.Serviceable; 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.Task; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; @@ -24,7 +24,6 @@ import org.apache.myrmidon.interfaces.executor.ExecutionFrame; import org.apache.myrmidon.interfaces.executor.Executor; import org.apache.myrmidon.interfaces.type.TypeException; import org.apache.myrmidon.interfaces.type.TypeFactory; -import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; /** * The basic executor that just executes the tasks. @@ -103,8 +102,7 @@ public class DefaultExecutor { try { - final TaskContextAdapter context = new TaskContextAdapter( taskContext ); - m_configurer.configure( task, taskModel, context ); + m_configurer.configure( task, taskModel, taskContext ); } catch( final Throwable throwable ) { diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/MultiSourceTypeFactory.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/MultiSourceTypeFactory.java index c1f6ca4bb..38a0fb6bf 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/MultiSourceTypeFactory.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/MultiSourceTypeFactory.java @@ -14,7 +14,7 @@ import org.apache.myrmidon.interfaces.type.TypeException; import org.apache.myrmidon.interfaces.type.TypeFactory; /** - * This factory acts as a proxy to set of object factorys. + * This factory acts as a proxy to set of object factories. * * @author Peter Donald * @version $Revision$ $Date$ @@ -29,9 +29,9 @@ public class MultiSourceTypeFactory private final MultiSourceTypeFactory m_parent; ///Map of name->factory list - private final HashMap m_factorys = new HashMap(); + private final HashMap m_factories = new HashMap(); - ///Type expected to be created from factorys + ///Type expected to be created from factories private final Class m_type; public MultiSourceTypeFactory( final Class type ) @@ -51,7 +51,7 @@ public class MultiSourceTypeFactory */ public void register( final String name, final TypeFactory factory ) { - m_factorys.put( name, factory ); + m_factories.put( name, factory ); } /** @@ -118,6 +118,6 @@ public class MultiSourceTypeFactory protected final TypeFactory getTypeFactory( final String name ) { - return (TypeFactory)m_factorys.get( name ); + return (TypeFactory)m_factories.get( name ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java index 4d64598db..57d3afc5d 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java @@ -13,14 +13,10 @@ import java.util.Map; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.excalibur.io.FileUtil; -import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.components.configurer.PropertyException; -import org.apache.myrmidon.components.configurer.PropertyUtil; -import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; /** * Default implementation of TaskContext. @@ -73,14 +69,9 @@ public class DefaultTaskContext } /** - * Retrieve an item from the Context. - * - * @param key the key of item - * @return the item stored in context - * @exception ContextException if item not present + * Retrieve a property. */ - public Object get( final Object key ) - throws ContextException + private Object get( final String key ) { final Object data = m_contextData.get( key ); if( null != data ) @@ -96,10 +87,10 @@ public class DefaultTaskContext if( null == m_parent ) { // There was no parent, and no data - throw new ContextException( "Unable to locate " + key ); + return null; } - return m_parent.getProperty( key.toString() ); + return m_parent.getProperty( key ); } /** @@ -109,15 +100,7 @@ public class DefaultTaskContext */ public String getName() { - try - { - return (String)get( NAME ); - } - catch( final ContextException ce ) - { - final String message = REZ.getString( "no-name.error" ); - throw new IllegalStateException( message ); - } + return (String)get( NAME ); } /** @@ -127,15 +110,7 @@ public class DefaultTaskContext */ public File getBaseDirectory() { - try - { - return (File)get( BASE_DIRECTORY ); - } - catch( final ContextException ce ) - { - final String message = REZ.getString( "no-dir.error" ); - throw new IllegalStateException( message ); - } + return (File)get( BASE_DIRECTORY ); } /** @@ -205,10 +180,8 @@ public class DefaultTaskContext { try { - final TaskContextAdapter context = new TaskContextAdapter( this ); - final Object object = - PropertyUtil.resolveProperty( value, context, false ); + PropertyUtil.resolveProperty( value, this, false ); if( null == object ) { @@ -218,10 +191,10 @@ public class DefaultTaskContext return object; } - catch( final PropertyException pe ) + catch( final TaskException te ) { final String message = REZ.getString( "bad-resolve.error", value ); - throw new TaskException( message, pe ); + throw new TaskException( message, te ); } } @@ -233,14 +206,7 @@ public class DefaultTaskContext */ public Object getProperty( final String name ) { - try - { - return get( name ); - } - catch( final ContextException ce ) - { - return null; - } + return get( name ); } /** @@ -248,7 +214,7 @@ public class DefaultTaskContext * * @return the map of all property names to values */ - public Map getPropertys() + public Map getProperties() { return null; } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java index 935d88504..4cc90e7bf 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java @@ -59,7 +59,7 @@ public class DefaultWorkspace private ServiceManager m_serviceManager; private Parameters m_parameters; private TaskContext m_baseContext; - private HashMap m_entrys = new HashMap(); + private HashMap m_entries = new HashMap(); private TypeManager m_typeManager; private Deployer m_deployer; private Hierarchy m_hierarchy; @@ -279,7 +279,7 @@ public class DefaultWorkspace private ProjectEntry getProjectEntry( final Project project ) throws TaskException { - ProjectEntry entry = (ProjectEntry)m_entrys.get( project ); + ProjectEntry entry = (ProjectEntry)m_entries.get( project ); if( null == entry ) { @@ -287,7 +287,7 @@ public class DefaultWorkspace { final ExecutionFrame frame = createExecutionFrame( project ); entry = new ProjectEntry( project, frame ); - m_entrys.put( project, entry ); + m_entries.put( project, entry ); } catch( Exception e ) { diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyUtil.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/PropertyUtil.java similarity index 83% rename from proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyUtil.java rename to proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/PropertyUtil.java index 1c10f658f..09a92f23e 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyUtil.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/PropertyUtil.java @@ -5,15 +5,15 @@ * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ -package org.apache.myrmidon.components.configurer; +package org.apache.myrmidon.components.workspace; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.framework.context.Context; -import org.apache.avalon.framework.context.ContextException; +import org.apache.myrmidon.api.Context; +import org.apache.myrmidon.api.TaskException; /** - * Utility class to evaluate propertys. + * Utility class to evaluate properties. * * @author Peter Donald * @version $Revision$ $Date$ @@ -33,14 +33,14 @@ public final class PropertyUtil * * @param property the property to resolve * @param context the context in which to resolve property - * @param ignoreUndefined if false will throw an PropertyException if property is not found + * @param ignoreUndefined if false will throw an TaskException if property is not found * @return the reolved property - * @exception PropertyException if an error occurs + * @exception TaskException if an error occurs */ public static Object resolveProperty( final String property, final Context context, final boolean ignoreUndefined ) - throws PropertyException + throws TaskException { int start = findBeginning( property, 0 ); if( -1 == start ) @@ -94,14 +94,14 @@ public final class PropertyUtil * * @param property the property to resolve * @param context the context in which to resolve property - * @param ignoreUndefined if false will throw an PropertyException if property is not found + * @param ignoreUndefined if false will throw an TaskException if property is not found * @return the reolved property - * @exception PropertyException if an error occurs + * @exception TaskException if an error occurs */ public static Object recursiveResolveProperty( final String property, final Context context, final boolean ignoreUndefined ) - throws PropertyException + throws TaskException { int start = findBeginning( property, 0 ); if( -1 == start ) @@ -156,21 +156,21 @@ public final class PropertyUtil } private static int findEnding( final String property, final int currentPosition ) - throws PropertyException + throws TaskException { //TODO: Check if it is commented out final int index = property.indexOf( '}', currentPosition ); if( -1 == index ) { final String message = REZ.getString( "prop.mismatched-braces.error" ); - throw new PropertyException( message ); + throw new TaskException( message ); } return index; } private static int findNestedEnding( final String property, final int currentPosition ) - throws PropertyException + throws TaskException { final int length = property.length(); final int start = currentPosition + 2; @@ -204,42 +204,36 @@ public final class PropertyUtil } final String message = REZ.getString( "prop.mismatched-braces.error" ); - throw new PropertyException( message ); + throw new TaskException( message ); } /** * Retrieve a value from the specified context using the specified key. * If there is no such value and ignoreUndefined is not false then a - * PropertyException is generated. + * TaskException is generated. * * @param key the key of value in context * @param context the Context * @param ignoreUndefined true if undefined variables are ignored * @return the object retrieved from context - * @exception PropertyException if an error occurs + * @exception TaskException if an error occurs */ private static Object resolveValue( final String key, final Context context, final boolean ignoreUndefined ) - throws PropertyException + throws TaskException { - try + final Object value = context.getProperty( key ); + if( value != null ) { - return context.get( key ); + return value; } - catch( final ContextException ce ) + if( ignoreUndefined ) { - if( ignoreUndefined ) - { - return ""; - } - else - { - final String message = - REZ.getString( "prop.missing-value.error", key ); - throw new PropertyException( message ); - } + return ""; } + final String message = REZ.getString( "prop.missing-value.error", key ); + throw new TaskException( message ); } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties index ab5ef4927..582395c6b 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties @@ -20,4 +20,8 @@ bad-property.error=Property {0} must have a value of type {1}. null-resolved-value.error=Value "{0}" resolved to null. bad-resolve.error=Unable to resolve value "{0}". bad-find-service.error=Could not find service "{0}". -bad-service-class.error=Find service "{0}" but it was of type {1} where it was expected to be of type {2}. \ No newline at end of file +bad-service-class.error=Find service "{0}" but it was of type {1} where it was expected to be of type {2}. + +#PropertyUtil +prop.mismatched-braces.error=Malformed property with mismatched }'s. +prop.missing-value.error=Unable to find "{0}" to expand during property resolution. diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java index 307a8380c..6eb652e70 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java @@ -7,6 +7,8 @@ */ package org.apache.myrmidon.framework; +import org.apache.aut.converter.Converter; +import org.apache.aut.converter.ConverterException; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.Configuration; @@ -14,15 +16,11 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.myrmidon.api.AbstractTask; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; -import org.apache.aut.converter.Converter; -import org.apache.aut.converter.ConverterException; import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.executor.Executor; import org.apache.myrmidon.interfaces.type.TypeException; import org.apache.myrmidon.interfaces.type.TypeFactory; import org.apache.myrmidon.interfaces.type.TypeManager; -import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; /** * This is the class that Task writers should extend to provide custom tasks. @@ -37,7 +35,7 @@ public abstract class AbstractContainerTask ResourceManager.getPackageResources( AbstractContainerTask.class ); ///For converting own attributes - private MasterConverter m_converter; + private Converter m_converter; ///For configuring own sub-elements private Configurer m_configurer; @@ -55,7 +53,7 @@ public abstract class AbstractContainerTask { super.contextualize( context ); m_configurer = (Configurer)getService( Configurer.class ); - m_converter = (MasterConverter)getService( MasterConverter.class ); + m_converter = (Converter)getService( Converter.class ); m_executor = (Executor)getService( Executor.class ); } @@ -91,8 +89,7 @@ public abstract class AbstractContainerTask protected final void configure( final Object object, final Configuration element ) throws ConfigurationException { - final TaskContextAdapter context = new TaskContextAdapter( getContext() ); - getConfigurer().configure( object, element, context ); + getConfigurer().configure( object, element, getContext() ); } /** @@ -106,8 +103,7 @@ public abstract class AbstractContainerTask protected final void configure( final Object object, final String name, final String value ) throws ConfigurationException { - final TaskContextAdapter context = new TaskContextAdapter( getContext() ); - getConfigurer().configure( object, name, value, context ); + getConfigurer().configure( object, name, value, getContext() ); } /** diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/ExecManagerFactory.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/ExecManagerFactory.java similarity index 97% rename from proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/ExecManagerFactory.java rename to proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/ExecManagerFactory.java index 29a3eb75e..7c3cedef2 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/ExecManagerFactory.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/ExecManagerFactory.java @@ -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.framework.factorys; +package org.apache.myrmidon.framework.factories; import java.io.File; import org.apache.aut.nativelib.ExecException; diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/Resources.properties similarity index 100% rename from proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/Resources.properties rename to proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/Resources.properties diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/VfsManagerFactory.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/VfsManagerFactory.java similarity index 96% rename from proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/VfsManagerFactory.java rename to proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/VfsManagerFactory.java index fdc39cb90..4ff530dcb 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/VfsManagerFactory.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factories/VfsManagerFactory.java @@ -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.framework.factorys; +package org.apache.myrmidon.framework.factories; import org.apache.aut.vfs.FileSystemManager; import org.apache.aut.vfs.impl.DefaultFileSystemManager; diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/Configurer.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/Configurer.java index 24dc1d34f..8f83281b4 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/Configurer.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/Configurer.java @@ -9,7 +9,7 @@ package org.apache.myrmidon.interfaces.configurer; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.context.Context; +import org.apache.myrmidon.api.Context; /** * Class used to configure tasks. diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java deleted file mode 100644 index 8f8be0164..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/configurer/TaskContextAdapter.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.configurer; - -import org.apache.avalon.framework.context.Context; -import org.apache.avalon.framework.context.ContextException; -import org.apache.avalon.framework.context.Resolvable; -import org.apache.myrmidon.api.TaskContext; - -/** - * This class adpats the TaskContext API to the Avalon Context API. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class TaskContextAdapter - implements Context, Resolvable -{ - private final TaskContext m_context; - - public TaskContextAdapter( final TaskContext context ) - { - m_context = context; - } - - public Object resolve( Context context ) - throws ContextException - { - return m_context; - } - - public Object get( Object key ) - throws ContextException - { - final Object value = m_context.getProperty( key.toString() ); - if( null != value ) - { - return value; - } - else - { - throw new ContextException( "Missing key " + key ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/converter/MasterConverter.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/converter/MasterConverter.java deleted file mode 100644 index f6478337d..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/converter/MasterConverter.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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.converter; - -import org.apache.aut.converter.Converter; - -/** - * Master Converter to handle converting between types. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public interface MasterConverter - extends Converter -{ - String ROLE = MasterConverter.class.getName(); -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleInfo.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleInfo.java index 340df5e2c..f04dc33d1 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleInfo.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/role/RoleInfo.java @@ -20,6 +20,7 @@ public final class RoleInfo private final String m_name; private final String m_shorthand; private final Class m_type; + private final String m_defaultType; /** * Creates a role definition. @@ -28,9 +29,7 @@ public final class RoleInfo */ public RoleInfo( final String name ) { - m_name = name; - m_shorthand = null; - m_type = null; + this( name, null, null, null ); } /** @@ -41,9 +40,7 @@ public final class RoleInfo */ public RoleInfo( final String name, final String shorthand ) { - m_name = name; - m_shorthand = shorthand; - m_type = null; + this( name, shorthand, null, null ); } /** @@ -55,9 +52,7 @@ public final class RoleInfo */ public RoleInfo( final String name, final String shorthand, final Class type ) { - m_name = name; - m_shorthand = shorthand; - m_type = type; + this( name, shorthand, type, null ); } /** @@ -66,9 +61,21 @@ public final class RoleInfo */ public RoleInfo( final String shorthand, final Class type ) { - m_name = type.getName(); + this( type.getName(), shorthand, type, null ); + } + + /** + * Creates a role definition. + */ + public RoleInfo( final String name, + final String shorthand, + final Class type, + final String defaultType ) + { + m_name = name; m_shorthand = shorthand; m_type = type; + m_defaultType = defaultType; } /** @@ -127,4 +134,14 @@ public final class RoleInfo { return m_type; } + + /** + * Returns the name of the default implementation of this role. + * + * @return The default type name, or null if this role has no default type. + */ + public String getDefaultType() + { + return m_defaultType; + } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java index 06dd9f026..0dde5c845 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java @@ -88,7 +88,7 @@ public class Script extends AbstractTask { try { - addBeans( getContext().getPropertys() ); + addBeans( getContext().getProperties() ); //In Ant2 there is no difference between properties and references //addBeans( getProject().getReferences() ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 17fa438b6..a8425d085 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -617,7 +617,7 @@ public class JUnitTask extends AbstractTask // Create a temporary file to pass the Ant properties to the forked test File propsFile = new File( "junit" + ( new Random( System.currentTimeMillis() ) ).nextLong() + ".properties" ); cmd.addArgument( "propsfile=" + propsFile.getAbsolutePath() ); - Map p = getContext().getPropertys(); + Map p = getContext().getProperties(); Properties props = new Properties(); for( Iterator enum = p.keySet().iterator(); enum.hasNext(); ) { @@ -663,7 +663,7 @@ public class JUnitTask extends AbstractTask private int executeInVM( JUnitTest test ) throws TaskException { - test.setProperties( getContext().getPropertys() ); + test.setProperties( getContext().getProperties() ); if( dir != null ) { getLogger().warn( "dir attribute ignored if running in the same VM" ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/converters/StringToPathConverter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/converters/StringToPathConverter.java index b7aaf9869..63984cc75 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/converters/StringToPathConverter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/converters/StringToPathConverter.java @@ -7,7 +7,6 @@ */ package org.apache.tools.ant.types.converters; -import org.apache.avalon.framework.context.Context; import org.apache.aut.converter.AbstractConverter; import org.apache.aut.converter.ConverterException; import org.apache.tools.ant.types.Path; diff --git a/proposal/myrmidon/src/manifest/core-services.xml b/proposal/myrmidon/src/manifest/core-services.xml index fa8076bae..b2cfc8883 100644 --- a/proposal/myrmidon/src/manifest/core-services.xml +++ b/proposal/myrmidon/src/manifest/core-services.xml @@ -1,6 +1,6 @@ - - + + diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java index 94c488888..0b541aa18 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java @@ -50,6 +50,9 @@ public class AbstractProjectTest { if( m_embeddor == null ) { + // Need to set the context classloader - The default embeddor uses it + Thread.currentThread().setContextClassLoader( getClass().getClassLoader() ); + final Logger logger = createLogger(); m_embeddor = new DefaultEmbeddor(); m_embeddor.enableLogging( logger ); diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java index 8c37267db..24be1370c 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java @@ -29,9 +29,9 @@ import org.apache.myrmidon.components.role.DefaultRoleManager; import org.apache.myrmidon.components.type.DefaultTypeManager; import org.apache.myrmidon.interfaces.configurer.Configurer; import org.apache.myrmidon.interfaces.converter.ConverterRegistry; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.deployer.Deployer; import org.apache.myrmidon.interfaces.extensions.ExtensionManager; +import org.apache.myrmidon.interfaces.role.RoleInfo; import org.apache.myrmidon.interfaces.role.RoleManager; import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; import org.apache.myrmidon.interfaces.type.TypeException; @@ -83,7 +83,7 @@ public abstract class AbstractComponentTest List components = new ArrayList(); Object component = new DefaultMasterConverter(); - m_serviceManager.put( MasterConverter.ROLE, component ); + m_serviceManager.put( Converter.ROLE, component ); components.add( component ); component = new DefaultConverterRegistry(); @@ -138,6 +138,29 @@ public abstract class AbstractComponentTest } } + /** + * Utility method to register a role. + */ + protected void registerRole( final RoleInfo roleInfo ) + throws Exception + { + RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); + roleMgr.addRole( roleInfo ); + } + + /** + * Utility method to register a type. + */ + protected void registerType( final Class roleType, + final String typeName, + final Class type ) + throws Exception + { + final ClassLoader loader = getClass().getClassLoader(); + final DefaultTypeFactory factory = new DefaultTypeFactory( loader ); + factory.addNameClassMapping( typeName, type.getName() ); + getTypeManager().registerType( roleType, typeName, factory ); + } /** * Utility method to register a Converter. diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java index b0b16f150..4d7cfd299 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest4.java @@ -7,8 +7,7 @@ */ package org.apache.myrmidon.components.configurer; -import java.util.ArrayList; -import junit.framework.AssertionFailedError; + /** * Simple class to test typed adder. diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest8.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestConfigProps.java similarity index 87% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest8.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestConfigProps.java index d1792f33c..35e9751ef 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest8.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestConfigProps.java @@ -8,7 +8,6 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; -import junit.framework.AssertionFailedError; import org.apache.avalon.framework.configuration.Configuration; /** @@ -17,7 +16,7 @@ import org.apache.avalon.framework.configuration.Configuration; * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest8 +public class ConfigTestConfigProps { private ArrayList m_configurations = new ArrayList(); @@ -28,7 +27,7 @@ public class ConfigTest8 public boolean equals( final Object object ) { - final ConfigTest8 other = (ConfigTest8)object; + final ConfigTestConfigProps other = (ConfigTestConfigProps)object; return m_configurations.equals( other.m_configurations ); } } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest9.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestConfigurable.java similarity index 82% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest9.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestConfigurable.java index 7ed334b30..9f3898fde 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest9.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestConfigurable.java @@ -7,19 +7,17 @@ */ package org.apache.myrmidon.components.configurer; -import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; /** - * Simple class to test adder for Configurations. + * Simple class to test {@link Configurable}. * * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest9 +public class ConfigTestConfigurable implements Configurable { private Configuration m_configuration; @@ -32,7 +30,7 @@ public class ConfigTest9 public boolean equals( final Object object ) { - final ConfigTest9 other = (ConfigTest9)object; + final ConfigTestConfigurable other = (ConfigTestConfigurable)object; return m_configuration == other.m_configuration; } } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestInterfaceProp.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestInterfaceProp.java new file mode 100644 index 000000000..14c4ef669 --- /dev/null +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestInterfaceProp.java @@ -0,0 +1,32 @@ +/* + * 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.configurer; + +import java.util.ArrayList; + +/** + * A test class with an interface property. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public class ConfigTestInterfaceProp +{ + private final ArrayList m_elems = new ArrayList(); + + public void addPropA( final MyRole1 role1 ) + { + m_elems.add( role1 ); + } + + public boolean equals( Object obj ) + { + final ConfigTestInterfaceProp test = (ConfigTestInterfaceProp)obj; + return m_elems.equals( test.m_elems ); + } +} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestMultiSetter.java similarity index 79% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestMultiSetter.java index d8882d26d..330f203c8 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest3.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestMultiSetter.java @@ -15,15 +15,15 @@ import junit.framework.AssertionFailedError; * * @author Adam Murdoch */ -public class ConfigTest3 +public class ConfigTestMultiSetter { - private ConfigTest1 m_prop1; - private ConfigTest1 m_prop2; + private ConfigTestStringProps m_prop1; + private ConfigTestStringProps m_prop2; private ArrayList m_prop3 = new ArrayList(); public boolean equals( Object obj ) { - ConfigTest3 test = (ConfigTest3)obj; + ConfigTestMultiSetter test = (ConfigTestMultiSetter)obj; if( !DefaultConfigurerTest.equals( m_prop1, test.m_prop1 ) ) { return false; @@ -48,7 +48,7 @@ public class ConfigTest3 throw new AssertionFailedError(); } - public void setProp1( final ConfigTest1 value ) + public void setProp1( final ConfigTestStringProps value ) { m_prop1 = value; } @@ -62,7 +62,7 @@ public class ConfigTest3 throw new AssertionFailedError(); } - public void setProp2( final ConfigTest1 value ) + public void setProp2( final ConfigTestStringProps value ) { m_prop2 = value; } @@ -76,7 +76,7 @@ public class ConfigTest3 throw new AssertionFailedError(); } - public void addProp3( final ConfigTest1 value ) + public void addProp3( final ConfigTestStringProps value ) { m_prop3.add( value ); } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestMultiTypedAdder.java similarity index 72% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestMultiTypedAdder.java index 7d727acce..0eb4c5d41 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest5.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestMultiTypedAdder.java @@ -7,17 +7,15 @@ */ package org.apache.myrmidon.components.configurer; -import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.avalon.framework.configuration.Configuration; + /** - * Simple class to test typed adder. + * Simple class with more than one typed adder method. * * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest5 +public class ConfigTestMultiTypedAdder { public void add( final MyRole1 role1 ) { diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestObjectProps.java similarity index 76% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest2.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestObjectProps.java index b1f061dc4..d829e8100 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest2.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestObjectProps.java @@ -15,14 +15,14 @@ import java.util.List; * * @author Adam Murdoch */ -public class ConfigTest2 +public class ConfigTestObjectProps { - ConfigTest1 m_prop; + ConfigTestStringProps m_prop; List m_propList = new ArrayList(); public boolean equals( Object obj ) { - ConfigTest2 test = (ConfigTest2)obj; + ConfigTestObjectProps test = (ConfigTestObjectProps)obj; if( !DefaultConfigurerTest.equals( m_prop, test.m_prop ) ) { return false; @@ -34,12 +34,12 @@ public class ConfigTest2 return true; } - public void setProp( final ConfigTest1 test ) + public void setProp( final ConfigTestStringProps test ) { m_prop = test; } - public void addAnotherProp( final ConfigTest1 test ) + public void addAnotherProp( final ConfigTestStringProps test ) { m_propList.add( test ); } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest10.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestPrimConvert.java similarity index 81% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest10.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestPrimConvert.java index e7a67f032..4a204f7f6 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest10.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestPrimConvert.java @@ -14,24 +14,24 @@ import org.apache.myrmidon.components.AbstractComponentTest; * * @author Adam Murdoch */ -public class ConfigTest10 +public class ConfigTestPrimConvert { private int m_intProp; private Integer m_integerProp; - public void setIntProp( int intProp ) + public void setIntProp( final int intProp ) { m_intProp = intProp; } - public void setIntegerProp( Integer integerProp ) + public void setIntegerProp( final Integer integerProp ) { m_integerProp = integerProp; } public boolean equals( Object obj ) { - ConfigTest10 test = (ConfigTest10)obj; + ConfigTestPrimConvert test = (ConfigTestPrimConvert)obj; if( m_intProp != test.m_intProp ) { return false; diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestStringProps.java similarity index 84% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest1.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestStringProps.java index a45169128..0d1f42c6c 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest1.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestStringProps.java @@ -9,13 +9,15 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; import java.util.List; +import org.apache.myrmidon.framework.DataType; /** - * A simple test class. + * A simple test class with string properties. * * @author Adam Murdoch */ -public class ConfigTest1 +public class ConfigTestStringProps + implements DataType { private String m_someProp; private List m_propList = new ArrayList(); @@ -23,7 +25,7 @@ public class ConfigTest1 public boolean equals( final Object obj ) { - final ConfigTest1 test = (ConfigTest1)obj; + final ConfigTestStringProps test = (ConfigTestStringProps)obj; if( !DefaultConfigurerTest.equals( m_someProp, test.m_someProp ) ) { return false; diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest7.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestTypedConfigProp.java similarity index 87% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest7.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestTypedConfigProp.java index b10c7f990..fd7ec3e87 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest7.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestTypedConfigProp.java @@ -8,7 +8,6 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; -import junit.framework.AssertionFailedError; import org.apache.avalon.framework.configuration.Configuration; /** @@ -17,7 +16,7 @@ import org.apache.avalon.framework.configuration.Configuration; * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest7 +public class ConfigTestTypedConfigProp { private ArrayList m_configurations = new ArrayList(); @@ -28,7 +27,7 @@ public class ConfigTest7 public boolean equals( final Object object ) { - final ConfigTest7 other = (ConfigTest7)object; + final ConfigTestTypedConfigProp other = (ConfigTestTypedConfigProp)object; return m_configurations.equals( other.m_configurations ); } } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest6.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestTypedProp.java similarity index 79% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest6.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestTypedProp.java index 7f67ae5c5..361744716 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest6.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTestTypedProp.java @@ -8,8 +8,6 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.avalon.framework.configuration.Configuration; /** * Simple class to test typed adder. @@ -17,7 +15,7 @@ import org.apache.avalon.framework.configuration.Configuration; * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest6 +public class ConfigTestTypedProp { private ArrayList m_roles = new ArrayList(); @@ -28,7 +26,7 @@ public class ConfigTest6 public boolean equals( final Object object ) { - final ConfigTest6 other = (ConfigTest6)object; + final ConfigTestTypedProp other = (ConfigTestTypedProp)object; return m_roles.equals( other.m_roles ); } } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java index 074489d65..b569488b6 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java @@ -13,16 +13,12 @@ import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfiguration; -import org.apache.avalon.framework.context.Context; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.components.AbstractComponentTest; import org.apache.myrmidon.components.workspace.DefaultTaskContext; import org.apache.myrmidon.framework.DataType; import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; import org.apache.myrmidon.interfaces.role.RoleInfo; -import org.apache.myrmidon.interfaces.role.RoleManager; -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; /** * Test cases for the default configurer and related classes. @@ -37,7 +33,6 @@ public class DefaultConfigurerTest private Configurer m_configurer; private DefaultTaskContext m_context; - private Context m_adaptor; public DefaultConfigurerTest( String name ) { @@ -59,7 +54,6 @@ public class DefaultConfigurerTest m_context = new DefaultTaskContext(); final File baseDir = new File( "." ).getAbsoluteFile(); m_context.setProperty( TaskContext.BASE_DIRECTORY, baseDir ); - m_adaptor = new TaskContextAdapter( m_context ); } /** @@ -75,13 +69,13 @@ public class DefaultConfigurerTest final String value2 = "some other value"; config.setAttribute( "prop", value2 ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( value1 ); expected.addProp( value2 ); assertEquals( expected, test ); @@ -99,18 +93,15 @@ public class DefaultConfigurerTest config.setAttribute( "integer-prop", "-401" ); // Register the converter - final Class converterClass = StringToIntegerConverter.class; - final Class sourceClass = String.class; - final Class destClass = Integer.class; - registerConverter( converterClass, sourceClass, destClass ); + registerConverter( StringToIntegerConverter.class, String.class, Integer.class ); - final ConfigTest10 test = new ConfigTest10(); + final ConfigTestPrimConvert test = new ConfigTestPrimConvert(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest10 expected = new ConfigTest10(); + final ConfigTestPrimConvert expected = new ConfigTestPrimConvert(); expected.setIntProp( 90 ); expected.setIntegerProp( new Integer(-401) ); assertEquals( expected, test ); @@ -126,12 +117,12 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "unknown", "some value" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -158,17 +149,17 @@ public class DefaultConfigurerTest child2.setAttribute( "some-prop", value2 ); config.addChild( child2 ); - final ConfigTest2 test = new ConfigTest2(); + final ConfigTestObjectProps test = new ConfigTestObjectProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest2 expected = new ConfigTest2(); - ConfigTest1 elem = new ConfigTest1(); + final ConfigTestObjectProps expected = new ConfigTestObjectProps(); + ConfigTestStringProps elem = new ConfigTestStringProps(); elem.setSomeProp( value1 ); expected.setProp( elem ); - elem = new ConfigTest1(); + elem = new ConfigTestStringProps(); elem.setSomeProp( value2 ); expected.addAnotherProp( elem ); assertEquals( expected, test ); @@ -185,12 +176,12 @@ public class DefaultConfigurerTest final DefaultConfiguration elem = new DefaultConfiguration( "unknown", "test" ); config.addChild( elem ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -211,13 +202,13 @@ public class DefaultConfigurerTest final String value1 = "some value"; config.setValue( value1 ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.addContent( value1 ); assertEquals( expected, test ); } @@ -232,12 +223,12 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setValue( "some value" ); - final ConfigTest2 test = new ConfigTest2(); + final ConfigTestObjectProps test = new ConfigTestObjectProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -257,15 +248,15 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "prop", "some ${prop-a} value" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "prop-a", "other" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.addProp( "some other value" ); assertEquals( expected, test ); } @@ -279,15 +270,15 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "prop-a" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "prop-a", "some value" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( "some value" ); assertEquals( expected, test ); } @@ -303,15 +294,15 @@ public class DefaultConfigurerTest elem.setAttribute( "id", "prop-a" ); config.addChild( elem ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "prop-a", "some value" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( "some value" ); assertEquals( expected, test ); } @@ -329,12 +320,12 @@ public class DefaultConfigurerTest elem.setAttribute( "extra-attr", "some value" ); config.addChild( elem ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -347,6 +338,57 @@ public class DefaultConfigurerTest } } + /** + * Tests reference type conversion. + */ + public void testReferenceConversion() throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + config.setAttribute( "prop-a-ref", "id" ); + + final Integer refValue = new Integer( 21 ); + m_context.setProperty( "id", refValue ); + + registerConverter( ObjectToMyRole1Converter.class, Object.class, MyRole1.class ); + + final ConfigTestInterfaceProp test = new ConfigTestInterfaceProp(); + + // Configure + m_configurer.configure( test, config, m_context ); + + // Check result + final ConfigTestInterfaceProp expected = new ConfigTestInterfaceProp(); + expected.addPropA( new MyRole1Adaptor( refValue ) ); + assertEquals( expected, test ); + } + + /** + * Tests that the role's default type is used for interface typed + * elements. + */ + public void testInterfaceAdder() + throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + final DefaultConfiguration child = new DefaultConfiguration( "prop-a", "test" ); + config.addChild( child ); + + registerRole( new RoleInfo( "myrole1", null, MyRole1.class, "default-type" ) ); + registerType( MyRole1.class, "default-type", MyType1.class ); + + final ConfigTestInterfaceProp test = new ConfigTestInterfaceProp(); + + // Configure object + m_configurer.configure( test, config, m_context ); + + // Check result + final ConfigTestInterfaceProp expected = new ConfigTestInterfaceProp(); + expected.addPropA( new MyType1() ); + assertEquals( expected, test ); + } + /** * Tests whether an object with a non-iterface typed adder causes an * exception. @@ -362,7 +404,7 @@ public class DefaultConfigurerTest try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -386,12 +428,12 @@ public class DefaultConfigurerTest // Setup test data final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final ConfigTest5 test = new ConfigTest5(); + final ConfigTestMultiTypedAdder test = new ConfigTestMultiTypedAdder(); try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -399,7 +441,7 @@ public class DefaultConfigurerTest final String[] messages = { REZ.getString( "bad-configure-element.error", "test" ), REZ.getString( "multiple-adder-methods-for-element.error", - ConfigTest5.class.getName(), + ConfigTestMultiTypedAdder.class.getName(), "") }; assertSameMessage( messages, ce ); @@ -419,24 +461,75 @@ public class DefaultConfigurerTest config.addChild( child1 ); config.addChild( child2 ); - final ClassLoader loader = getClass().getClassLoader(); - final DefaultTypeFactory factory = new DefaultTypeFactory( loader ); - factory.addNameClassMapping( "my-type1", MyType1.class.getName() ); - factory.addNameClassMapping( "my-type2", MyType2.class.getName() ); - getTypeManager().registerType( DataType.class, "my-type1", factory ); - getTypeManager().registerType( DataType.class, "my-type2", factory ); + registerType( DataType.class, "my-type1", MyType1.class ); + registerType( DataType.class, "my-type2", MyType2.class ); - final ConfigTest6 test = new ConfigTest6(); + final ConfigTestTypedProp test = new ConfigTestTypedProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest6 expected = new ConfigTest6(); + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); expected.add( new MyType1() ); expected.add( new MyType2() ); assertEquals( expected, test ); } + /** + * Tests to check that role is used for typed adder. + */ + public void testTypedAdderRole() + throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + final DefaultConfiguration child1 = new DefaultConfiguration( "my-type1", "test" ); + config.addChild( child1 ); + + // Register incompatible types with the same name, as data-type and myrole1. + registerRole( new RoleInfo( "myrole1", "myrole1", MyRole1.class ) ); + registerType( MyRole1.class, "my-type1", MyType1.class ); + registerType( DataType.class, "my-type1", StringBuffer.class ); + + final ConfigTestTypedProp test = new ConfigTestTypedProp(); + + // Configure the object + m_configurer.configure( test, config, m_context ); + + // Check the result + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); + expected.add( new MyType1() ); + assertEquals( expected, test ); + } + + /** + * Tests conversion with a typed adder. + */ + public void testTypedAdderConversion() + throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + final DefaultConfiguration child = new DefaultConfiguration( "some-type", "test" ); + child.setAttribute( "prop", "some value" ); + config.addChild( child ); + + registerType( DataType.class, "some-type", ConfigTestStringProps.class ); + registerConverter( ObjectToMyRole1Converter.class, Object.class, MyRole1.class ); + + final ConfigTestTypedProp test = new ConfigTestTypedProp(); + + // Configure the object + m_configurer.configure( test, config, m_context ); + + // Check the result + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); + final ConfigTestStringProps nested = new ConfigTestStringProps(); + nested.addProp( "some value" ); + expected.add( new MyRole1Adaptor( nested ) ); + assertEquals( expected, test ); + } + /** * Tests to see if typed adder can be used via an attribute. */ @@ -448,19 +541,17 @@ public class DefaultConfigurerTest config.setAttribute( "my-role1", "some value" ); // Set up the converter and role - RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - final RoleInfo roleInfo = new RoleInfo("my-role1", MyRole1.class ); - roleMgr.addRole( roleInfo ); - registerConverter( StringToMyRole1Converter.class, String.class, MyRole1.class ); + registerRole( new RoleInfo("my-role1", MyRole1.class ) ); + registerConverter( ObjectToMyRole1Converter.class, String.class, MyRole1.class ); - final ConfigTest6 test = new ConfigTest6(); + final ConfigTestTypedProp test = new ConfigTestTypedProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest6 expected = new ConfigTest6(); - expected.add( new MyType1() ); + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); + expected.add( new MyRole1Adaptor( "some value" ) ); assertEquals( expected, test ); } @@ -477,12 +568,12 @@ public class DefaultConfigurerTest config.addChild( child1 ); config.addChild( child2 ); - final ConfigTest7 test = new ConfigTest7(); + final ConfigTestTypedConfigProp test = new ConfigTestTypedConfigProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest7 expected = new ConfigTest7(); + final ConfigTestTypedConfigProp expected = new ConfigTestTypedConfigProp(); expected.add( child1 ); expected.add( child2 ); assertEquals( expected, test ); @@ -501,12 +592,12 @@ public class DefaultConfigurerTest config.addChild( child1 ); config.addChild( child2 ); - final ConfigTest8 test = new ConfigTest8(); + final ConfigTestConfigProps test = new ConfigTestConfigProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest8 expected = new ConfigTest8(); + final ConfigTestConfigProps expected = new ConfigTestConfigProps(); expected.addConfig( child1 ); expected.addConfig( child2 ); assertEquals( expected, test ); @@ -521,12 +612,12 @@ public class DefaultConfigurerTest // Setup test data final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final ConfigTest9 test = new ConfigTest9(); + final ConfigTestConfigurable test = new ConfigTestConfigurable(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest9 expected = new ConfigTest9(); + final ConfigTestConfigurable expected = new ConfigTestConfigurable(); expected.configure( config ); assertEquals( expected, test ); } @@ -541,22 +632,22 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "${id}" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "id", "prop-a" ); m_context.setProperty( "prop-a", "some indirect value" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( "some indirect value" ); assertEquals( expected, test ); } /** - * Test an unknown reference. + * Tests an unknown reference. */ public void testUnknownReference() throws Exception @@ -565,12 +656,12 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "unknown-prop" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -593,14 +684,14 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "prop-a" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); - m_context.setProperty( "prop-a", new ConfigTest2() ); + m_context.setProperty( "prop-a", new ConfigTestObjectProps() ); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -609,8 +700,7 @@ public class DefaultConfigurerTest REZ.getString( "bad-set-attribute.error", "test", "some-prop-ref" ), REZ.getString( "mismatch-ref-types.error", "prop-a", - String.class.getName(), - ConfigTest2.class.getName() ) + "some-prop" ) }; assertSameMessage( messages, e ); } @@ -631,19 +721,17 @@ public class DefaultConfigurerTest config.addChild( child ); // Add role mapping, and add to reference to context - final RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - final RoleInfo roleInfo = new RoleInfo( "my-role1", MyRole1.class ); - roleMgr.addRole( roleInfo ); + registerRole( new RoleInfo( "my-role1", MyRole1.class ) ); m_context.setProperty( "id", new MyType1() ); m_context.setProperty( "id2", new MyType2() ); - final ConfigTest6 test = new ConfigTest6(); + final ConfigTestTypedProp test = new ConfigTestTypedProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Compare against expected value - final ConfigTest6 expected = new ConfigTest6(); + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); expected.add( new MyType1() ); expected.add( new MyType2() ); assertEquals( expected, test ); @@ -660,12 +748,12 @@ public class DefaultConfigurerTest elem.setAttribute( "not-a-prop", "not-a-value" ); config.addChild( elem ); - final ConfigTest2 test = new ConfigTest2(); + final ConfigTestObjectProps test = new ConfigTestObjectProps(); try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -693,16 +781,16 @@ public class DefaultConfigurerTest elem = new DefaultConfiguration( "prop3", "test" ); config.addChild( elem ); - final ConfigTest3 test = new ConfigTest3(); + final ConfigTestMultiSetter test = new ConfigTestMultiSetter(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Test expected value - final ConfigTest3 expected = new ConfigTest3(); - expected.setProp1( new ConfigTest1() ); - expected.setProp2( new ConfigTest1() ); - expected.addProp3( new ConfigTest1() ); + final ConfigTestMultiSetter expected = new ConfigTestMultiSetter(); + expected.setProp1( new ConfigTestStringProps() ); + expected.setProp2( new ConfigTestStringProps() ); + expected.addProp3( new ConfigTestStringProps() ); assertEquals( expected, test ); } } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1Adaptor.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1Adaptor.java new file mode 100644 index 000000000..a683499d3 --- /dev/null +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/MyRole1Adaptor.java @@ -0,0 +1,33 @@ +/* + * 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.configurer; + +import org.apache.myrmidon.AbstractMyrmidonTest; + +/** + * Adapts an Object to MyRole + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public class MyRole1Adaptor + implements MyRole1 +{ + private final Object m_object; + + public MyRole1Adaptor( final Object o ) + { + m_object = o; + } + + public boolean equals( Object obj ) + { + final MyRole1Adaptor adaptor = (MyRole1Adaptor)obj; + return AbstractMyrmidonTest.equals( m_object, adaptor.m_object ); + } +} diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/StringToMyRole1Converter.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ObjectToMyRole1Converter.java similarity index 70% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/StringToMyRole1Converter.java rename to proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ObjectToMyRole1Converter.java index dbeac97aa..34934097c 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/StringToMyRole1Converter.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ObjectToMyRole1Converter.java @@ -9,24 +9,24 @@ package org.apache.myrmidon.components.configurer; import org.apache.aut.converter.AbstractConverter; import org.apache.aut.converter.ConverterException; -import org.apache.avalon.framework.context.Context; /** - * Converts from a string to a {@link MyRole1} implementation. + * Converts from Object to MyRole1. * * @author Adam Murdoch + * @version $Revision$ $Date$ */ -public class StringToMyRole1Converter +public class ObjectToMyRole1Converter extends AbstractConverter { - public StringToMyRole1Converter() + public ObjectToMyRole1Converter() { - super( String.class, MyRole1.class ); + super( Object.class, MyRole1.class ); } protected Object convert( Object original, Object context ) throws ConverterException { - return new MyType1(); + return new MyRole1Adaptor( original ); } } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java index ebec3f704..3416c45f6 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java @@ -7,21 +7,19 @@ */ package org.apache.myrmidon.components.deployer; +import java.io.File; +import org.apache.aut.converter.Converter; +import org.apache.aut.converter.ConverterException; import org.apache.myrmidon.components.AbstractComponentTest; import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.deployer.ConverterDefinition; import org.apache.myrmidon.interfaces.deployer.Deployer; import org.apache.myrmidon.interfaces.deployer.TypeDefinition; import org.apache.myrmidon.interfaces.deployer.TypeDeployer; -import org.apache.myrmidon.interfaces.role.RoleManager; import org.apache.myrmidon.interfaces.role.RoleInfo; -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.type.TypeException; -import org.apache.aut.converter.ConverterException; -import org.apache.aut.converter.Converter; -import java.io.File; +import org.apache.myrmidon.interfaces.type.TypeFactory; /** * Test cases for the default deployer. @@ -37,7 +35,7 @@ public class DefaultDeployerTest private Deployer m_deployer; private RoleManager m_roleManager; - private MasterConverter m_converter; + private Converter m_converter; public DefaultDeployerTest( final String name ) { @@ -52,7 +50,7 @@ public class DefaultDeployerTest { super.setUp(); m_deployer = (Deployer)getServiceManager().lookup( Deployer.ROLE ); - m_converter = (MasterConverter)getServiceManager().lookup( MasterConverter.ROLE ); + m_converter = (Converter)getServiceManager().lookup( Converter.ROLE ); // Add some core roles m_roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/TestConverter1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/TestConverter1.java index 07c0d9f20..fc9abe6c3 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/TestConverter1.java +++ b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/TestConverter1.java @@ -9,7 +9,6 @@ package org.apache.myrmidon.components.deployer; import org.apache.aut.converter.Converter; import org.apache.aut.converter.ConverterException; -import org.apache.avalon.framework.context.Context; /** * A test converter. diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/AbstractProjectTest.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/AbstractProjectTest.java index 94c488888..0b541aa18 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/AbstractProjectTest.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/AbstractProjectTest.java @@ -50,6 +50,9 @@ public class AbstractProjectTest { if( m_embeddor == null ) { + // Need to set the context classloader - The default embeddor uses it + Thread.currentThread().setContextClassLoader( getClass().getClassLoader() ); + final Logger logger = createLogger(); m_embeddor = new DefaultEmbeddor(); m_embeddor.enableLogging( logger ); diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java index 8c37267db..24be1370c 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java @@ -29,9 +29,9 @@ import org.apache.myrmidon.components.role.DefaultRoleManager; import org.apache.myrmidon.components.type.DefaultTypeManager; import org.apache.myrmidon.interfaces.configurer.Configurer; import org.apache.myrmidon.interfaces.converter.ConverterRegistry; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.deployer.Deployer; import org.apache.myrmidon.interfaces.extensions.ExtensionManager; +import org.apache.myrmidon.interfaces.role.RoleInfo; import org.apache.myrmidon.interfaces.role.RoleManager; import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; import org.apache.myrmidon.interfaces.type.TypeException; @@ -83,7 +83,7 @@ public abstract class AbstractComponentTest List components = new ArrayList(); Object component = new DefaultMasterConverter(); - m_serviceManager.put( MasterConverter.ROLE, component ); + m_serviceManager.put( Converter.ROLE, component ); components.add( component ); component = new DefaultConverterRegistry(); @@ -138,6 +138,29 @@ public abstract class AbstractComponentTest } } + /** + * Utility method to register a role. + */ + protected void registerRole( final RoleInfo roleInfo ) + throws Exception + { + RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); + roleMgr.addRole( roleInfo ); + } + + /** + * Utility method to register a type. + */ + protected void registerType( final Class roleType, + final String typeName, + final Class type ) + throws Exception + { + final ClassLoader loader = getClass().getClassLoader(); + final DefaultTypeFactory factory = new DefaultTypeFactory( loader ); + factory.addNameClassMapping( typeName, type.getName() ); + getTypeManager().registerType( roleType, typeName, factory ); + } /** * Utility method to register a Converter. diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java index b0b16f150..4d7cfd299 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest4.java @@ -7,8 +7,7 @@ */ package org.apache.myrmidon.components.configurer; -import java.util.ArrayList; -import junit.framework.AssertionFailedError; + /** * Simple class to test typed adder. diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest8.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestConfigProps.java similarity index 87% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest8.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestConfigProps.java index d1792f33c..35e9751ef 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest8.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestConfigProps.java @@ -8,7 +8,6 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; -import junit.framework.AssertionFailedError; import org.apache.avalon.framework.configuration.Configuration; /** @@ -17,7 +16,7 @@ import org.apache.avalon.framework.configuration.Configuration; * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest8 +public class ConfigTestConfigProps { private ArrayList m_configurations = new ArrayList(); @@ -28,7 +27,7 @@ public class ConfigTest8 public boolean equals( final Object object ) { - final ConfigTest8 other = (ConfigTest8)object; + final ConfigTestConfigProps other = (ConfigTestConfigProps)object; return m_configurations.equals( other.m_configurations ); } } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest9.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestConfigurable.java similarity index 82% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest9.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestConfigurable.java index 7ed334b30..9f3898fde 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest9.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestConfigurable.java @@ -7,19 +7,17 @@ */ package org.apache.myrmidon.components.configurer; -import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; /** - * Simple class to test adder for Configurations. + * Simple class to test {@link Configurable}. * * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest9 +public class ConfigTestConfigurable implements Configurable { private Configuration m_configuration; @@ -32,7 +30,7 @@ public class ConfigTest9 public boolean equals( final Object object ) { - final ConfigTest9 other = (ConfigTest9)object; + final ConfigTestConfigurable other = (ConfigTestConfigurable)object; return m_configuration == other.m_configuration; } } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestInterfaceProp.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestInterfaceProp.java new file mode 100644 index 000000000..14c4ef669 --- /dev/null +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestInterfaceProp.java @@ -0,0 +1,32 @@ +/* + * 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.configurer; + +import java.util.ArrayList; + +/** + * A test class with an interface property. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public class ConfigTestInterfaceProp +{ + private final ArrayList m_elems = new ArrayList(); + + public void addPropA( final MyRole1 role1 ) + { + m_elems.add( role1 ); + } + + public boolean equals( Object obj ) + { + final ConfigTestInterfaceProp test = (ConfigTestInterfaceProp)obj; + return m_elems.equals( test.m_elems ); + } +} diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestMultiSetter.java similarity index 79% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestMultiSetter.java index d8882d26d..330f203c8 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest3.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestMultiSetter.java @@ -15,15 +15,15 @@ import junit.framework.AssertionFailedError; * * @author Adam Murdoch */ -public class ConfigTest3 +public class ConfigTestMultiSetter { - private ConfigTest1 m_prop1; - private ConfigTest1 m_prop2; + private ConfigTestStringProps m_prop1; + private ConfigTestStringProps m_prop2; private ArrayList m_prop3 = new ArrayList(); public boolean equals( Object obj ) { - ConfigTest3 test = (ConfigTest3)obj; + ConfigTestMultiSetter test = (ConfigTestMultiSetter)obj; if( !DefaultConfigurerTest.equals( m_prop1, test.m_prop1 ) ) { return false; @@ -48,7 +48,7 @@ public class ConfigTest3 throw new AssertionFailedError(); } - public void setProp1( final ConfigTest1 value ) + public void setProp1( final ConfigTestStringProps value ) { m_prop1 = value; } @@ -62,7 +62,7 @@ public class ConfigTest3 throw new AssertionFailedError(); } - public void setProp2( final ConfigTest1 value ) + public void setProp2( final ConfigTestStringProps value ) { m_prop2 = value; } @@ -76,7 +76,7 @@ public class ConfigTest3 throw new AssertionFailedError(); } - public void addProp3( final ConfigTest1 value ) + public void addProp3( final ConfigTestStringProps value ) { m_prop3.add( value ); } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestMultiTypedAdder.java similarity index 72% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestMultiTypedAdder.java index 7d727acce..0eb4c5d41 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest5.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestMultiTypedAdder.java @@ -7,17 +7,15 @@ */ package org.apache.myrmidon.components.configurer; -import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.avalon.framework.configuration.Configuration; + /** - * Simple class to test typed adder. + * Simple class with more than one typed adder method. * * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest5 +public class ConfigTestMultiTypedAdder { public void add( final MyRole1 role1 ) { diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest2.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestObjectProps.java similarity index 76% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest2.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestObjectProps.java index b1f061dc4..d829e8100 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest2.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestObjectProps.java @@ -15,14 +15,14 @@ import java.util.List; * * @author Adam Murdoch */ -public class ConfigTest2 +public class ConfigTestObjectProps { - ConfigTest1 m_prop; + ConfigTestStringProps m_prop; List m_propList = new ArrayList(); public boolean equals( Object obj ) { - ConfigTest2 test = (ConfigTest2)obj; + ConfigTestObjectProps test = (ConfigTestObjectProps)obj; if( !DefaultConfigurerTest.equals( m_prop, test.m_prop ) ) { return false; @@ -34,12 +34,12 @@ public class ConfigTest2 return true; } - public void setProp( final ConfigTest1 test ) + public void setProp( final ConfigTestStringProps test ) { m_prop = test; } - public void addAnotherProp( final ConfigTest1 test ) + public void addAnotherProp( final ConfigTestStringProps test ) { m_propList.add( test ); } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest10.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestPrimConvert.java similarity index 81% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest10.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestPrimConvert.java index e7a67f032..4a204f7f6 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest10.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestPrimConvert.java @@ -14,24 +14,24 @@ import org.apache.myrmidon.components.AbstractComponentTest; * * @author Adam Murdoch */ -public class ConfigTest10 +public class ConfigTestPrimConvert { private int m_intProp; private Integer m_integerProp; - public void setIntProp( int intProp ) + public void setIntProp( final int intProp ) { m_intProp = intProp; } - public void setIntegerProp( Integer integerProp ) + public void setIntegerProp( final Integer integerProp ) { m_integerProp = integerProp; } public boolean equals( Object obj ) { - ConfigTest10 test = (ConfigTest10)obj; + ConfigTestPrimConvert test = (ConfigTestPrimConvert)obj; if( m_intProp != test.m_intProp ) { return false; diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest1.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestStringProps.java similarity index 84% rename from proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest1.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestStringProps.java index a45169128..0d1f42c6c 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTest1.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestStringProps.java @@ -9,13 +9,15 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; import java.util.List; +import org.apache.myrmidon.framework.DataType; /** - * A simple test class. + * A simple test class with string properties. * * @author Adam Murdoch */ -public class ConfigTest1 +public class ConfigTestStringProps + implements DataType { private String m_someProp; private List m_propList = new ArrayList(); @@ -23,7 +25,7 @@ public class ConfigTest1 public boolean equals( final Object obj ) { - final ConfigTest1 test = (ConfigTest1)obj; + final ConfigTestStringProps test = (ConfigTestStringProps)obj; if( !DefaultConfigurerTest.equals( m_someProp, test.m_someProp ) ) { return false; diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest7.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestTypedConfigProp.java similarity index 87% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest7.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestTypedConfigProp.java index b10c7f990..fd7ec3e87 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest7.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestTypedConfigProp.java @@ -8,7 +8,6 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; -import junit.framework.AssertionFailedError; import org.apache.avalon.framework.configuration.Configuration; /** @@ -17,7 +16,7 @@ import org.apache.avalon.framework.configuration.Configuration; * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest7 +public class ConfigTestTypedConfigProp { private ArrayList m_configurations = new ArrayList(); @@ -28,7 +27,7 @@ public class ConfigTest7 public boolean equals( final Object object ) { - final ConfigTest7 other = (ConfigTest7)object; + final ConfigTestTypedConfigProp other = (ConfigTestTypedConfigProp)object; return m_configurations.equals( other.m_configurations ); } } diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest6.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestTypedProp.java similarity index 79% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest6.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestTypedProp.java index 7f67ae5c5..361744716 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/ConfigTest6.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ConfigTestTypedProp.java @@ -8,8 +8,6 @@ package org.apache.myrmidon.components.configurer; import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.avalon.framework.configuration.Configuration; /** * Simple class to test typed adder. @@ -17,7 +15,7 @@ import org.apache.avalon.framework.configuration.Configuration; * @author Peter Donald * @version $Revision$ $Date$ */ -public class ConfigTest6 +public class ConfigTestTypedProp { private ArrayList m_roles = new ArrayList(); @@ -28,7 +26,7 @@ public class ConfigTest6 public boolean equals( final Object object ) { - final ConfigTest6 other = (ConfigTest6)object; + final ConfigTestTypedProp other = (ConfigTestTypedProp)object; return m_roles.equals( other.m_roles ); } } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java index 074489d65..b569488b6 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java @@ -13,16 +13,12 @@ import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfiguration; -import org.apache.avalon.framework.context.Context; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.components.AbstractComponentTest; import org.apache.myrmidon.components.workspace.DefaultTaskContext; import org.apache.myrmidon.framework.DataType; import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; import org.apache.myrmidon.interfaces.role.RoleInfo; -import org.apache.myrmidon.interfaces.role.RoleManager; -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; /** * Test cases for the default configurer and related classes. @@ -37,7 +33,6 @@ public class DefaultConfigurerTest private Configurer m_configurer; private DefaultTaskContext m_context; - private Context m_adaptor; public DefaultConfigurerTest( String name ) { @@ -59,7 +54,6 @@ public class DefaultConfigurerTest m_context = new DefaultTaskContext(); final File baseDir = new File( "." ).getAbsoluteFile(); m_context.setProperty( TaskContext.BASE_DIRECTORY, baseDir ); - m_adaptor = new TaskContextAdapter( m_context ); } /** @@ -75,13 +69,13 @@ public class DefaultConfigurerTest final String value2 = "some other value"; config.setAttribute( "prop", value2 ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( value1 ); expected.addProp( value2 ); assertEquals( expected, test ); @@ -99,18 +93,15 @@ public class DefaultConfigurerTest config.setAttribute( "integer-prop", "-401" ); // Register the converter - final Class converterClass = StringToIntegerConverter.class; - final Class sourceClass = String.class; - final Class destClass = Integer.class; - registerConverter( converterClass, sourceClass, destClass ); + registerConverter( StringToIntegerConverter.class, String.class, Integer.class ); - final ConfigTest10 test = new ConfigTest10(); + final ConfigTestPrimConvert test = new ConfigTestPrimConvert(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest10 expected = new ConfigTest10(); + final ConfigTestPrimConvert expected = new ConfigTestPrimConvert(); expected.setIntProp( 90 ); expected.setIntegerProp( new Integer(-401) ); assertEquals( expected, test ); @@ -126,12 +117,12 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "unknown", "some value" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -158,17 +149,17 @@ public class DefaultConfigurerTest child2.setAttribute( "some-prop", value2 ); config.addChild( child2 ); - final ConfigTest2 test = new ConfigTest2(); + final ConfigTestObjectProps test = new ConfigTestObjectProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest2 expected = new ConfigTest2(); - ConfigTest1 elem = new ConfigTest1(); + final ConfigTestObjectProps expected = new ConfigTestObjectProps(); + ConfigTestStringProps elem = new ConfigTestStringProps(); elem.setSomeProp( value1 ); expected.setProp( elem ); - elem = new ConfigTest1(); + elem = new ConfigTestStringProps(); elem.setSomeProp( value2 ); expected.addAnotherProp( elem ); assertEquals( expected, test ); @@ -185,12 +176,12 @@ public class DefaultConfigurerTest final DefaultConfiguration elem = new DefaultConfiguration( "unknown", "test" ); config.addChild( elem ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -211,13 +202,13 @@ public class DefaultConfigurerTest final String value1 = "some value"; config.setValue( value1 ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.addContent( value1 ); assertEquals( expected, test ); } @@ -232,12 +223,12 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setValue( "some value" ); - final ConfigTest2 test = new ConfigTest2(); + final ConfigTestObjectProps test = new ConfigTestObjectProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -257,15 +248,15 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "prop", "some ${prop-a} value" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "prop-a", "other" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.addProp( "some other value" ); assertEquals( expected, test ); } @@ -279,15 +270,15 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "prop-a" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "prop-a", "some value" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( "some value" ); assertEquals( expected, test ); } @@ -303,15 +294,15 @@ public class DefaultConfigurerTest elem.setAttribute( "id", "prop-a" ); config.addChild( elem ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "prop-a", "some value" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( "some value" ); assertEquals( expected, test ); } @@ -329,12 +320,12 @@ public class DefaultConfigurerTest elem.setAttribute( "extra-attr", "some value" ); config.addChild( elem ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -347,6 +338,57 @@ public class DefaultConfigurerTest } } + /** + * Tests reference type conversion. + */ + public void testReferenceConversion() throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + config.setAttribute( "prop-a-ref", "id" ); + + final Integer refValue = new Integer( 21 ); + m_context.setProperty( "id", refValue ); + + registerConverter( ObjectToMyRole1Converter.class, Object.class, MyRole1.class ); + + final ConfigTestInterfaceProp test = new ConfigTestInterfaceProp(); + + // Configure + m_configurer.configure( test, config, m_context ); + + // Check result + final ConfigTestInterfaceProp expected = new ConfigTestInterfaceProp(); + expected.addPropA( new MyRole1Adaptor( refValue ) ); + assertEquals( expected, test ); + } + + /** + * Tests that the role's default type is used for interface typed + * elements. + */ + public void testInterfaceAdder() + throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + final DefaultConfiguration child = new DefaultConfiguration( "prop-a", "test" ); + config.addChild( child ); + + registerRole( new RoleInfo( "myrole1", null, MyRole1.class, "default-type" ) ); + registerType( MyRole1.class, "default-type", MyType1.class ); + + final ConfigTestInterfaceProp test = new ConfigTestInterfaceProp(); + + // Configure object + m_configurer.configure( test, config, m_context ); + + // Check result + final ConfigTestInterfaceProp expected = new ConfigTestInterfaceProp(); + expected.addPropA( new MyType1() ); + assertEquals( expected, test ); + } + /** * Tests whether an object with a non-iterface typed adder causes an * exception. @@ -362,7 +404,7 @@ public class DefaultConfigurerTest try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -386,12 +428,12 @@ public class DefaultConfigurerTest // Setup test data final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final ConfigTest5 test = new ConfigTest5(); + final ConfigTestMultiTypedAdder test = new ConfigTestMultiTypedAdder(); try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( final ConfigurationException ce ) @@ -399,7 +441,7 @@ public class DefaultConfigurerTest final String[] messages = { REZ.getString( "bad-configure-element.error", "test" ), REZ.getString( "multiple-adder-methods-for-element.error", - ConfigTest5.class.getName(), + ConfigTestMultiTypedAdder.class.getName(), "") }; assertSameMessage( messages, ce ); @@ -419,24 +461,75 @@ public class DefaultConfigurerTest config.addChild( child1 ); config.addChild( child2 ); - final ClassLoader loader = getClass().getClassLoader(); - final DefaultTypeFactory factory = new DefaultTypeFactory( loader ); - factory.addNameClassMapping( "my-type1", MyType1.class.getName() ); - factory.addNameClassMapping( "my-type2", MyType2.class.getName() ); - getTypeManager().registerType( DataType.class, "my-type1", factory ); - getTypeManager().registerType( DataType.class, "my-type2", factory ); + registerType( DataType.class, "my-type1", MyType1.class ); + registerType( DataType.class, "my-type2", MyType2.class ); - final ConfigTest6 test = new ConfigTest6(); + final ConfigTestTypedProp test = new ConfigTestTypedProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest6 expected = new ConfigTest6(); + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); expected.add( new MyType1() ); expected.add( new MyType2() ); assertEquals( expected, test ); } + /** + * Tests to check that role is used for typed adder. + */ + public void testTypedAdderRole() + throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + final DefaultConfiguration child1 = new DefaultConfiguration( "my-type1", "test" ); + config.addChild( child1 ); + + // Register incompatible types with the same name, as data-type and myrole1. + registerRole( new RoleInfo( "myrole1", "myrole1", MyRole1.class ) ); + registerType( MyRole1.class, "my-type1", MyType1.class ); + registerType( DataType.class, "my-type1", StringBuffer.class ); + + final ConfigTestTypedProp test = new ConfigTestTypedProp(); + + // Configure the object + m_configurer.configure( test, config, m_context ); + + // Check the result + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); + expected.add( new MyType1() ); + assertEquals( expected, test ); + } + + /** + * Tests conversion with a typed adder. + */ + public void testTypedAdderConversion() + throws Exception + { + // Setup test data + final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); + final DefaultConfiguration child = new DefaultConfiguration( "some-type", "test" ); + child.setAttribute( "prop", "some value" ); + config.addChild( child ); + + registerType( DataType.class, "some-type", ConfigTestStringProps.class ); + registerConverter( ObjectToMyRole1Converter.class, Object.class, MyRole1.class ); + + final ConfigTestTypedProp test = new ConfigTestTypedProp(); + + // Configure the object + m_configurer.configure( test, config, m_context ); + + // Check the result + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); + final ConfigTestStringProps nested = new ConfigTestStringProps(); + nested.addProp( "some value" ); + expected.add( new MyRole1Adaptor( nested ) ); + assertEquals( expected, test ); + } + /** * Tests to see if typed adder can be used via an attribute. */ @@ -448,19 +541,17 @@ public class DefaultConfigurerTest config.setAttribute( "my-role1", "some value" ); // Set up the converter and role - RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - final RoleInfo roleInfo = new RoleInfo("my-role1", MyRole1.class ); - roleMgr.addRole( roleInfo ); - registerConverter( StringToMyRole1Converter.class, String.class, MyRole1.class ); + registerRole( new RoleInfo("my-role1", MyRole1.class ) ); + registerConverter( ObjectToMyRole1Converter.class, String.class, MyRole1.class ); - final ConfigTest6 test = new ConfigTest6(); + final ConfigTestTypedProp test = new ConfigTestTypedProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check result - final ConfigTest6 expected = new ConfigTest6(); - expected.add( new MyType1() ); + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); + expected.add( new MyRole1Adaptor( "some value" ) ); assertEquals( expected, test ); } @@ -477,12 +568,12 @@ public class DefaultConfigurerTest config.addChild( child1 ); config.addChild( child2 ); - final ConfigTest7 test = new ConfigTest7(); + final ConfigTestTypedConfigProp test = new ConfigTestTypedConfigProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest7 expected = new ConfigTest7(); + final ConfigTestTypedConfigProp expected = new ConfigTestTypedConfigProp(); expected.add( child1 ); expected.add( child2 ); assertEquals( expected, test ); @@ -501,12 +592,12 @@ public class DefaultConfigurerTest config.addChild( child1 ); config.addChild( child2 ); - final ConfigTest8 test = new ConfigTest8(); + final ConfigTestConfigProps test = new ConfigTestConfigProps(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest8 expected = new ConfigTest8(); + final ConfigTestConfigProps expected = new ConfigTestConfigProps(); expected.addConfig( child1 ); expected.addConfig( child2 ); assertEquals( expected, test ); @@ -521,12 +612,12 @@ public class DefaultConfigurerTest // Setup test data final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final ConfigTest9 test = new ConfigTest9(); + final ConfigTestConfigurable test = new ConfigTestConfigurable(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); - final ConfigTest9 expected = new ConfigTest9(); + final ConfigTestConfigurable expected = new ConfigTestConfigurable(); expected.configure( config ); assertEquals( expected, test ); } @@ -541,22 +632,22 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "${id}" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); m_context.setProperty( "id", "prop-a" ); m_context.setProperty( "prop-a", "some indirect value" ); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Check the configured object - final ConfigTest1 expected = new ConfigTest1(); + final ConfigTestStringProps expected = new ConfigTestStringProps(); expected.setSomeProp( "some indirect value" ); assertEquals( expected, test ); } /** - * Test an unknown reference. + * Tests an unknown reference. */ public void testUnknownReference() throws Exception @@ -565,12 +656,12 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "unknown-prop" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -593,14 +684,14 @@ public class DefaultConfigurerTest final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); config.setAttribute( "some-prop-ref", "prop-a" ); - final ConfigTest1 test = new ConfigTest1(); + final ConfigTestStringProps test = new ConfigTestStringProps(); - m_context.setProperty( "prop-a", new ConfigTest2() ); + m_context.setProperty( "prop-a", new ConfigTestObjectProps() ); // Configure the object try { - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -609,8 +700,7 @@ public class DefaultConfigurerTest REZ.getString( "bad-set-attribute.error", "test", "some-prop-ref" ), REZ.getString( "mismatch-ref-types.error", "prop-a", - String.class.getName(), - ConfigTest2.class.getName() ) + "some-prop" ) }; assertSameMessage( messages, e ); } @@ -631,19 +721,17 @@ public class DefaultConfigurerTest config.addChild( child ); // Add role mapping, and add to reference to context - final RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - final RoleInfo roleInfo = new RoleInfo( "my-role1", MyRole1.class ); - roleMgr.addRole( roleInfo ); + registerRole( new RoleInfo( "my-role1", MyRole1.class ) ); m_context.setProperty( "id", new MyType1() ); m_context.setProperty( "id2", new MyType2() ); - final ConfigTest6 test = new ConfigTest6(); + final ConfigTestTypedProp test = new ConfigTestTypedProp(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Compare against expected value - final ConfigTest6 expected = new ConfigTest6(); + final ConfigTestTypedProp expected = new ConfigTestTypedProp(); expected.add( new MyType1() ); expected.add( new MyType2() ); assertEquals( expected, test ); @@ -660,12 +748,12 @@ public class DefaultConfigurerTest elem.setAttribute( "not-a-prop", "not-a-value" ); config.addChild( elem ); - final ConfigTest2 test = new ConfigTest2(); + final ConfigTestObjectProps test = new ConfigTestObjectProps(); try { // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); fail(); } catch( ConfigurationException e ) @@ -693,16 +781,16 @@ public class DefaultConfigurerTest elem = new DefaultConfiguration( "prop3", "test" ); config.addChild( elem ); - final ConfigTest3 test = new ConfigTest3(); + final ConfigTestMultiSetter test = new ConfigTestMultiSetter(); // Configure the object - m_configurer.configure( test, config, m_adaptor ); + m_configurer.configure( test, config, m_context ); // Test expected value - final ConfigTest3 expected = new ConfigTest3(); - expected.setProp1( new ConfigTest1() ); - expected.setProp2( new ConfigTest1() ); - expected.addProp3( new ConfigTest1() ); + final ConfigTestMultiSetter expected = new ConfigTestMultiSetter(); + expected.setProp1( new ConfigTestStringProps() ); + expected.setProp2( new ConfigTestStringProps() ); + expected.addProp3( new ConfigTestStringProps() ); assertEquals( expected, test ); } } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1Adaptor.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1Adaptor.java new file mode 100644 index 000000000..a683499d3 --- /dev/null +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/MyRole1Adaptor.java @@ -0,0 +1,33 @@ +/* + * 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.configurer; + +import org.apache.myrmidon.AbstractMyrmidonTest; + +/** + * Adapts an Object to MyRole + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + */ +public class MyRole1Adaptor + implements MyRole1 +{ + private final Object m_object; + + public MyRole1Adaptor( final Object o ) + { + m_object = o; + } + + public boolean equals( Object obj ) + { + final MyRole1Adaptor adaptor = (MyRole1Adaptor)obj; + return AbstractMyrmidonTest.equals( m_object, adaptor.m_object ); + } +} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/StringToMyRole1Converter.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ObjectToMyRole1Converter.java similarity index 70% rename from proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/StringToMyRole1Converter.java rename to proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ObjectToMyRole1Converter.java index dbeac97aa..34934097c 100644 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/StringToMyRole1Converter.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/ObjectToMyRole1Converter.java @@ -9,24 +9,24 @@ package org.apache.myrmidon.components.configurer; import org.apache.aut.converter.AbstractConverter; import org.apache.aut.converter.ConverterException; -import org.apache.avalon.framework.context.Context; /** - * Converts from a string to a {@link MyRole1} implementation. + * Converts from Object to MyRole1. * * @author Adam Murdoch + * @version $Revision$ $Date$ */ -public class StringToMyRole1Converter +public class ObjectToMyRole1Converter extends AbstractConverter { - public StringToMyRole1Converter() + public ObjectToMyRole1Converter() { - super( String.class, MyRole1.class ); + super( Object.class, MyRole1.class ); } protected Object convert( Object original, Object context ) throws ConverterException { - return new MyType1(); + return new MyRole1Adaptor( original ); } } diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java index ebec3f704..3416c45f6 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java @@ -7,21 +7,19 @@ */ package org.apache.myrmidon.components.deployer; +import java.io.File; +import org.apache.aut.converter.Converter; +import org.apache.aut.converter.ConverterException; import org.apache.myrmidon.components.AbstractComponentTest; import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.interfaces.converter.MasterConverter; import org.apache.myrmidon.interfaces.deployer.ConverterDefinition; import org.apache.myrmidon.interfaces.deployer.Deployer; import org.apache.myrmidon.interfaces.deployer.TypeDefinition; import org.apache.myrmidon.interfaces.deployer.TypeDeployer; -import org.apache.myrmidon.interfaces.role.RoleManager; import org.apache.myrmidon.interfaces.role.RoleInfo; -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.type.TypeException; -import org.apache.aut.converter.ConverterException; -import org.apache.aut.converter.Converter; -import java.io.File; +import org.apache.myrmidon.interfaces.type.TypeFactory; /** * Test cases for the default deployer. @@ -37,7 +35,7 @@ public class DefaultDeployerTest private Deployer m_deployer; private RoleManager m_roleManager; - private MasterConverter m_converter; + private Converter m_converter; public DefaultDeployerTest( final String name ) { @@ -52,7 +50,7 @@ public class DefaultDeployerTest { super.setUp(); m_deployer = (Deployer)getServiceManager().lookup( Deployer.ROLE ); - m_converter = (MasterConverter)getServiceManager().lookup( MasterConverter.ROLE ); + m_converter = (Converter)getServiceManager().lookup( Converter.ROLE ); // Add some core roles m_roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); diff --git a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/TestConverter1.java b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/TestConverter1.java index 07c0d9f20..fc9abe6c3 100644 --- a/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/TestConverter1.java +++ b/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/TestConverter1.java @@ -9,7 +9,6 @@ package org.apache.myrmidon.components.deployer; import org.apache.aut.converter.Converter; import org.apache.aut.converter.ConverterException; -import org.apache.avalon.framework.context.Context; /** * A test converter. diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java index 06dd9f026..0dde5c845 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java @@ -88,7 +88,7 @@ public class Script extends AbstractTask { try { - addBeans( getContext().getPropertys() ); + addBeans( getContext().getProperties() ); //In Ant2 there is no difference between properties and references //addBeans( getProject().getReferences() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 17fa438b6..a8425d085 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -617,7 +617,7 @@ public class JUnitTask extends AbstractTask // Create a temporary file to pass the Ant properties to the forked test File propsFile = new File( "junit" + ( new Random( System.currentTimeMillis() ) ).nextLong() + ".properties" ); cmd.addArgument( "propsfile=" + propsFile.getAbsolutePath() ); - Map p = getContext().getPropertys(); + Map p = getContext().getProperties(); Properties props = new Properties(); for( Iterator enum = p.keySet().iterator(); enum.hasNext(); ) { @@ -663,7 +663,7 @@ public class JUnitTask extends AbstractTask private int executeInVM( JUnitTest test ) throws TaskException { - test.setProperties( getContext().getPropertys() ); + test.setProperties( getContext().getProperties() ); if( dir != null ) { getLogger().warn( "dir attribute ignored if running in the same VM" ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/converters/StringToPathConverter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/converters/StringToPathConverter.java index b7aaf9869..63984cc75 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/converters/StringToPathConverter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/converters/StringToPathConverter.java @@ -7,7 +7,6 @@ */ package org.apache.tools.ant.types.converters; -import org.apache.avalon.framework.context.Context; import org.apache.aut.converter.AbstractConverter; import org.apache.aut.converter.ConverterException; import org.apache.tools.ant.types.Path;