ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/property/test AbstractPropertyResolverTestCase.java
Date Fri, 26 Apr 2002 03:12:51 GMT
adammurdoch    02/04/25 20:12:51

  Modified:    container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/test/org/apache/myrmidon/components/configurer/test
                        DefaultConfigurerTestCase.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java
               container/src/test/org/apache/myrmidon/components/property/test
                        AbstractPropertyResolverTestCase.java
  Log:
  - Fix configurer and prop resolver tests.
  - Make sure there's an event manager available in the component tests.
  - Move context creation up to AbstractComponentTest.
  
  Revision  Changes    Path
  1.28      +30 -5     jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AbstractComponentTest.java	25 Apr 2002 01:41:50 -0000	1.27
  +++ AbstractComponentTest.java	26 Apr 2002 03:12:50 -0000	1.28
  @@ -24,6 +24,7 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.AbstractContainerTestCase;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.components.classloader.DefaultClassLoaderManager;
   import org.apache.myrmidon.components.configurer.DefaultConfigurer;
   import org.apache.myrmidon.components.converter.DefaultMasterConverter;
  @@ -33,11 +34,16 @@
   import org.apache.myrmidon.components.property.DefaultPropertyResolver;
   import org.apache.myrmidon.components.role.DefaultRoleManager;
   import org.apache.myrmidon.components.type.DefaultTypeManager;
  +import org.apache.myrmidon.components.event.DefaultTaskEventManager;
  +import org.apache.myrmidon.components.store.DefaultPropertyStore;
  +import org.apache.myrmidon.components.workspace.DefaultExecutionFrame;
  +import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.classloader.ClassLoaderManager;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.executor.Executor;
  +import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
  @@ -46,22 +52,19 @@
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.event.TaskEventManager;
   
   /**
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.27 $ $Date: 2002/04/25 01:41:50 $
  + * @version $Revision: 1.28 $ $Date: 2002/04/26 03:12:50 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
   {
       private DefaultServiceManager m_serviceManager;
   
  -    public static final String DATA_TYPE_ROLE = "data-type";
  -    public static final String CONVERTER_ROLE = "converter";
  -    public static final String SERVICE_FACTORY_ROLE = "service-factory";
  -
       public AbstractComponentTest( final String name )
       {
           super( name );
  @@ -118,6 +121,10 @@
               m_serviceManager.put( PropertyResolver.ROLE, component );
               components.add( component );
   
  +            component = createComponent( TaskEventManager.ROLE, DefaultTaskEventManager.class
);
  +            m_serviceManager.put( TaskEventManager.ROLE, component );
  +            components.add( component );
  +
               // Log enable the components
               for( Iterator iterator = components.iterator(); iterator.hasNext(); )
               {
  @@ -209,6 +216,24 @@
           throws Exception
       {
           return (TypeManager)getServiceManager().lookup( TypeManager.ROLE );
  +    }
  +
  +    /**
  +     * Utility method to create a task context.
  +     */
  +    protected TaskContext createContext()
  +        throws Exception
  +    {
  +        final ServiceManager serviceManager = getServiceManager();
  +        final TaskEventManager eventManager = (TaskEventManager)serviceManager.lookup(
TaskEventManager.ROLE );
  +
  +        final DefaultPropertyStore store = new DefaultPropertyStore();
  +        final ExecutionFrame frame
  +            = new DefaultExecutionFrame( "", getLogger(), store, serviceManager, eventManager
);
  +        final TaskContext context = new DefaultTaskContext( frame, "test", "gen:///test:0:0"
);
  +        final File baseDir = new File( "." ).getAbsoluteFile();
  +        context.setProperty( TaskContext.BASE_DIRECTORY, baseDir );
  +        return context;
       }
   
       /**
  
  
  
  1.14      +5 -18     jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java
  
  Index: DefaultConfigurerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultConfigurerTestCase.java	25 Apr 2002 09:54:33 -0000	1.13
  +++ DefaultConfigurerTestCase.java	26 Apr 2002 03:12:50 -0000	1.14
  @@ -7,17 +7,16 @@
    */
   package org.apache.myrmidon.components.configurer.test;
   
  -import java.io.File;
  -import java.util.Map;
   import java.util.HashMap;
  +import java.util.Map;
   import org.apache.aut.converter.lib.StringToIntegerConverter;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.ExceptionUtil;
   import org.apache.myrmidon.api.TaskContext;
  -import org.apache.myrmidon.api.metadata.ModelException;
   import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.api.metadata.ModelException;
   import org.apache.myrmidon.components.AbstractComponentTest;
  -import org.apache.myrmidon.components.store.DefaultPropertyStore;
  +import org.apache.myrmidon.components.TestDataType;
   import org.apache.myrmidon.components.configurer.DefaultConfigurer;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestAttributeConvert;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestConfigAdder;
  @@ -39,14 +38,8 @@
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderReference;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderRole;
   import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedConfigAdder;
  -import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  -import org.apache.myrmidon.components.workspace.DefaultExecutionFrame;
  -import org.apache.myrmidon.components.TestDataType;
  -import org.apache.myrmidon.components.event.DefaultTaskEventManager;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
  -import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  -import org.apache.myrmidon.interfaces.event.TaskEventManager;
   
   /**
    * Test cases for the default configurer and related classes.
  @@ -60,7 +53,7 @@
           getResourcesForTested( DefaultConfigurerTestCase.class );
   
       private Configurer m_configurer;
  -    private DefaultTaskContext m_context;
  +    private TaskContext m_context;
   
       public DefaultConfigurerTestCase( String name )
       {
  @@ -79,13 +72,7 @@
           m_configurer = (Configurer)getServiceManager().lookup( Configurer.ROLE );
   
           // Setup a context
  -        final DefaultPropertyStore store = new DefaultPropertyStore();
  -        final TaskEventManager eventManager = new DefaultTaskEventManager();
  -        final ExecutionFrame frame
  -            = new DefaultExecutionFrame( "/", getLogger(), store, getServiceManager(),
eventManager );
  -        m_context = new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
  -        final File baseDir = new File( "." ).getAbsoluteFile();
  -        m_context.setProperty( TaskContext.BASE_DIRECTORY, baseDir );
  +        m_context = createContext();
       }
   
       /**
  
  
  
  1.5       +1 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java
  
  Index: DefaultDeployerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultDeployerTestCase.java	25 Apr 2002 01:41:50 -0000	1.4
  +++ DefaultDeployerTestCase.java	26 Apr 2002 03:12:51 -0000	1.5
  @@ -74,10 +74,8 @@
           final String typeName = TEST_TYPE1_NAME;
           final String classname = TestType1.class.getName();
   
  -        // Determine the shorthand for the DataType role
  -
           // Create the type definition
  -        final TypeDefinition typeDef = new TypeDefinition( typeName, DATA_TYPE_ROLE, classname
);
  +        final TypeDefinition typeDef = new TypeDefinition( typeName, TestDataType.ROLE,
classname );
   
           final ClassLoader classLoader = getClass().getClassLoader();
           final TypeLibraryDeployer typeDeployer = m_deployer.createDeployer( classLoader
);
  
  
  
  1.11      +3 -17     jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java
  
  Index: AbstractPropertyResolverTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractPropertyResolverTestCase.java	25 Apr 2002 09:54:33 -0000	1.10
  +++ AbstractPropertyResolverTestCase.java	26 Apr 2002 03:12:51 -0000	1.11
  @@ -11,23 +11,17 @@
   import java.util.Date;
   import org.apache.aut.converter.lib.ObjectToStringConverter;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.components.AbstractComponentTest;
  -import org.apache.myrmidon.components.event.DefaultTaskEventManager;
  -import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  -import org.apache.myrmidon.components.workspace.DefaultExecutionFrame;
   import org.apache.myrmidon.components.property.DefaultPropertyResolver;
  -import org.apache.myrmidon.components.store.DefaultPropertyStore;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
  -import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
    * General-purpose property resolver test cases.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.10 $ $Date: 2002/04/25 09:54:33 $
  + * @version $Revision: 1.11 $ $Date: 2002/04/26 03:12:51 $
    */
   public abstract class AbstractPropertyResolverTestCase
       extends AbstractComponentTest
  @@ -46,15 +40,7 @@
   
           m_resolver = (PropertyResolver)getServiceManager().lookup( PropertyResolver.ROLE
);
   
  -        final PropertyStore store = new DefaultPropertyStore();
  -        final DefaultExecutionFrame frame =
  -            new DefaultExecutionFrame( "",
  -                                       getLogger(),
  -                                       store,
  -                                       new DefaultServiceManager(),
  -                                       new DefaultTaskEventManager() );
  -        m_context = new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
  -
  +        m_context = createContext();
           m_context.setProperty( "intProp", new Integer( 333 ) );
           m_context.setProperty( "stringProp", "String property" );
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message