Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 40254 invoked by uid 500); 27 Jun 2003 22:52:14 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 40243 invoked by uid 500); 27 Jun 2003 22:52:13 -0000 Received: (qmail 40240 invoked from network); 27 Jun 2003 22:52:13 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 27 Jun 2003 22:52:13 -0000 Received: (qmail 12664 invoked by uid 1438); 27 Jun 2003 22:52:13 -0000 Date: 27 Jun 2003 22:52:13 -0000 Message-ID: <20030627225213.12663.qmail@icarus.apache.org> From: mcconnell@apache.org To: avalon-sandbox-cvs@apache.org Subject: cvs commit: avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/repository LocalRepositoryTestCase.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mcconnell 2003/06/27 15:52:12 Modified: merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl DefaultAppliance.java merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl EngineClassLoader.java merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl DefaultDeploymentService.java merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl SingletonLifestyleHandler.java merlin/assembly/src/java/org/apache/avalon/assembly/repository/impl FileRepository.java merlin/assembly/src/test/org/apache/avalon/assembly TestBase.java merlin/assembly/src/test/org/apache/avalon/assembly/engine ApplianceTestCase.java EngineTestCase.java FactoryTestCase.java merlin/assembly/src/test/org/apache/avalon/assembly/repository LocalRepositoryTestCase.java Added: merlin/assembly/src/java/org/apache/avalon/assembly/repository/impl DefaultAuthenticator.java HttpController.java Log: Updates incorporating a structured repository implemetation. Revision Changes Path 1.18 +1 -3 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java Index: DefaultAppliance.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- DefaultAppliance.java 24 Jun 2003 20:50:18 -0000 1.17 +++ DefaultAppliance.java 27 Jun 2003 22:52:11 -0000 1.18 @@ -663,7 +663,6 @@ * assembly directive, or implicity disabled as a result of an assembly failure. * * @return TRUE if the profile is enabled. - * @see #setEnabled( boolean ) */ public boolean isEnabled() { @@ -673,7 +672,6 @@ /** * Set the enabled status of the profile to the supplied value. * @param value the enabled status - TRUE or FALSE - * @see #isEnabled() */ private void setEnabled( boolean value ) { 1.11 +3 -19 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/EngineClassLoader.java Index: EngineClassLoader.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/EngineClassLoader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- EngineClassLoader.java 23 Jun 2003 02:37:49 -0000 1.10 +++ EngineClassLoader.java 27 Jun 2003 22:52:11 -0000 1.11 @@ -291,27 +291,11 @@ */ public void contextualize( Locator context ) throws ContextException { + m_repository = (Repository) context.get( Repository.KEY ); + if( context.hasEntry( "urn:assembly:system" ) ) { m_root = (File) context.get( "urn:assembly:system" ); - } - - // - // a repository is option - if not supplied and no root system directory - // if declared, then resource references in a classpath will raise an error. - // - - if( context.hasEntry( Repository.KEY ) ) - { - m_repository = (Repository) context.get( Repository.KEY ); - } - else - { - if( m_root != null ) - { - File repository = new File( m_root, "repository" ); - m_repository = FileRepository.newInstance( repository ); - } } if( context.hasEntry( "urn:assembly:system-map" ) ) 1.16 +3 -3 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java Index: DefaultDeploymentService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- DefaultDeploymentService.java 22 Jun 2003 00:28:33 -0000 1.15 +++ DefaultDeploymentService.java 27 Jun 2003 22:52:12 -0000 1.16 @@ -310,7 +310,7 @@ else { final String error = - "Component deployment failure in appliance: " + "Component deployment failure in: " + appliance; throw new DeploymentException( error, ce ); } @@ -322,7 +322,7 @@ catch( Throwable e ) { final String error = - "Component deployment failure in appliance: " + "Component deployment failure in: " + appliance; throw new DeploymentException( error, e ); } 1.6 +9 -1 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/SingletonLifestyleHandler.java Index: SingletonLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/SingletonLifestyleHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SingletonLifestyleHandler.java 24 Jun 2003 20:50:19 -0000 1.5 +++ SingletonLifestyleHandler.java 27 Jun 2003 22:52:12 -0000 1.6 @@ -99,6 +99,14 @@ Object object = newInstance(); super.processAccessStage( object ); + + if( getLogger().isDebugEnabled() ) + { + final String debug = + "access complete: " + getAppliance(); + getLogger().debug( debug ); + } + return object; } 1.5 +202 -236 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/repository/impl/FileRepository.java Index: FileRepository.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/repository/impl/FileRepository.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FileRepository.java 26 May 2003 17:51:52 -0000 1.4 +++ FileRepository.java 27 Jun 2003 22:52:12 -0000 1.5 @@ -60,25 +60,31 @@ import java.net.URLConnection; import java.util.ArrayList; import java.util.List; +import java.net.Authenticator; import org.apache.avalon.assembly.repository.Repository; import org.apache.avalon.assembly.repository.RepositoryException; import org.apache.avalon.assembly.repository.TransportException; import org.apache.avalon.assembly.util.ExceptionHelper; +import org.apache.avalon.framework.logger.AbstractLogEnabled; 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.context.DefaultContext; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.excalibur.configuration.ConfigurationUtil; /** * A component that provides access to versioned resources based on * an underlying file system. * - * @author Stephen McConnell - * @author David Bernard + * @author Avalon Development Team * @version $Revision$ $Date$ */ -public class FileRepository implements Repository, Contextualizable +public class FileRepository extends AbstractLogEnabled + implements Contextualizable, Configurable, Repository { //------------------------------------------------------------------ // static @@ -86,47 +92,6 @@ public static final String BASE_KEY = "urn:avalon:repository.base"; - public static final String HOSTS_KEY = "urn:avalon:repository.hosts"; - - public static final URL DEFAULT_HOST = getDefaultHost(); - - private static URL getDefaultHost() - { - try - { - return new URL( "http://www.osm.net/repository/" ); - } - catch( Throwable e ) - { - throw new RuntimeException( "default-host" ); - } - } - - /** - * Utility method to construct a new repository using the supplied - * directory as a local file cache. - */ - public static Repository newInstance( File base ) throws ContextException - { - final URL[] hosts = new URL[]{ DEFAULT_HOST }; - return newInstance( hosts, base ); - } - - /** - * Utility method to construct a new repository using the supplied - * directory as a local file cache and the supplied URL array as a - * sequence of remote repository sources. - */ - public static Repository newInstance( URL[] hosts, File base ) throws ContextException - { - FileRepository repository = new FileRepository(); - DefaultContext context = new DefaultContext(); - context.put( HOSTS_KEY, hosts ); - context.put( BASE_KEY, base ); - repository.contextualize( context ); - return repository; - } - //------------------------------------------------------------------ // state //------------------------------------------------------------------ @@ -141,6 +106,7 @@ */ private URL[] m_hosts; + //------------------------------------------------------------------ // lifecycle //------------------------------------------------------------------ @@ -153,10 +119,128 @@ * @exception ContextException of the supplied context does not include * a File instance under the context entry 'urn:avalon:repository.base'. */ - public void contextualize( Context context ) throws ContextException + public void contextualize( final Context context ) throws ContextException { m_base = (File) context.get( BASE_KEY ); - m_hosts = (URL[]) context.get( HOSTS_KEY ); + } + + /** + *

