avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/repository LocalRepositoryTestCase.java
Date Mon, 14 Jul 2003 04:49:36 GMT
mcconnell    2003/07/13 21:49:36

  Modified:    merlin   project.xml
               merlin/composition maven.xml
               merlin/composition/src/test/conf block.xml
               merlin/composition/src/test/org/apache/avalon/composition/model
                        AbstractTestCase.java
               merlin/composition/src/test/org/apache/avalon/composition/model/testa
                        TestA.java TestA.xinfo
               merlin/composition/src/test/org/apache/avalon/composition/repository
                        LocalRepositoryTestCase.java
  Added:       merlin/composition/src/test/conf context.xml
               merlin/composition/src/test/org/apache/avalon/composition/model/test
                        ContextTestCase.java
  Removed:     merlin/composition/src/test/org/apache/avalon/composition/model
                        CompositionTestCase.java
  Log:
  Synchronization with context management updates.
  
  Revision  Changes    Path
  1.22      +2 -1      avalon-sandbox/merlin/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/project.xml,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- project.xml	3 Jul 2003 04:28:53 -0000	1.21
  +++ project.xml	14 Jul 2003 04:49:36 -0000	1.22
  @@ -174,9 +174,10 @@
   
       <unitTest>
         <includes>
  -        <include>**/*TestCase*</include>
  +        <include>**/*TestCase.*</include>
         </includes>
         <excludes>
  +        <include>**/Abstract*.*</include>
         </excludes>
         <resources>
           <resource>
  
  
  
  1.3       +15 -0     avalon-sandbox/merlin/composition/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/maven.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- maven.xml	5 Jul 2003 07:59:08 -0000	1.2
  +++ maven.xml	14 Jul 2003 04:49:36 -0000	1.3
  @@ -31,6 +31,21 @@
         manifest="${basedir}/src/test/etc/e.mf"
         includes="**/teste/*.*" basedir="${basedir}/target/test-classes">
       </ant:jar>
  +
  +    <ant:delete>
  +      <fileset dir="${basedir}/target/test-classes">
  +        <include name="**/testa/*.*"/>
  +        <include name="**/testb/*.*"/>
  +        <include name="**/testc/*.*"/>
  +        <include name="**/testd/*.*"/>
  +      </fileset>
  +    </ant:delete>
  +
  +    <ant:copy toDir="${basedir}/target/test-classes/ext" 
  +      file="${pom.getDependencyPath('avalon-framework:avalon-framework-api')}"/>
  +    <ant:copy toDir="${basedir}/target/test-classes/ext" 
  +      file="${pom.getDependencyPath('avalon-framework:avalon-framework-impl')}"/>
  +
     </postGoal>
   
   </project>
  
  
  
  1.7       +2 -6      avalon-sandbox/merlin/composition/src/test/conf/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/test/conf/block.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- block.xml	11 Jul 2003 11:06:31 -0000	1.6
  +++ block.xml	14 Jul 2003 04:49:36 -0000	1.7
  @@ -11,10 +11,6 @@
        </service>
      </services>
   
  -   <dependencies>
  -     <dependency type="fred.george.sally" optional="true"/>
  -   </dependencies>
  -
      <classloader>
        <library>
          <include>ext</include>
  @@ -25,9 +21,9 @@
            <include>test-c.jar</include>
          </fileset>
          <repository>
  +         <resource id="avalon-framework:avalon-framework-api" version="SNAPSHOT"/>
  +         <resource id="avalon-framework:avalon-framework-impl" version="SNAPSHOT"/>
            <resource id="test:test-d"/>
  -         <resource id="avalon-framework:avalon-framework-api" version="4.1.5-dev"/>
  -         <resource id="avalon-framework:avalon-framework-impl" version="4.1.5-dev"/>
          </repository>
        </classpath>
      </classloader>
  
  
  
  1.1                  avalon-sandbox/merlin/composition/src/test/conf/context.xml
  
  Index: context.xml
  ===================================================================
  
  
  <container>
  
     <classloader>
       <classpath>
         <repository>
           <resource id="avalon-framework:avalon-framework-api" version="SNAPSHOT"/>
           <resource id="avalon-framework:avalon-framework-impl" version="SNAPSHOT"/>
         </repository>
         <fileset dir="ext">
           <include>test-a.jar</include>
         </fileset>
       </classpath>
     </classloader>
  
     <component name="test-a" class="org.apache.avalon.composition.model.testa.TestA"/>
  
  </container>
  
  
  
  1.5       +30 -101   avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/AbstractTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractTestCase.java	8 Jul 2003 17:48:53 -0000	1.4
  +++ AbstractTestCase.java	14 Jul 2003 04:49:36 -0000	1.5
  @@ -5,6 +5,8 @@
   import java.io.File;
   import java.io.IOException;
   import java.net.URL;
  +import java.net.URLClassLoader;
  +import java.lang.reflect.Method;
   
   import org.apache.avalon.composition.logging.LoggingManager;
   import org.apache.avalon.composition.logging.LoggerException;
  @@ -12,6 +14,9 @@
   import org.apache.avalon.composition.logging.TargetDescriptor;
   import org.apache.avalon.composition.logging.TargetProvider;
   import org.apache.avalon.composition.logging.impl.DefaultLoggingManager;
  +import org.apache.avalon.composition.model.ModelRuntimeException;
  +import org.apache.avalon.composition.model.impl.DefaultModelFactory;
  +import org.apache.avalon.composition.model.impl.DefaultSystemContext;
   import org.apache.avalon.composition.repository.impl.FileRepository;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  @@ -31,124 +36,48 @@
      // state
      //-------------------------------------------------------
   
  -   /**
  -    * Source XML.
  -    */
  -    protected String m_path;
  -
  -   /**
  -    * Internal logger.
  -    */
  -    protected Logger m_logger;
  -
  -   /**
  -    * Setup argument for resolving relative references.
  -    */
  -    protected File m_base;
  -
  -   /**
  -    * Setup argument (not used)
  -    */
  -    protected FileRepository m_repository;
  -
  -    protected LoggingManager m_logging;
  -
  -   /**
  -    * The block profile.
  -    */
  -    protected ContainmentProfile m_profile;
  +    public ContainmentModel m_model;
   
  -    public AbstractTestCase( )
  -    {
  -        this( "data" );
  -    }
  +    private Logger m_logger = new ConsoleLogger();
   
  -    public AbstractTestCase( String name )
  -    {
  -        super( name );
  -    }
  +    private String m_path;
   
      //-------------------------------------------------------
  -   // setup
  +   // constructor
      //-------------------------------------------------------
   
  -   /**
  -    * The setup process covers the establishment of the base
  -    * directory (from which relative references for extension directories
  -    * and fileset base directories are resolved), a file repository (not
  -    * used in this test case at this time), and a class loader model from 
  -    * which a classpath will be established.
  -    *
  -    * @exception Exception if things don't work out
  -    */
  -    public void setUp() throws Exception
  -    {
  -        setUpCommon();
  -
  -        if( m_base == null )
  -        {
  -            throw new NullPointerException( "base" );
  -        }
  -
  -        //
  -        // load the meta data
  -        File conf = new File( m_base, getPath() );
  -        m_profile = setUpProfile( conf );
  -    }
  +   public AbstractTestCase( String path )
  +   {
  +       super( path );
  +       m_path = path;
  +   }
   
  -    protected abstract String getPath();
  -
  -    protected void setUpCommon() throws Exception
  -    {
  -        m_logging = createLoggingManager();
  -        m_logger = m_logging.getSystemLoggerForCategory( "" );
  -        m_base = new File( getTestDir(), "test-classes" );
  -        File repository = new File( m_base, "repository" );
  -        m_repository = setUpRepository( repository );
  -    }
  -
  -    protected LoggingManager createLoggingManager() throws Exception
  -    {
  -        LoggingDescriptor logging =
  -                new LoggingDescriptor(
  -                        "", "DEBUG", null,
  -                        new TargetDescriptor[0],
  -                        new CategoryDirective( "logging", "WARN" ) );
  -
  -        DefaultLoggingManager manager = 
  -          new DefaultLoggingManager( m_base, "model", logging );
  -        return manager;
  -    }
  +   //-------------------------------------------------------
  +   // constructor
  +   //-------------------------------------------------------
   
       protected Logger getLogger()
       {
           return m_logger;
       }
   
  -    protected FileRepository setUpRepository( File root ) throws Exception
  +    protected File getTestDir()
       {
  -        URL ibiblio = new URL( "http://www.ibiblio.org/maven" );
  -        FileRepository repository = new FileRepository();
  -        repository.enableLogging( new ConsoleLogger() );
  -        DefaultContext context = new DefaultContext();
  -        context.put( FileRepository.BASE_KEY, root );
  -        context.put( FileRepository.HOSTS_KEY, new URL[]{ ibiblio } );
  -        context.makeReadOnly();
  -        repository.contextualize( context );
  -        return repository;
  +        return new File( System.getProperty( "basedir" ), "target" );
       }
   
  -    protected ContainmentProfile setUpProfile( File file )
  -      throws Exception
  +    public void setUp() throws Exception
       {
  -        XMLContainmentProfileCreator creator = new XMLContainmentProfileCreator();
  -        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        Configuration config = builder.buildFromFile( file );
  -        return creator.createContainmentProfile( config );
  -    }
  +        if( m_model == null )
  +        {
  +            File base = new File( getTestDir(), "test-classes" );
  +            File repository = new File( base, "repository" );
   
  -    protected static File getTestDir()
  -    {
  -        return new File( System.getProperty( "basedir" ), "target" );
  +            File confDir = new File( base, "conf" );
  +            File source = new File( confDir, m_path );
  +
  +            SystemContext system = DefaultSystemContext.createSystemContext( base, repository
);
  +            m_model = system.getFactory().createContainmentModel( source.toURL() );
  +        }
       }
   }
  
  
  
  1.1                  avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/test/ContextTestCase.java
  
  Index: ContextTestCase.java
  ===================================================================
  
  
  package org.apache.avalon.composition.model.test;
  
  import java.io.File;
  import java.io.IOException;
  import java.net.URL;
  
  import org.apache.avalon.composition.model.Model;
  import org.apache.avalon.composition.model.DeploymentModel;
  import org.apache.avalon.composition.model.ContextModel;
  import org.apache.avalon.composition.model.AbstractTestCase;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.ServiceDescriptor;
  
  public class ContextTestCase extends AbstractTestCase
  {
  
     //-------------------------------------------------------
     // constructor
     //-------------------------------------------------------
  
      public ContextTestCase( )
      {
          super( "context.xml" );
      }
  
     //-------------------------------------------------------
     // tests
     //-------------------------------------------------------
  
     /**
      * Validate the composition model.
      */
      public void testStandardContextModel() throws Exception
      {
          DeploymentModel model = (DeploymentModel) m_model.getModel( "test-a" );
          if( model == null )
          {
              fail( "null deployment model" );
          }
  
          ContextModel contextModel = model.getContextModel();
          if( contextModel == null )
          {
              fail( "null context model" );
          }
  
          Context context = contextModel.getContext();
          if( context == null )
          {
              fail( "null context" );
          }
  
          try
          {
              ClassLoader loader = (ClassLoader) context.get( "urn:avalon:classloader" );
          }
          catch( ContextException e )
          {
              assertTrue( "urn:avalon:classloader", false );
          }
          
          try
          {
              File home = (File) context.get( "urn:avalon:home.dir" );
          }
          catch( ContextException e )
          {
              assertTrue( "urn:avalon:home.dir", false );
          }
  
          try
          {
              File temp = (File) context.get( "urn:avalon:temp.dir" );
          }
          catch( ContextException e )
          {
              assertTrue( "urn:avalon:temp.dir", false );
          }
  
          try
          {
              String partition = (String) context.get( "urn:avalon:partition.name" );
          }
          catch( ContextException e )
          {
              assertTrue( "urn:avalon:partition.name", false );
          }
  
          //
          // validate context entry lookup using an alias
          //
  
          try
          {
              String name = (String) context.get( "name" );
          }
          catch( ContextException e )
          {
              assertTrue( "name", false );
          }
      }
  }
  
  
  
  1.2       +13 -2     avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/testa/TestA.java
  
  Index: TestA.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/testa/TestA.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestA.java	4 Jul 2003 07:27:43 -0000	1.1
  +++ TestA.java	14 Jul 2003 04:49:36 -0000	1.2
  @@ -3,12 +3,23 @@
   package org.apache.avalon.composition.model.testa;
   
   import org.apache.avalon.framework.activity.Initializable;
  -import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   
   public class TestA extends AbstractLogEnabled
  -  implements Initializable, A
  +  implements Contextualizable, Initializable, A
   {
  +    public void contextualize( Context context ) throws ContextException
  +    {
  +        getLogger().info( "name: " + context.get( "urn:avalon:name" ) );
  +        getLogger().info( "partition: " + context.get( "urn:avalon:partition" ) );
  +        getLogger().info( "classloader: " + context.get( "urn:avalon:classloader" ) );
  +        getLogger().info( "work: " + context.get( "urn:avalon:work.dir" ) );
  +        getLogger().info( "temp: " + context.get( "urn:avalon:temp.dir" ) );
  +    }
  +
       public void initialize() throws Exception
       {
           getLogger().info( "hello" );
  
  
  
  1.2       +7 -0      avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/testa/TestA.xinfo
  
  Index: TestA.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/model/testa/TestA.xinfo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestA.xinfo	4 Jul 2003 07:27:43 -0000	1.1
  +++ TestA.xinfo	14 Jul 2003 04:49:36 -0000	1.2
  @@ -4,6 +4,13 @@
       <name>component-a</name>
       <lifestyle>singleton</lifestyle>
     </info>
  +  <context>
  +    <entry key="urn:avalon:partition.name"/>
  +    <entry key="urn:avalon:classloader"/>
  +    <entry key="urn:avalon:home.dir"/>
  +    <entry key="urn:avalon:temp.dir"/>
  +    <entry key="urn:avalon:name" alias="name"/>
  +  </context>
     <services>
       <service type="org.apache.avalon.composition.model.testa.A"/>
     </services>
  
  
  
  1.3       +1 -1      avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/repository/LocalRepositoryTestCase.java
  
  Index: LocalRepositoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/test/org/apache/avalon/composition/repository/LocalRepositoryTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalRepositoryTestCase.java	8 Jul 2003 13:47:07 -0000	1.2
  +++ LocalRepositoryTestCase.java	14 Jul 2003 04:49:36 -0000	1.3
  @@ -83,7 +83,7 @@
       {
           File base = new File( System.getProperty("basedir") );
           File target = new File( base, "target" );
  -        File source = new File( target, "test-repository" );
  +        File source = new File( target, "test-classes/repository" );
           source.mkdirs();
   
           m_repository = setUpRepository( source );
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message