avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit AbstractMerlinTestCase.java
Date Sat, 13 Dec 2003 18:25:55 GMT
mcconnell    2003/12/13 10:25:55

  Modified:    merlin   maven.xml
               merlin/kernel/impl/conf kernel.xml
               merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl
                        DefaultCriteria.java DefaultFactory.java
               merlin/kernel/plugin maven.xml
               merlin/kernel/plugin/src/java/org/apache/avalon/merlin/tools
                        MerlinBean.java
               merlin/kernel/unit maven.xml merlin.properties project.xml
               merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit
                        AbstractMerlinTestCase.java
  Added:       merlin/kernel/main .cvsignore maven.xml project.xml
               merlin/kernel/main/src/java/org/apache/avalon/merlin/main
                        DefaultMerlinBuilder.java package.html
  Log:
  Addition of a kernel builder utility that provides support for the handling of property
file inspection for a merlin.implemetation property that can be used to switch in alternative
implementation of the kernel based on client property settings.
  
  Revision  Changes    Path
  1.19      +2 -1      avalon/merlin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/maven.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- maven.xml	11 Dec 2003 04:51:49 -0000	1.18
  +++ maven.xml	13 Dec 2003 18:25:54 -0000	1.19
  @@ -349,6 +349,7 @@
           <sourcepath path="${basedir}/activation/spi/src/java"/>
           <sourcepath path="${basedir}/activation/impl/src/java"/>
           <sourcepath path="${basedir}/kernel/api/src/java"/>
  +        <sourcepath path="${basedir}/kernel/main/src/java"/>
           <sourcepath path="${basedir}/kernel/impl/src/java"/>
           <sourcepath path="${basedir}/kernel/unit/src/java"/>
           <classpath>
  @@ -379,7 +380,7 @@
         excludes="project.xml,merlin-extensions/**"
         goals="clean:clean"
         banner="Cleaning subproject:"
  -      ignoreFailures="false"/>
  +      ignoreFailures="true"/>
     </goal>
   
     <goal name="merlin-clean" prereqs="merlin:clean"/>
  
  
  
  1.3       +1 -1      avalon/merlin/kernel/impl/conf/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/conf/kernel.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- kernel.xml	8 Dec 2003 15:37:13 -0000	1.2
  +++ kernel.xml	13 Dec 2003 18:25:54 -0000	1.3
  @@ -2,7 +2,7 @@
   
   <kernel>
      <logging name="kernel" target="default" priority="INFO">
  -      <category name="" priority="WARN"/>
  +      <category name="" priority="INFO"/>
      </logging>
      <repository>
        <hosts>
  
  
  
  1.7       +58 -15    avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java
  
  Index: DefaultCriteria.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultCriteria.java	12 Dec 2003 14:02:35 -0000	1.6
  +++ DefaultCriteria.java	13 Dec 2003 18:25:54 -0000	1.7
  @@ -103,15 +103,54 @@
       private static final File TEMP_DIR = 
         new File( System.getProperty( "java.io.tmpdir" ) );
       private static final File AVALON_HOME_DIR = 
  -      new File( USER_HOME, ".avalon" );
  +      getAvalonHomeDirectory();
       private static final File MERLIN_HOME_DIR = 
  -      new File( USER_HOME, ".merlin" );
  +      getMerlinHomeDirectory();
  +
  +    private static File getAvalonHomeDirectory()
  +    {
  +        return getEnvironment( "AVALON_HOME", ".avalon" );
  +    }
  +
  +    private static File getMerlinHomeDirectory()
  +    {
  +        return getEnvironment( "MERLIN_HOME", ".merlin" );
  +    }
  +
  +    private static File getEnvironment( String symbol, String path )
  +    {
  +        try
  +        {
  +            String home = 
  +              System.getProperty( 
  +                "merlin.home", 
  +                Env.getEnvVariable( "MERLIN_HOME" ) );
  +
  +            if( null != home ) return new File( home ).getCanonicalFile();
  +
  +            return new File(
  +              System.getProperty( "user.home" ) 
  +              + File.separator 
  +              + ".merlin" ).getCanonicalFile();
  +
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Internal error while attempting to access MERLIN_HOME environment variable.";
  +            final String message = 
  +              ExceptionHelper.packException( error, e, true );
  +            throw new RuntimeException( message );
  +        }
  +    }
  +
   
      /**
       * The factory parameters template.
       */
  -    private static final Parameter[] PARAMS = 
  -      new Parameter[]{
  +    private static Parameter[] buildParameters( InitialContext context )
  +    { 
  +        return new Parameter[]{
           new Parameter( 
             MERLIN_REPOSITORY,
             File.class, AVALON_HOME_DIR ),
  @@ -133,7 +172,7 @@
           new Parameter( 
             MERLIN_OVERRIDE, String.class, null ),
           new Parameter( 
  -          MERLIN_DIR, File.class, USER_DIR ),
  +          MERLIN_DIR, File.class, context.getInitialWorkingDirectory() ),
           new Parameter( 
             MERLIN_TEMP, File.class, TEMP_DIR ),
           new Parameter( 
  @@ -151,12 +190,13 @@
           new Parameter( 
             MERLIN_LANG, String.class, null )
         };
  +    }
   
  -    private static final String [] SINGLE_KEYS = 
  -      Parameter.getKeys( PARAMS );
  +    //private static final String [] SINGLE_KEYS = 
  +    //  Parameter.getKeys( PARAMS );
   
  -    private static final String[] MULTI_VALUE_KEYS = 
  -      new String[0];
  +    //private static final String[] MULTI_VALUE_KEYS = 
  +    //  new String[0];
   
       //--------------------------------------------------------------
       // immutable state
  @@ -173,7 +213,7 @@
       */
       public DefaultCriteria( InitialContext context )
       {
  -        super( PARAMS );
  +        super( buildParameters( context ) );
   
           m_context = context;
   
  @@ -236,7 +276,9 @@
               new SystemDefaultsFinder() 
             };
           
  -        Defaults defaults = new Defaults( SINGLE_KEYS, MULTI_VALUE_KEYS, finders );
  +        Defaults defaults = 
  +          new Defaults( 
  +             Parameter.getKeys( super.getParameters() ), new String[0], finders );
   
           //
           // add ${merlin.dir} to assist in synbol expansion then expand
  @@ -255,9 +297,10 @@
   
           put( "merlin.dir", work.toString() );
           ArrayList errors = new ArrayList();
  -        for( int i=0; i<PARAMS.length; i++ )
  +        Parameter[] params = super.getParameters();
  +        for( int i=0; i<params.length; i++ )
           {
  -            Parameter param = PARAMS[i];
  +            Parameter param = params[i];
               final String key = param.getKey();
               if( !key.equals( "merlin.dir" ) )
               {
  @@ -300,7 +343,7 @@
       */
       public String toString()
       {
  -        return "[merlin: " + super.toString() + "]";
  +        return super.toString();
       }
   
       //--------------------------------------------------------------
  
  
  
  1.6       +0 -13     avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultFactory.java	10 Dec 2003 06:13:53 -0000	1.5
  +++ DefaultFactory.java	13 Dec 2003 18:25:54 -0000	1.6
  @@ -347,19 +347,6 @@
                 "\n  ${merlin.autostart} == " 
                 + criteria.isAutostartEnabled() );
   
  -            /*
  -            Iterator keys = criteria.keySet().iterator();
  -            while( keys.hasNext() )
  -            {
  -                String key = (String) keys.next();
  -                if( !key.equals( "merlin.deployment" ) )
  -                {
  -                    Object value = criteria.get( key );
  -                    buffer.append( "\n  ${" + key + "} == " + value );
  -                }
  -            }
  -            */
  -
               buffer.append( "\n  ${merlin.deployment} == " );
               URL[] urls = criteria.getDeploymentURLs();
               for( int i=0; i<urls.length; i++ )
  
  
  
  1.1                  avalon/merlin/kernel/main/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  maven.log
  velocity.log
  snapshot.properties
  .classpath
  .project
  
  
  
  1.1                  avalon/merlin/kernel/main/maven.xml
  
  Index: maven.xml
  ===================================================================
  
  <project default="jar:install" xmlns:j="jelly:core" xmlns:ant="jelly:ant">
  
    <!--
    Create the merlin.properties property file.                    
    This contains the information used to identify the             
    the default merlin implementation artifact.                    
    -->
  
    <postGoal name="java:compile">
      <j:set var="impl" value="${pom.getDependency('merlin:merlin-impl')}"/>
      <ant:echo file="${maven.build.dir}/classes/merlin.properties">
  #===================================================================#
  # Default merlin implementation artifact identifier.                #
  #===================================================================#
  
  merlin.implementation = ${impl.groupId}:${impl.artifactId};${impl.version}
  
  </ant:echo>
    </postGoal>
  
  </project>
  
  
  
  1.1                  avalon/merlin/kernel/main/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <project>
  
    <extend>${basedir}/../../project.xml</extend>
  
    <groupId>merlin</groupId>
    <id>merlin-main</id>
    <name>Merlin Embedding Reference</name>
    <currentVersion>3.2-dev</currentVersion>
  
    <package>org.apache.avalon.merlin</package>
  
    <inceptionYear>2002</inceptionYear>
    <shortDescription>Merlin Builder</shortDescription>
    
    <dependencies>
      <dependency>
        <groupId>merlin</groupId>
        <artifactId>merlin-impl</artifactId>
        <version>3.2-dev</version>
      </dependency>
      <dependency>
        <groupId>avalon-repository</groupId>
        <artifactId>avalon-repository-main</artifactId>
        <version>1.2-dev</version>
      </dependency>
    </dependencies>
  
    <build>
  
      <sourceDirectory>${basedir}/src/java/</sourceDirectory>
      <unitTestSourceDirectory>${basedir}/src/test/</unitTestSourceDirectory>
  
      <resources>
        <resource>
          <directory>${basedir}/src/java</directory>
          <includes> 
            <include>**/*.properties</include>
          </includes>
        </resource>
      </resources>
  
      <jars></jars>
  
    </build>
  
  </project>
  
  
  
  1.1                  avalon/merlin/kernel/main/src/java/org/apache/avalon/merlin/main/DefaultMerlinBuilder.java
  
  Index: DefaultMerlinBuilder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.merlin.main;
  
  import org.apache.avalon.repository.main.DefaultBuilder;
  import org.apache.avalon.repository.provider.InitialContext;
  
  
  /**
   * Application and component bootstrapper used to instantiate, and or invoke
   * Classes and their methods within newly constructed Merlin ClassLoaders.
   * 
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultMerlinBuilder extends DefaultBuilder
  {
      //-----------------------------------------------------------
      // static
      //-----------------------------------------------------------
  
      private static final String MERLIN_PROPERITES = "merlin.properties";
  
      private static final String IMPLEMENTATION_KEY = "merlin.implementation";
  
      //-----------------------------------------------------------
      // constructors
      //-----------------------------------------------------------
  
     /**
      * Creates a DefaultBuilder for a specific target application.
      * 
      * @param context the initial repository context
      * @exception Exception if a app factory creation error occurs
      */
      public DefaultMerlinBuilder( InitialContext context )
          throws Exception
      {
          super( 
            context, 
            DefaultBuilder.class.getClassLoader(),
            createImplementationArtifact( 
              DefaultBuilder.class.getClassLoader(),
              context.getInitialWorkingDirectory(), 
              MERLIN_PROPERITES, 
              IMPLEMENTATION_KEY ) );
      }
  
  }
  
  
  
  1.1                  avalon/merlin/kernel/main/src/java/org/apache/avalon/merlin/main/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The merlin builder package contains a utiity class that simplifies the building of a kernel
factory.
  </p>
  </body>
  
  
  
  
  1.3       +29 -1     avalon/merlin/kernel/plugin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/plugin/maven.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- maven.xml	8 Dec 2003 15:37:13 -0000	1.2
  +++ maven.xml	13 Dec 2003 18:25:55 -0000	1.3
  @@ -1,2 +1,30 @@
  -<project default="plugin:install">
  +<project default="plugin:install" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util"
xmlns:ant="jelly:ant">
  +
  +  <!--
  +  ###################################################################
  +  # Create the merlin.implementation property file.                 #
  +  # This contains the information used to identify the              #
  +  # the implementation artifact classpath, factory, etc.            #
  +  ###################################################################
  +  -->
  +
  +  <postGoal name="java:compile">
  +    <ant:echo file="${maven.build.dir}/classes/merlin.implementation">
  +#===================================================================#
  +# Default merlin implementation artifact identifier.                #
  +#===================================================================#
  +
  +meta.domain = avalon
  +meta.version = 1.0
  +avalon.artifact.group = ${merlin.implementation.group}
  +avalon.artifact.name = ${merlin.implementation.name}
  +avalon.artifact.version = ${merlin.implementation.version}
  +
  +#
  +# EOF
  +#
  +</ant:echo>
  +  </postGoal>
  +
  +
   </project>
  
  
  
  1.6       +86 -4     avalon/merlin/kernel/plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java
  
  Index: MerlinBean.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MerlinBean.java	11 Dec 2003 04:51:49 -0000	1.5
  +++ MerlinBean.java	13 Dec 2003 18:25:55 -0000	1.6
  @@ -51,6 +51,7 @@
   package org.apache.avalon.merlin.tools;
   
   import java.io.File;
  +import java.io.InputStream;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.util.Map;
  @@ -82,6 +83,16 @@
   public class MerlinBean
   {
       //----------------------------------------------------------
  +    // static
  +    //----------------------------------------------------------
  +
  +    private static final String MERLIN = "merlin.properties";
  +
  +    private static final String IMPLEMENTATION_KEY = "merlin.implementation";
  +
  +    private static final String IMPLEMENTATION_PATH = "merlin.implementation";
  +
  +    //----------------------------------------------------------
       // immutable state
       //----------------------------------------------------------
   
  @@ -139,9 +150,9 @@
       {
           try
           {
  -            Artifact artifact = 
  -              Artifact.createArtifact( 
  -                "merlin", "merlin-impl", "3.2-dev" );
  +            Artifact artifact = getImplementation();
  +            //  Artifact.createArtifact( 
  +            //    "merlin", "merlin-impl", "3.2-dev" );
   
               InitialContext context = 
                  new DefaultInitialContext( 
  @@ -208,6 +219,77 @@
           properties.load( new FileInputStream( file ) );
           return properties;
       }
  +
  +   /**
  +    * Resolve the default implementation taking into account 
  +    * command line arguments, local and hom properties, and 
  +    * application defaults.
  +    * @param line the command line construct
  +    * @return the artifact reference
  +    */
  +    private Artifact getImplementation() throws Exception
  +    {
  +        //
  +        // check in ${basedir}/merlin.properties and ${user.home}/merlin.properties
  +        // for a "merlin.implementation" property and use it if decleared
  +        //
  +
  +        File user = new File( System.getProperty( "user.home" ) );
  +        String spec1 = 
  +          getLocalProperties( user, MERLIN ).
  +            getProperty( IMPLEMENTATION_KEY );
  +        String spec = 
  +          getLocalProperties( getBaseDirectory(), MERLIN ).
  +            getProperty( IMPLEMENTATION_KEY, spec1 );
  +        if( null != spec )
  +        {
  +            return Artifact.createArtifact( spec );
  +        }
  +
  +        //
  +        // otherwise go with the defaults packaged with the jar file
  +        //
  + 
  +        Properties properties = loadProperties( IMPLEMENTATION_PATH );
  +        final String group = 
  +          properties.getProperty( Artifact.GROUP_KEY );
  +        final String name = 
  +          properties.getProperty( Artifact.NAME_KEY  );
  +        final String version = 
  +          properties.getProperty( Artifact.VERSION_KEY );
  +        return Artifact.createArtifact( group, name, version );
  +    }
  +
  +   /**
  +    * Load a properties file from a supplied resource name.
  +    * @path the resource path
  +    * @return the properties instance
  +    */
  +    private Properties loadProperties( String path )
  +    {
  +        try
  +        {
  +            Properties properties = new Properties();
  +            ClassLoader classloader = MerlinBean.class.getClassLoader();
  +            InputStream input = classloader.getResourceAsStream( path );
  +            if( input == null ) 
  +            {
  +                final String error = 
  +                  "Missing resource: [" + path + "]";
  +                throw new Error( error );
  +            }
  +            properties.load( input );
  +            return properties;
  +        }
  +        catch ( Throwable e )
  +        {
  +            final String error = 
  +              "Internal error. " 
  +              + "Unable to locate the resource: [" + IMPLEMENTATION_PATH + "].";
  +            throw new IllegalArgumentException( error );
  +        }
  +    }
  +
   
   
       private static File getMavenRepositoryDirectory()
  
  
  
  1.5       +26 -0     avalon/merlin/kernel/unit/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/maven.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- maven.xml	8 Dec 2003 15:37:13 -0000	1.4
  +++ maven.xml	13 Dec 2003 18:25:55 -0000	1.5
  @@ -1,6 +1,32 @@
   
   <project default="jar:install" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util"
xmlns:ant="jelly:ant">
   
  +  <!--
  +  ###################################################################
  +  # Create the merlin.implementation property file.                 #
  +  # This contains the information used to identify the              #
  +  # the implementation artifact.                                    #
  +  ###################################################################
  +  -->
  +
  +  <postGoal name="java:compile">
  +    <ant:echo file="${maven.build.dir}/classes/merlin.implementation">
  +#===================================================================#
  +# Default merlin implementation artifact identifier.                #
  +#===================================================================#
  +
  +meta.domain = avalon
  +meta.version = 1.0
  +avalon.artifact.group = ${merlin.implementation.group}
  +avalon.artifact.name = ${merlin.implementation.name}
  +avalon.artifact.version = ${merlin.implementation.version}
  +
  +#
  +# EOF
  +#
  +</ant:echo>
  +  </postGoal>
  +
     <preGoal name="jar:jar">
       <j:forEach var="dep" items="${pom.dependencies}">
         <j:if test="${dep.getId() != 'junit:junit'}">
  
  
  
  1.2       +3 -2      avalon/merlin/kernel/unit/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/merlin.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- merlin.properties	8 Dec 2003 15:37:13 -0000	1.1
  +++ merlin.properties	13 Dec 2003 18:25:55 -0000	1.2
  @@ -1,5 +1,6 @@
   
  -merlin.info = false
  +merlin.info = true
   merlin.debug = false
  -merlin.deployment = conf/test.block,conf/test-2.block,conf/hello.block
  +merlin.deployment = conf/hello.block
   merlin.override = conf/override.xml
  +merlin.implementation = merlin:merlin-impl;SNAPSHOT
  
  
  
  1.17      +5 -0      avalon/merlin/kernel/unit/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/project.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- project.xml	11 Dec 2003 04:51:49 -0000	1.16
  +++ project.xml	13 Dec 2003 18:25:55 -0000	1.17
  @@ -21,6 +21,11 @@
         <version>1.2-dev</version>
       </dependency>
       <dependency>
  +      <groupId>merlin</groupId>
  +      <artifactId>merlin-main</artifactId>
  +      <version>3.2-dev</version>
  +    </dependency>
  +    <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>3.8.1</version>
  
  
  
  1.20      +16 -70    avalon/merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java
  
  Index: AbstractMerlinTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AbstractMerlinTestCase.java	11 Dec 2003 04:51:49 -0000	1.19
  +++ AbstractMerlinTestCase.java	13 Dec 2003 18:25:55 -0000	1.20
  @@ -51,6 +51,7 @@
   package org.apache.avalon.merlin.unit;
   
   import java.io.File;
  +import java.io.InputStream;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.util.Map;
  @@ -68,6 +69,7 @@
   import org.apache.avalon.repository.RepositoryException;
   import org.apache.avalon.repository.main.DefaultInitialContext;
   import org.apache.avalon.repository.main.DefaultBuilder;
  +import org.apache.avalon.merlin.main.DefaultMerlinBuilder;
   
   import org.apache.avalon.util.env.Env;
   import org.apache.avalon.util.exception.ExceptionHelper;
  @@ -120,15 +122,12 @@
       {
           try
           {
  -            Artifact artifact = 
  -              Artifact.createArtifact( 
  -                "merlin", "merlin-impl", "3.2-dev" );
  +            File repository = new File( getMavenHome(), "repository" );
   
               InitialContext context = 
  -               new DefaultInitialContext( 
  -                 getMavenRepositoryDirectory() );
  +               new DefaultInitialContext( repository );
   
  -            Builder builder = new DefaultBuilder( context, artifact );
  +            Builder builder = new DefaultMerlinBuilder( context );
               m_classloader = builder.getClassLoader();
               Factory factory = builder.getFactory();
               Map criteria = factory.createDefaultCriteria();
  @@ -137,15 +136,9 @@
               // set the defaults
               //
   
  -            criteria.put( "merlin.repository", getMavenRepositoryDirectory() );
  -            criteria.put( "merlin.context", new File( getBaseDirectory(), "target" ) );
  -
  -            //
  -            // read in any properties declared under the path 
  -            // ${basedir}/merlin.properties
  -            //
  -
  -            applyLocalProperties( criteria );
  +            criteria.put( "merlin.repository", repository );
  +            criteria.put( "merlin.context", "target" );
  +            criteria.put( "merlin.server", "true" );
   
               //
               // if the deployment path is undefined then the best we 
  @@ -283,46 +276,7 @@
           return null;
       }
   
  -    private void applyLocalProperties( Map criteria ) throws IOException
  -    {
  -        File base = getBaseDirectory();
  -        Properties properties = 
  -          getLocalProperties( base, "merlin.properties" );
  -        Enumeration keys = properties.keys();
  -        while( keys.hasMoreElements() )
  -        {
  -            final String key = (String) keys.nextElement();
  -            if( key.startsWith( "merlin." ) )
  -            {
  -                String value = properties.getProperty( key );
  -                criteria.put( key, value );
  -            }
  -        }
  -    }
  -
  -    private Properties getLocalProperties( 
  -      File dir, String filename ) throws IOException
  -    {
  -        Properties properties = new Properties();
  -        if( null == dir ) return properties;
  -        File file = new File( dir, filename );
  -        if( !file.exists() ) return properties;
  -        properties.load( new FileInputStream( file ) );
  -        return properties;
  -    }
  -
  -
  -    private static File getMavenRepositoryDirectory()
  -    {
  -        return new File( getMavenHomeDirectory(), "repository" );
  -    }
  -
  -    private static File getMavenHomeDirectory()
  -    {
  -        return new File( getMavenHome() );
  -    }
  -
  -    private static String getMavenHome()
  +    private static File getMavenHome()
       {
           try
           {
  @@ -331,9 +285,12 @@
                   "maven.home.local", 
                   Env.getEnvVariable( "MAVEN_HOME_LOCAL" ) );
   
  -            if( null != local ) return local;
  +            if( null != local ) return new File( local ).getCanonicalFile();
   
  -            return System.getProperty( "user.home" ) + File.separator + ".maven";
  +            return new File(
  +              System.getProperty( "user.home" ) 
  +              + File.separator 
  +              + ".maven" ).getCanonicalFile();
   
           }
           catch( Throwable e )
  @@ -346,18 +303,6 @@
           }
       }
   
  -    private static String getEnvValue( String key )
  -    {
  -        try
  -        {
  -            return Env.getEnvVariable( key );
  -        }
  -        catch( Throwable e )
  -        {
  -            throw new RuntimeException( e.toString() );
  -        }
  -    }
  -
       private File getBaseDirectory()
       {
           final String base = System.getProperty( "basedir" );
  @@ -367,4 +312,5 @@
           }
           return new File( System.getProperty( "user.dir" ) );
       }
  +
   }
  
  
  

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


Mime
View raw message