Configuration of the repository by the container.

+ *

Example configuration:

+ *
  +    *   <repository>
  +    *     <cache></cache> <!-- optional -->
  +    *     <proxy> <!-- optional -->
  +    *       <host></host>
  +    *       <port></port>
  +    *       <credentials>
  +    *         <username></username>
  +    *         <password></password>
  +    *       </credentials>
  +    *     </proxy>
  +    *     <hosts> <!-- optional -->
  +    *       <host></host>
  +    *       <host></host>
  +    *     <hosts>
  +    *   </repository>
  +    * 
+ * + * @param config the repostory configuration + * @exception ConfigurationException if a confiuration related error occurs + */ + public void configure( final Configuration config ) throws ConfigurationException + { + if( config == null ) + { + throw new NullPointerException( "config" ); + } + + // + // set the repository cache + // + + String cache = config.getChild( "cache" ).getValue( null ); + if( cache != null ) + { + m_base = new File( cache ); + getLogger().debug( "setting cache to: " + m_base ); + } + m_base.mkdirs(); + + // + // set the remote repository urls + // + + final ArrayList list = new ArrayList(); + final Configuration[] hosts = config.getChild( "hosts" ).getChildren( "host" ); + for( int i=0; i. */ package org.apache.avalon.assembly.repository.impl; import java.net.Authenticator; import java.net.PasswordAuthentication; import org.apache.avalon.framework.configuration.Configuration; /** * Default authenticator that provides support for username password * based authentication in conjunction with the repository proxy settings. * * @author Avalon Development Team * @version $Revision: 1.1 $ $Date: 2003/06/27 22:52:12 $ */ public final class DefaultAuthenticator extends Authenticator { /** * Proxy username. */ private String m_username; /** * Proxy password. */ private char[] m_password; /** *

Configuration of the authenticator by the container.

* *

Example configuration:

* * <credentials> * <username>test</username> * <password>test</password> * <credentials> * * @param config the authenticator configuration * @exception NullPointerException if the supplied configuration is null */ public DefaultAuthenticator( Configuration config ) throws NullPointerException { if( config == null ) { throw new NullPointerException( "config" ); } m_username = config.getChild( "username" ).getValue( null ); String password = config.getChild( "password" ).getValue( null ); if( password == null ) { m_password = new char[0]; } else { m_password = password.toCharArray(); } } /** * Returns the password authenticator. * @return the password authenticator */ protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication( m_username, m_password ); } } 1.1 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/repository/impl/HttpController.java Index: HttpController.java =================================================================== package org.apache.avalon.assembly.repository.impl; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; /** * Class supporting the retrival of remotely located resources. * Implementation is based on original code from the Maven project * refactored to seperate static proxy establishment from transport * concerns. * * @author costin@dnt.ro * @author gg@grtmail.com (Added Java 1.1 style HTTP basic auth) * @author Jason van Zyl * @author Avalon Development Team * @version $Revision: 1.1 $ $Date: 2003/06/27 22:52:12 $ */ class HttpController { /** * Retrieve a remote file. Returns true if the file was updated, false * if the existing cached resource was not modified. * * @param url the of the file to retrieve * @param destinationFile where to store it * @param useTimestamp whether to check the modified timestamp on the * destinationFile against the remote source * @param useChecksum Flag to indicate the use of the checksum for the retrieved * artifact if it is available. */ public static boolean getFile( String url, File destinationFile, boolean useTimestamp, boolean useChecksum ) throws Exception { // Get the requested file. boolean result = getFile( url, destinationFile, useTimestamp ); // Get the checksum if requested. if ( useChecksum ) { File checksumFile = new File( destinationFile + ".md5" ); try { getFile( url + ".md5", checksumFile, useTimestamp ); } catch ( Exception e ) { // do nothing we will check later in the process // for the checksums. } } return result; } /** * Retrieve a remote file. Returns true if the file was successfully * retrieved or if it is up to date (when the useTimestamp flag is set). * * @param url the of the file to retrieve * @param destinationFile where to store it * @param useTimestamp whether to check the modified timestamp on the * destinationFile against the remote source * @return TRUE if the file was updated else FALSE */ public static boolean getFile( String url, File destinationFile, boolean useTimestamp ) throws Exception { String[] s = parseUrl( url ); String username = s[0]; String password = s[1]; String parsedUrl = s[2]; URL source = new URL( parsedUrl ); //set the timestamp to the file date. long timestamp = 0; boolean hasTimestamp = false; if ( useTimestamp && destinationFile.exists() ) { timestamp = destinationFile.lastModified(); hasTimestamp = true; } //set up the URL connection URLConnection connection = source.openConnection(); //modify the headers //NB: things like user authentication could go in here too. if ( useTimestamp && hasTimestamp ) { connection.setIfModifiedSince( timestamp ); } //connect to the remote site (may take some time) connection.connect(); //next test for a 304 result (HTTP only) if ( connection instanceof HttpURLConnection ) { HttpURLConnection httpConnection = (HttpURLConnection) connection; if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED ) { return false; } // test for 401 result (HTTP only) if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED ) { throw new Exception( "Not authorized." ); } } // REVISIT: at this point even non HTTP connections may support the // if-modified-since behaviour - we just check the date of the // content and skip the write if it is not newer. // Some protocols (FTP) dont include dates, of course. InputStream is = null; for ( int i = 0; i < 3; i++ ) { try { is = connection.getInputStream(); break; } catch ( IOException ex ) { // do nothing } } if ( is == null ) { final String error = "Connection returned a null input stream: " + url; throw new IOException( error ); } File parent = destinationFile.getParentFile(); parent.mkdirs(); FileOutputStream fos = new FileOutputStream( destinationFile ); byte[] buffer = new byte[100 * 1024]; int length; while ( ( length = is.read( buffer ) ) >= 0 ) { fos.write( buffer, 0, length ); } fos.close(); is.close(); // if (and only if) the use file time option is set, then the // saved file now has its timestamp set to that of the downloaded // file if ( useTimestamp ) { long remoteTimestamp = connection.getLastModified(); if ( remoteTimestamp != 0 ) { touchFile( destinationFile, remoteTimestamp ); } } return true; } /** * Parse an url which might contain a username and password. If the * given url doesn't contain a username and password then return the * origin url unchanged. * * @param url The url to parse. * @return The username, password and url. */ static String[] parseUrl( String url ) { String[] parsedUrl = new String[3]; parsedUrl[0] = null; parsedUrl[1] = null; parsedUrl[2] = url; // We want to be able to deal with Basic Auth where the username // and password are part of the URL. An example of the URL string // we would like to be able to parse is like the following: // // http://username:password@repository.mycompany.com int i = url.indexOf( "@" ); if ( i > 0 ) { String s = url.substring( 7, i ); int j = s.indexOf( ":" ); parsedUrl[0] = s.substring( 0, j ); parsedUrl[1] = s.substring( j + 1 ); parsedUrl[2] = "http://" + url.substring( i + 1 ); } return parsedUrl; } /** * set the timestamp of a named file to a specified time. * * @param file the file to touch * @param timemillis in milliseconds since the start of the era * @return true if it succeeded. False means that this is a java1.1 system * and that file times can not be set * @exception Exception Thrown in unrecoverable error. Likely this * comes from file access failures. */ private static boolean touchFile( File file, long timemillis ) throws Exception { long modifiedTime; if ( timemillis < 0 ) { modifiedTime = System.currentTimeMillis(); } else { modifiedTime = timemillis; } file.setLastModified( modifiedTime ); return true; } } 1.7 +91 -0 avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/TestBase.java Index: TestBase.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/TestBase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TestBase.java 26 Apr 2003 12:37:47 -0000 1.6 +++ TestBase.java 27 Jun 2003 22:52:12 -0000 1.7 @@ -52,13 +52,24 @@ import java.io.File; +import org.apache.avalon.assembly.engine.impl.EngineClassLoader; +import org.apache.avalon.assembly.locator.impl.DefaultLocator; import org.apache.avalon.assembly.locator.impl.DefaultLocator; import org.apache.avalon.assembly.logging.impl.DefaultLoggingManager; import org.apache.avalon.assembly.logging.LoggingDescriptor; import org.apache.avalon.assembly.logging.LoggingManager; import org.apache.avalon.assembly.logging.TargetDescriptor; +import org.apache.avalon.assembly.repository.Repository; +import org.apache.avalon.assembly.repository.impl.FileRepository; +import org.apache.avalon.assembly.util.ExceptionHelper; import org.apache.avalon.framework.logger.Logger; +import org.apache.avalon.framework.context.DefaultContext; +import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.meta.model.Category; +import org.apache.excalibur.event.command.CommandManager; +import org.apache.excalibur.event.command.TPCThreadManager; +import org.apache.excalibur.mpool.DefaultPoolManager; +import org.apache.excalibur.mpool.PoolManager; import junit.framework.TestCase; @@ -107,4 +118,84 @@ { return m_logManager.getLoggerForCategory( "test" ); } + + protected EngineClassLoader setUpEngine( boolean bootstrap ) throws Exception + { + try + { + EngineClassLoader engine = new EngineClassLoader(); + engine.enableLogging( getLogger() ); + DefaultLocator context = new DefaultLocator(); + context.put( LoggingManager.KEY, m_logManager ); + context.put( "urn:assembly:engine.bootstrap", "" + bootstrap ); + context.put( Repository.KEY, getRepository() ); + context.put( PoolManager.ROLE, getPoolManager() ); + context.makeReadOnly(); + engine.contextualize( context ); + engine.initialize(); + return engine; + } + catch( Exception e ) + { + ExceptionHelper.printException( "Engine setup failure.", e, this, true ); + assertTrue( false ); + throw e; + } + } + + private Repository getRepository() throws Exception + { + File base = new File( System.getProperty("basedir") ); + File target = new File( base, "target" ); + File root = new File( target, "test-repository" ); + root.mkdirs(); + FileRepository repository = new FileRepository(); + repository.enableLogging( getLogger().getChildLogger( "repository" ) ); + DefaultContext context = new DefaultContext(); + context.put( FileRepository.BASE_KEY, root ); + context.makeReadOnly(); + repository.contextualize( context ); + return repository; + } + + private PoolManager getPoolManager() throws Exception + { + try + { + // + // Set up the ThreadManager that the CommandManager uses + // + + TPCThreadManager threadManager = new TPCThreadManager(); + threadManager.enableLogging( getLogger().getChildLogger( "threads" ) ); + Parameters params = new Parameters(); + params.setParameter( "threads-per-processor", "2" ); + params.setParameter( "sleep-time", "1000" ); + params.setParameter( "block-timeout", "250" ); + threadManager.parameterize( params ); + threadManager.initialize(); + + // + // Set up the CommandManager that the PoolManager uses. + // + + CommandManager commandManager = new CommandManager(); + threadManager.register( commandManager ); + + // + // Set up the PoolManager that the pooled lifecycle helper needs + // + + DefaultPoolManager poolManager = + new DefaultPoolManager( commandManager.getCommandSink() ); + return poolManager; + } + catch( Throwable e ) + { + final String error = + "Internal error during establishment of the default pool manager. Cause: "; + throw new Exception( error + e.toString() ); + } + } + } 1.10 +6 -62 avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/ApplianceTestCase.java Index: ApplianceTestCase.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/ApplianceTestCase.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ApplianceTestCase.java 30 Apr 2003 02:03:41 -0000 1.9 +++ ApplianceTestCase.java 27 Jun 2003 22:52:12 -0000 1.10 @@ -50,6 +50,8 @@ package org.apache.avalon.assembly.engine; +import java.io.File; + import org.apache.avalon.assembly.TestBase; import org.apache.avalon.assembly.appliance.Appliance; import org.apache.avalon.assembly.appliance.DependencyGraph; @@ -57,8 +59,12 @@ import org.apache.avalon.assembly.engine.impl.DefaultTypeRepository; import org.apache.avalon.assembly.locator.impl.DefaultLocator; import org.apache.avalon.assembly.logging.LoggingManager; +import org.apache.avalon.assembly.repository.Repository; +import org.apache.avalon.assembly.repository.impl.FileRepository; import org.apache.avalon.assembly.util.ExceptionHelper; import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.context.DefaultContext; +import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.meta.info.StageDescriptor; import org.apache.excalibur.event.command.CommandManager; import org.apache.excalibur.event.command.TPCThreadManager; @@ -122,68 +128,6 @@ String error = ExceptionHelper.packException( reason, e ); getLogger().error( error ); assertTrue( false ); - } - } - - protected EngineClassLoader setUpEngine( boolean bootstrap ) throws Exception - { - try - { - EngineClassLoader engine = new EngineClassLoader(); - engine.enableLogging( getLogger() ); - DefaultLocator context = new DefaultLocator(); - context.put( "urn:assembly:engine.bootstrap", "" + bootstrap ); - context.put( LoggingManager.KEY, m_logManager ); - context.put( PoolManager.ROLE, getPoolManager() ); - context.makeReadOnly(); - engine.contextualize( context ); - engine.initialize(); - return engine; - } catch( Exception e ) - { - final String reason = "Engine setup failure."; - String error = ExceptionHelper.packException( reason, e ); - getLogger().error( error ); - throw new Exception( reason ); - } - } - - private PoolManager getPoolManager() throws Exception - { - try - { - // - // Set up the ThreadManager that the CommandManager uses - // - - TPCThreadManager threadManager = new TPCThreadManager(); - threadManager.enableLogging( getLogger().getChildLogger( "threads" ) ); - Parameters params = new Parameters(); - params.setParameter( "threads-per-processor", "2" ); - params.setParameter( "sleep-time", "1000" ); - params.setParameter( "block-timeout", "250" ); - threadManager.parameterize( params ); - threadManager.initialize(); - - // - // Set up the CommandManager that the PoolManager uses. - // - - CommandManager commandManager = new CommandManager(); - threadManager.register( commandManager ); - - // - // Set up the PoolManager that the pooled lifecycle helper needs - // - - DefaultPoolManager poolManager = - new DefaultPoolManager( commandManager.getCommandSink() ); - return poolManager; - } catch( Throwable e ) - { - final String error = - "Internal error during establishment of the default pool manager. Cause: "; - throw new Exception( error + e.toString() ); } } } 1.11 +0 -62 avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java Index: EngineTestCase.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- EngineTestCase.java 18 Jun 2003 11:16:15 -0000 1.10 +++ EngineTestCase.java 27 Jun 2003 22:52:12 -0000 1.11 @@ -265,66 +265,4 @@ } } - protected EngineClassLoader setUpEngine( boolean bootstrap ) throws Exception - { - try - { - EngineClassLoader engine = new EngineClassLoader(); - engine.enableLogging( getLogger() ); - DefaultLocator context = new DefaultLocator(); - context.put( LoggingManager.KEY, m_logManager ); - context.put( "urn:assembly:engine.bootstrap", "" + bootstrap ); - context.put( PoolManager.ROLE, getPoolManager() ); - context.makeReadOnly(); - engine.contextualize( context ); - engine.initialize(); - return engine; - } - catch( Exception e ) - { - ExceptionHelper.printException( "Engine setup failure.", e, this, true ); - assertTrue( false ); - throw e; - } - } - - private PoolManager getPoolManager() throws Exception - { - try - { - // - // Set up the ThreadManager that the CommandManager uses - // - - TPCThreadManager threadManager = new TPCThreadManager(); - threadManager.enableLogging( getLogger().getChildLogger( "threads" ) ); - Parameters params = new Parameters(); - params.setParameter( "threads-per-processor", "2" ); - params.setParameter( "sleep-time", "1000" ); - params.setParameter( "block-timeout", "250" ); - threadManager.parameterize( params ); - threadManager.initialize(); - - // - // Set up the CommandManager that the PoolManager uses. - // - - CommandManager commandManager = new CommandManager(); - threadManager.register( commandManager ); - - // - // Set up the PoolManager that the pooled lifecycle helper needs - // - - DefaultPoolManager poolManager = - new DefaultPoolManager( commandManager.getCommandSink() ); - return poolManager; - } - catch( Throwable e ) - { - final String error = - "Internal error during establishment of the default pool manager. Cause: "; - throw new Exception( error + e.toString() ); - } - } } 1.11 +0 -63 avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/FactoryTestCase.java Index: FactoryTestCase.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/FactoryTestCase.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- FactoryTestCase.java 18 Jun 2003 11:16:15 -0000 1.10 +++ FactoryTestCase.java 27 Jun 2003 22:52:12 -0000 1.11 @@ -136,67 +136,4 @@ assertTrue( false ); } } - - protected EngineClassLoader setUpEngine( boolean bootstrap ) throws Exception - { - try - { - EngineClassLoader engine = new EngineClassLoader(); - engine.enableLogging( getLogger() ); - DefaultLocator context = new DefaultLocator(); - context.put( LoggingManager.KEY, m_logManager ); - context.put( "urn:assembly:engine.bootstrap", "" + bootstrap ); - context.put( PoolManager.ROLE, getPoolManager() ); - context.makeReadOnly(); - engine.contextualize( context ); - engine.initialize(); - return engine; - } - catch( Exception e ) - { - ExceptionHelper.printException( "Engine setup failure.", e, this, true ); - assertTrue( false ); - throw e; - } - } - - private PoolManager getPoolManager() throws Exception - { - try - { - // - // Set up the ThreadManager that the CommandManager uses - // - - TPCThreadManager threadManager = new TPCThreadManager(); - threadManager.enableLogging( getLogger().getChildLogger( "threads" ) ); - Parameters params = new Parameters(); - params.setParameter( "threads-per-processor", "2" ); - params.setParameter( "sleep-time", "1000" ); - params.setParameter( "block-timeout", "250" ); - threadManager.parameterize( params ); - threadManager.initialize(); - - // - // Set up the CommandManager that the PoolManager uses. - // - - CommandManager commandManager = new CommandManager(); - threadManager.register( commandManager ); - - // - // Set up the PoolManager that the pooled lifecycle helper needs - // - - DefaultPoolManager poolManager = - new DefaultPoolManager( commandManager.getCommandSink() ); - return poolManager; - } - catch( Throwable e ) - { - final String error = - "Internal error during establishment of the default pool manager. Cause: "; - throw new Exception( error + e.toString() ); - } - } } 1.3 +8 -8 avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/repository/LocalRepositoryTestCase.java Index: LocalRepositoryTestCase.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/repository/LocalRepositoryTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LocalRepositoryTestCase.java 8 May 2003 22:28:29 -0000 1.2 +++ LocalRepositoryTestCase.java 27 Jun 2003 22:52:12 -0000 1.3 @@ -54,6 +54,8 @@ import org.apache.avalon.assembly.repository.Repository; import org.apache.avalon.assembly.repository.impl.FileRepository; +import org.apache.avalon.framework.logger.ConsoleLogger; +import org.apache.avalon.framework.context.DefaultContext; import junit.framework.TestCase; @@ -82,18 +84,16 @@ File target = new File( base, "target" ); File repository = new File( target, "test-repository" ); repository.mkdirs(); - m_repository = (FileRepository) FileRepository.newInstance( repository ); + m_repository = new FileRepository(); + DefaultContext context = new DefaultContext(); + context.put( FileRepository.BASE_KEY, repository ); + context.makeReadOnly(); + m_repository.enableLogging( new ConsoleLogger() ); + m_repository.contextualize( context ); } public void testInstall() throws Exception { - // - // this testcase is incomplete - objective is to be able to - // a packaged appication and populate the Merlin repository - // - a little more needs to be done to handle the unpacking side - // of things - until this text is disabled. - // - //m_repository.install( "james" ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org