ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer DefaultDeployerTest.java
Date Sun, 03 Feb 2002 02:35:37 GMT
donaldp     02/02/02 18:35:37

  Modified:    proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer
                        DefaultConfigurerTest.java
               proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer
                        DefaultDeployerTest.java
  Added:       proposal/myrmidon/src/testcases/org/apache/myrmidon/components
                        AbstractComponentTest.java
  Removed:     proposal/myrmidon/src/testcases/org/apache/myrmidon/components
                        ComponentTestBase.java
  Log:
  Rename ComponentTestBase to AbstractComponentTest and make AbstractComponentTest abstract.
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.components;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import junit.framework.TestCase;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.component.DefaultComponentManager;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.LogKitLogger;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.log.Hierarchy;
  import org.apache.log.LogTarget;
  import org.apache.log.Priority;
  import org.apache.log.format.PatternFormatter;
  import org.apache.log.output.io.StreamTarget;
  import org.apache.myrmidon.components.configurer.DefaultConfigurer;
  import org.apache.myrmidon.components.converter.DefaultConverterRegistry;
  import org.apache.myrmidon.components.converter.DefaultMasterConverter;
  import org.apache.myrmidon.components.deployer.DefaultDeployer;
  import org.apache.myrmidon.components.extensions.DefaultExtensionManager;
  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.RoleManager;
  import org.apache.myrmidon.interfaces.type.TypeManager;
  
  /**
   * A base class for tests for the default components.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public abstract class AbstractComponentTest
      extends TestCase
  {
      private DefaultComponentManager m_componentManager;
      private Logger m_logger;
  
      private final static String PATTERN = "[%8.8{category}] %{message}\\n%{throwable}";
  
      public AbstractComponentTest( final String name )
      {
          super( name );
      }
  
      /**
       * Returns the component manager containing the components to test.
       */
      protected ComponentManager getComponentManager()
      {
          return m_componentManager;
      }
  
      /**
       * Returns the type manager.
       */
      protected TypeManager getTypeManager() throws ComponentException
      {
          return (TypeManager)getComponentManager().lookup( TypeManager.ROLE );
      }
  
      /**
       * Setup the test case - prepares the set of components.
       */
      protected void setUp()
          throws Exception
      {
          // Setup a logger
          final Priority priority = Priority.DEBUG;
          final org.apache.log.Logger targetLogger = Hierarchy.getDefaultHierarchy().getLoggerFor(
"myrmidon" );
  
          final PatternFormatter formatter = new PatternFormatter( PATTERN );
          final StreamTarget target = new StreamTarget( System.out, formatter );
          targetLogger.setLogTargets( new LogTarget[]{target} );
          targetLogger.setPriority( priority );
  
          m_logger = new LogKitLogger( targetLogger );
  
          // Create the components
          m_componentManager = new DefaultComponentManager();
          List components = new ArrayList();
  
          Component component = new DefaultMasterConverter();
          m_componentManager.put( MasterConverter.ROLE, component );
          components.add( component );
  
          component = new DefaultConverterRegistry();
          m_componentManager.put( ConverterRegistry.ROLE, component );
          components.add( component );
  
          component = new DefaultTypeManager();
          m_componentManager.put( TypeManager.ROLE, component );
          components.add( component );
  
          component = new DefaultConfigurer();
          m_componentManager.put( Configurer.ROLE, component );
          components.add( component );
  
          component = new DefaultDeployer();
          m_componentManager.put( Deployer.ROLE, component );
          components.add( component );
  
          component = new DefaultExtensionManager();
          m_componentManager.put( ExtensionManager.ROLE, component );
          components.add( component );
  
          component = new DefaultRoleManager();
          m_componentManager.put( RoleManager.ROLE, component );
          components.add( component );
  
          // Log enable the components
          for( Iterator iterator = components.iterator(); iterator.hasNext(); )
          {
              Object obj = iterator.next();
              if( obj instanceof LogEnabled )
              {
                  final LogEnabled logEnabled = (LogEnabled)obj;
                  logEnabled.enableLogging( m_logger );
              }
          }
  
          // Compose the components
          for( Iterator iterator = components.iterator(); iterator.hasNext(); )
          {
              Object obj = iterator.next();
              if( obj instanceof Composable )
              {
                  final Composable composable = (Composable)obj;
                  composable.compose( m_componentManager );
              }
          }
      }
  
      /**
       * Asserts that an exception contains the expected message.
       *
       * TODO - should take the expected exception, rather than the message,
       * to check the entire cause chain.
       */
      protected void assertSameMessage( final String message, final Throwable throwable )
      {
          assertEquals( message, throwable.getMessage() );
      }
  
      /**
       * Compares 2 objects for equality, nulls are equal.  Used by the test
       * classes' equals() methods.
       */
      public static boolean equals( final Object o1, final Object o2 )
      {
          if( o1 == null && o2 == null )
          {
              return true;
          }
          if( o1 == null || o2 == null )
          {
              return false;
          }
          return o1.equals( o2 );
      }
  }
  
  
  
  1.10      +2 -2      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java
  
  Index: DefaultConfigurerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/configurer/DefaultConfigurerTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultConfigurerTest.java	2 Feb 2002 12:51:59 -0000	1.9
  +++ DefaultConfigurerTest.java	3 Feb 2002 02:35:37 -0000	1.10
  @@ -14,7 +14,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.myrmidon.api.TaskContext;
  -import org.apache.myrmidon.components.ComponentTestBase;
  +import org.apache.myrmidon.components.AbstractComponentTest;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
  @@ -25,7 +25,7 @@
    * @author Adam Murdoch
    */
   public class DefaultConfigurerTest
  -    extends ComponentTestBase
  +    extends AbstractComponentTest
   {
       private final static Resources REZ =
           ResourceManager.getPackageResources( DefaultConfigurerTest.class );
  
  
  
  1.2       +2 -2      jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java
  
  Index: DefaultDeployerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/testcases/org/apache/myrmidon/components/deployer/DefaultDeployerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultDeployerTest.java	2 Feb 2002 12:51:59 -0000	1.1
  +++ DefaultDeployerTest.java	3 Feb 2002 02:35:37 -0000	1.2
  @@ -7,7 +7,7 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  -import org.apache.myrmidon.components.ComponentTestBase;
  +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;
  @@ -23,7 +23,7 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
   public class DefaultDeployerTest
  -    extends ComponentTestBase
  +    extends AbstractComponentTest
   {
       private Deployer m_deployer;
   
  
  
  

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