[MRM-118] proxy config is not a component

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412658 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-06-08 04:59:55 +00:00
parent 1ef50fd5bd
commit bda451364b
5 changed files with 33 additions and 46 deletions

View File

@ -52,7 +52,7 @@ import java.util.Map;
* @author Edwin Punzalan
* @plexus.component role="org.apache.maven.repository.proxy.ProxyManager"
* @todo too much of wagon manager is reproduced here because checksums need to be downloaded separately - is that necessary?
* @todo this isn't reusing the parts of wagon manager than handle snapshots [!]
* @todo this isn't reusing the parts of artifact resolver that handles snapshots - should this be more artifact based than file-based?
* @todo currently, cache must be in the same layout as the request, which prohibits any mapping
*/
public class DefaultProxyManager
@ -69,21 +69,15 @@ public class DefaultProxyManager
*/
private ArtifactRepositoryFactory repositoryFactory;
/**
* @plexus.requirement
*/
private ProxyConfiguration config;
/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private Map repositoryLayoutMap;
/**
* A map
*/
private Map failuresCache = new HashMap();
private ProxyConfiguration config;
private static final int MS_PER_SEC = 1000;
/**
@ -102,11 +96,6 @@ public class DefaultProxyManager
this.config = config;
}
public ProxyConfiguration getConfiguration()
{
return config;
}
/**
* @see org.apache.maven.repository.proxy.ProxyManager#get(String)
*/
@ -120,15 +109,15 @@ public class DefaultProxyManager
File cachedFile = new File( cachePath, path );
if ( !cachedFile.exists() )
{
cachedFile = getRemoteFile( path );
cachedFile = getAlways( path );
}
return cachedFile;
}
/**
* @see org.apache.maven.repository.proxy.ProxyManager#getRemoteFile(String)
* @see org.apache.maven.repository.proxy.ProxyManager#getAlways(String)
*/
public File getRemoteFile( String path )
public File getAlways( String path )
throws ProxyException, ResourceDoesNotExistException
{
checkConfiguration();
@ -393,7 +382,7 @@ public class DefaultProxyManager
{
wagon = wagonManager.getWagon( repository.getProtocol() );
//@todo configure wagonManager [!]
//@todo configure wagon (ssh settings, etc)
if ( useChecksum )
{

View File

@ -25,7 +25,6 @@ import java.io.File;
* Class used to bridge the servlet to the repository proxy implementation.
*
* @author Edwin Punzalan
* @todo the names get() and getRemoteFile() are confusing [!]
*/
public interface ProxyManager
{
@ -53,7 +52,7 @@ public interface ProxyManager
* @throws ResourceDoesNotExistException when the requested object can't be found in any of the
* configured repositories
*/
File getRemoteFile( String path )
File getAlways( String path )
throws ProxyException, ResourceDoesNotExistException;
/**
@ -62,11 +61,4 @@ public interface ProxyManager
* @param config the ProxyConfiguration to set the behavior of the proxy
*/
void setConfiguration( ProxyConfiguration config );
/**
* Used to retrieve the configuration describing the behavior of the proxy
*
* @return the ProxyConfiguration of this proxy
*/
ProxyConfiguration getConfiguration();
}

View File

@ -34,6 +34,8 @@ public class DefaultProxyManagerTest
{
private ProxyManager proxy;
private ProxyConfiguration configuration;
protected void setUp()
throws Exception
{
@ -41,7 +43,8 @@ public class DefaultProxyManagerTest
proxy = (ProxyManager) container.lookup( ProxyManager.ROLE );
proxy.setConfiguration( getTestConfiguration() );
configuration = getTestConfiguration();
proxy.setConfiguration( configuration );
}
public void testExceptions()
@ -70,7 +73,7 @@ public class DefaultProxyManagerTest
File file = proxy.get( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
//test cache
proxy.get( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar" );
@ -89,11 +92,11 @@ public class DefaultProxyManagerTest
public void testArtifactChecksum()
throws Exception
{
//force the downlod from the remote repository, use getRemoteFile()
File file = proxy.getRemoteFile( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar.md5" );
//force the downlod from the remote repository, use getAlways()
File file = proxy.getAlways( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar.md5" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithNoChecksum()
@ -102,7 +105,7 @@ public class DefaultProxyManagerTest
File file = proxy.get( "/not-standard/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithMD5Checksum()
@ -111,7 +114,7 @@ public class DefaultProxyManagerTest
File file = proxy.get( "/checksumed-md5/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithSHA1Checksum()
@ -120,7 +123,7 @@ public class DefaultProxyManagerTest
File file = proxy.get( "/checksumed-sha1/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
protected void tearDown()
@ -134,7 +137,7 @@ public class DefaultProxyManagerTest
private ProxyConfiguration getTestConfiguration()
throws ComponentLookupException
{
ProxyConfiguration config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );
ProxyConfiguration config = new ProxyConfiguration();
config.setRepositoryCachePath( "target/proxy-cache" );

View File

@ -34,6 +34,8 @@ public class LegacyProxyManagerTest
{
private ProxyManager proxy;
private ProxyConfiguration configuration;
protected void setUp()
throws Exception
{
@ -41,7 +43,8 @@ public class LegacyProxyManagerTest
proxy = (ProxyManager) container.lookup( ProxyManager.ROLE );
proxy.setConfiguration( getTestConfiguration() );
configuration = getTestConfiguration();
proxy.setConfiguration( configuration );
}
public void testExceptions()
@ -70,7 +73,7 @@ public class LegacyProxyManagerTest
File file = proxy.get( "/commons-logging/jars/commons-logging-1.0.jar" );
assertTrue( "File must be downloaded: " + file.getAbsolutePath(), file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
//test cache
proxy.get( "/commons-logging/jars/commons-logging-1.0.jar" );
@ -89,11 +92,11 @@ public class LegacyProxyManagerTest
public void testArtifactChecksum()
throws Exception
{
//force the downlod from the remote repository, use getRemoteFile()
File file = proxy.getRemoteFile( "/commons-logging/jars/commons-logging-1.0.jar.md5" );
//force the downlod from the remote repository, use getAlways()
File file = proxy.getAlways( "/commons-logging/jars/commons-logging-1.0.jar.md5" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithNoChecksum()
@ -102,7 +105,7 @@ public class LegacyProxyManagerTest
File file = proxy.get( "/not-standard/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithMD5Checksum()
@ -111,7 +114,7 @@ public class LegacyProxyManagerTest
File file = proxy.get( "/checksumed-md5/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithSHA1Checksum()
@ -120,7 +123,7 @@ public class LegacyProxyManagerTest
File file = proxy.get( "/checksumed-sha1/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
protected void tearDown()
@ -134,7 +137,7 @@ public class LegacyProxyManagerTest
private ProxyConfiguration getTestConfiguration()
throws ComponentLookupException
{
ProxyConfiguration config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );
ProxyConfiguration config = new ProxyConfiguration();
config.setRepositoryCachePath( getTestFile( "target/m1-proxy-cache" ).getAbsolutePath() );

View File

@ -41,7 +41,7 @@ public class ProxyConfigurationTest
{
super.setUp();
config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );
config = new ProxyConfiguration();
}
public void testRepositoryCache()