You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/08/30 03:22:24 UTC
svn commit: r571008 [1/4] - in /maven/archiva/trunk/archiva-base:
archiva-proxy/ archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/
archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/
archiva-proxy/src/test/repositories/ archiva-proxy/...
Author: joakime
Date: Wed Aug 29 18:22:19 2007
New Revision: 571008
URL: http://svn.apache.org/viewvc?rev=571008&view=rev
Log:
[MRM-463] Metadata merging doesn't work.
Bug fixes to MetadataTool.
New Proxying features.
Proxying Unit Testing Updates.
Added:
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/create-managed-to-proxy-map.sh (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed-to-proxy-map.txt (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-metadata/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-metadata/1.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-metadata/1.0/get-default-metadata-1.0.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-metadata/1.0/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-not-on-remotes/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-not-on-remotes/1.0-beta-2/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-not-on-remotes/1.0-beta-2/get-not-on-remotes-1.0-beta-2.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-not-on-remotes/1.0-beta-2/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-not-on-remotes/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/1.0.22/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/1.0.22/get-on-local-on-remote-1.0.22.pom
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/1.0.22/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/1.0.8/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/1.0.8/get-on-local-on-remote-1.0.8.pom
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-local-on-remote/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-multiple-repos/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-multiple-repos/1.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-multiple-repos/1.0/get-on-multiple-repos-1.0.pom
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-multiple-repos/1.0/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-on-multiple-repos/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-present-metadata-snapshot/1.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/1.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/1.0/get-project-metadata-1.0.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/1.1/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/1.1/get-project-metadata-1.1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/2.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/2.0/get-project-metadata-2.0.pom
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-project-metadata/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-release-metadata/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-release-metadata/2.2/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-release-metadata/2.2/get-release-metadata-2.2.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-release-metadata/2.2/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-on-local-not-remote/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-on-local-not-remote/2.0-alpha-2-SNAPSHOT/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-on-local-not-remote/2.0-alpha-2-SNAPSHOT/get-snapshot-on-local-not-remote-2.0-alpha-2-20070821.123456-1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-on-local-not-remote/2.0-alpha-2-SNAPSHOT/get-snapshot-on-local-not-remote-2.0-alpha-2-20070821.220304-2.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-on-local-not-remote/2.0-alpha-2-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-popular/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070821.102030-1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070821.185701-2.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070822.021008-3.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-default-layout/1.0/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-default-layout/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-found-in-proxy/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-found-in-proxy/1.0.5/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-found-in-proxy/1.0.5/get-found-in-proxy-1.0.5-javadoc.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-found-in-proxy/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-local-on-remote/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-local-on-remote/1.0.22/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-local-on-remote/1.0.22/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-local-on-remote/2.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-local-on-remote/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-multiple-repos/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-multiple-repos/1.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-multiple-repos/1.0/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-multiple-repos/2.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-on-multiple-repos/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-present-metadata-snapshot/1.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-snapshot-popular/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070819.040004-1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070822.145534-9.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-20061222.034118-1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-20061227.112101-2.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/1.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/1.0.1/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/1.0.1/get-default-layout-1.0.1.pom
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/1.0/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-default-layout/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-on-multiple-repos/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-on-multiple-repos/1.0/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-on-multiple-repos/1.0.1/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-on-multiple-repos/1.0/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-on-multiple-repos/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-snapshot-popular/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070821.102030-1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070823.111741-5.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/get-snapshot-popular-2.0-20070823.212711-6.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-snapshot-popular/2.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-20061222.034118-1.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-20070101.000103-2.jar (with props)
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/maven-metadata.xml (with props)
maven/archiva/trunk/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_metadata_b/2.0.1/
maven/archiva/trunk/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/missing_metadata_b/2.0.1/missing_metadata_b-2.0.1.jar (with props)
Modified:
maven/archiva/trunk/archiva-base/archiva-proxy/pom.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/log4j.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ChecksumTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/SnapshotTransferTest.xml
maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java
maven/archiva/trunk/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java
maven/archiva/trunk/archiva-base/archiva-repository-layer/src/test/repositories/metadata-repository/org/apache/archiva/metadata/tests/snap_shots_a/1.0-alpha-11-SNAPSHOT/maven-metadata-snapshots.codehaus.org.xml
Modified: maven/archiva/trunk/archiva-base/archiva-proxy/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-proxy/pom.xml?rev=571008&r1=571007&r2=571008&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-proxy/pom.xml (original)
+++ maven/archiva/trunk/archiva-base/archiva-proxy/pom.xml Wed Aug 29 18:22:19 2007
@@ -72,6 +72,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
@@ -100,7 +105,6 @@
<exclude>**/*TestCase.java</exclude>
<exclude>**/*Tests.java</exclude>
<exclude>**/*TestSuite.java</exclude>
- <exclude>**/MetadataTransfer*</exclude>
<exclude>**/RelocateTransfer*</exclude>
</excludes>
</configuration>
Modified: maven/archiva/trunk/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java?rev=571008&r1=571007&r2=571008&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java Wed Aug 29 18:22:19 2007
@@ -35,6 +35,8 @@
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.metadata.MetadataTools;
+import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.Wagon;
@@ -89,6 +91,11 @@
private BidirectionalRepositoryLayoutFactory layoutFactory;
/**
+ * @plexus.requirement
+ */
+ private MetadataTools metadataTools;
+
+ /**
* @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
*/
private Map preDownloadPolicies;
@@ -107,26 +114,21 @@
private Map networkProxyMap = new HashMap();
+ /**
+ * Fetch an artifact from a remote repository.
+ *
+ * @param repository the managed repository to utilize for the request.
+ * @param artifact the artifact reference to fetch.
+ * @return the local file in the managed repository that was fetched, or null if the artifact was not (or
+ * could not be) fetched.
+ * @throws ProxyException if there was a problem fetching the artifact.
+ */
public File fetchFromProxies( ArchivaRepository repository, ArtifactReference artifact )
throws ProxyException
{
- if ( !repository.isManaged() )
- {
- throw new ProxyException( "Can only proxy managed repositories." );
- }
+ assertProxyCapable( repository );
- File localFile;
- try
- {
- BidirectionalRepositoryLayout sourceLayout = layoutFactory.getLayout( repository.getLayoutType() );
- String sourcePath = sourceLayout.toPath( artifact );
- localFile = new File( repository.getUrl().getPath(), sourcePath );
- }
- catch ( LayoutException e )
- {
- throw new ProxyException( "Unable to proxy due to bad source repository layout definition: "
- + e.getMessage(), e );
- }
+ File localFile = toLocalFile( repository, artifact );
Properties requestProperties = new Properties();
requestProperties.setProperty( "version", artifact.getVersion() );
@@ -136,58 +138,35 @@
while ( it.hasNext() )
{
ProxyConnector connector = (ProxyConnector) it.next();
- getLogger().debug( "Attempting connector: " + connector );
ArchivaRepository targetRepository = connector.getTargetRepository();
- try
- {
- BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() );
- String targetPath = targetLayout.toPath( artifact );
+ String targetPath = getLayout( targetRepository ).toPath( artifact );
- getLogger().debug(
- "Using target repository: " + targetRepository.getId() + " - layout: "
- + targetRepository.getLayoutType() + " - targetPath: " + targetPath );
+ File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile, requestProperties );
- File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile,
- requestProperties );
-
- if ( fileExists( downloadedFile ) )
- {
- getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() );
- return downloadedFile;
- }
- }
- catch ( LayoutException e )
+ if ( fileExists( downloadedFile ) )
{
- getLogger().error( "Unable to proxy due to bad layout definition: " + e.getMessage(), e );
- return null;
+ getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() );
+ return downloadedFile;
}
}
return null;
}
+ /**
+ * Fetch, from the proxies, a metadata.xml file for the groupId:artifactId:version metadata contents.
+ *
+ * @return the (local) metadata file that was fetched/merged/updated, or null if no metadata file exists.
+ */
public File fetchFromProxies( ArchivaRepository repository, VersionedReference metadata )
throws ProxyException
{
- if ( !repository.isManaged() )
- {
- throw new ProxyException( "Can only proxy managed repositories." );
- }
+ assertProxyCapable( repository );
- File localFile;
- try
- {
- BidirectionalRepositoryLayout sourceLayout = layoutFactory.getLayout( repository.getLayoutType() );
- String sourcePath = sourceLayout.toPath( metadata );
- localFile = new File( repository.getUrl().getPath(), sourcePath );
- }
- catch ( LayoutException e )
- {
- throw new ProxyException( "Unable to proxy due to bad source repository layout definition: "
- + e.getMessage(), e );
- }
+ File localFile = toLocalFile( repository, metadata );
Properties requestProperties = new Properties();
+ boolean hasFetched = false;
List connectors = getProxyConnectors( repository );
Iterator it = connectors.iterator();
@@ -195,52 +174,65 @@
{
ProxyConnector connector = (ProxyConnector) it.next();
ArchivaRepository targetRepository = connector.getTargetRepository();
- try
- {
- BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() );
- String targetPath = targetLayout.toPath( metadata );
+ String targetPath = getLayout( targetRepository ).toPath( metadata );
+
+ File localRepoFile = toLocalRepoFile( repository, targetRepository, targetPath );
+ File downloadedFile = transferFile( connector, targetRepository, targetPath, localRepoFile, requestProperties );
- File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile,
- requestProperties );
+ if ( fileExists( downloadedFile ) )
+ {
+ getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() );
+ hasFetched = true;
+ }
+ }
- if ( fileExists( downloadedFile ) )
- {
- getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() );
- return downloadedFile;
- }
+ if ( hasFetched || fileExists( localFile ) )
+ {
+ try
+ {
+ metadataTools.updateMetadata( repository, metadata );
}
catch ( LayoutException e )
{
- getLogger().error( "Unable to proxy due to bad layout definition: " + e.getMessage(), e );
- return null;
+ getLogger().warn( "Unable to update metadata " + localFile.getAbsolutePath() + ": " + e.getMessage() );
+ // TODO: add into repository report?
}
+ catch ( RepositoryMetadataException e )
+ {
+ getLogger()
+ .warn( "Unable to update metadata " + localFile.getAbsolutePath() + ": " + e.getMessage(), e );
+ // TODO: add into repository report?
+ }
+ catch ( IOException e )
+ {
+ getLogger()
+ .warn( "Unable to update metadata " + localFile.getAbsolutePath() + ": " + e.getMessage(), e );
+ // TODO: add into repository report?
+ }
+ }
+
+ if ( fileExists( localFile ) )
+ {
+ return localFile;
}
return null;
}
+ /**
+ * Fetch from the proxies a metadata.xml file for the groupId:artifactId metadata contents.
+ *
+ * @return the (local) metadata file that was fetched/merged/updated, or null if no metadata file exists.
+ */
public File fetchFromProxies( ArchivaRepository repository, ProjectReference metadata )
throws ProxyException
{
- if ( !repository.isManaged() )
- {
- throw new ProxyException( "Can only proxy managed repositories." );
- }
+ assertProxyCapable( repository );
- File localFile;
- try
- {
- BidirectionalRepositoryLayout sourceLayout = layoutFactory.getLayout( repository.getLayoutType() );
- String sourcePath = sourceLayout.toPath( metadata );
- localFile = new File( repository.getUrl().getPath(), sourcePath );
- }
- catch ( LayoutException e )
- {
- throw new ProxyException( "Unable to proxy due to bad source repository layout definition: "
- + e.getMessage(), e );
- }
+ File localFile = toLocalFile( repository, metadata );
Properties requestProperties = new Properties();
+ boolean hasFetched = false;
List connectors = getProxyConnectors( repository );
Iterator it = connectors.iterator();
@@ -248,30 +240,135 @@
{
ProxyConnector connector = (ProxyConnector) it.next();
ArchivaRepository targetRepository = connector.getTargetRepository();
- try
- {
- BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() );
- String targetPath = targetLayout.toPath( metadata );
+ String targetPath = getLayout( targetRepository ).toPath( metadata );
- File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile,
- requestProperties );
+ File localRepoFile = toLocalRepoFile( repository, targetRepository, targetPath );
+ File downloadedFile = transferFile( connector, targetRepository, targetPath, localRepoFile, requestProperties );
- if ( fileExists( downloadedFile ) )
- {
- getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() );
- return downloadedFile;
- }
+ if ( fileExists( downloadedFile ) )
+ {
+ getLogger().info( "Successfully transfered: " + downloadedFile.getAbsolutePath() );
+ hasFetched = true;
+ }
+ }
+
+ if ( hasFetched || fileExists( localFile ) )
+ {
+ try
+ {
+ metadataTools.updateMetadata( repository, metadata );
}
catch ( LayoutException e )
{
- getLogger().error( "Unable to proxy due to bad layout definition: " + e.getMessage(), e );
- return null;
+ getLogger().warn( "Unable to update metadata " + localFile.getAbsolutePath() + ": " + e.getMessage() );
+ // TODO: add into repository report?
+ }
+ catch ( RepositoryMetadataException e )
+ {
+ getLogger()
+ .warn( "Unable to update metadata " + localFile.getAbsolutePath() + ": " + e.getMessage(), e );
+ // TODO: add into repository report?
}
+ catch ( IOException e )
+ {
+ getLogger()
+ .warn( "Unable to update metadata " + localFile.getAbsolutePath() + ": " + e.getMessage(), e );
+ // TODO: add into repository report?
+ }
+ }
+
+ if ( fileExists( localFile ) )
+ {
+ return localFile;
}
return null;
}
+ private File toLocalRepoFile( ArchivaRepository repository, ArchivaRepository targetRepository, String targetPath )
+ {
+ String repoPath = metadataTools.getRepositorySpecificName( targetRepository, targetPath );
+ return new File( repository.getUrl().getPath(), repoPath );
+ }
+
+ /**
+ * Test if the provided ArchivaRepository has any proxies configured for it.
+ */
+ public boolean hasProxies( ArchivaRepository repository )
+ {
+ synchronized ( this.proxyConnectorMap )
+ {
+ return this.proxyConnectorMap.containsKey( repository.getId() );
+ }
+ }
+
+ /**
+ * Test the repository to see if it is proxy capable.
+ *
+ * @param repository the repository to test.
+ * @throws ProxyException if the repository is not proxy capable.
+ */
+ private void assertProxyCapable( ArchivaRepository repository )
+ throws ProxyException
+ {
+ if ( !repository.isManaged() )
+ {
+ throw new ProxyException( "Can only proxy managed repositories." );
+ }
+ }
+
+ private File toLocalFile( ArchivaRepository repository, ArtifactReference artifact )
+ throws ProxyException
+ {
+ BidirectionalRepositoryLayout sourceLayout = getLayout( repository );
+ String sourcePath = sourceLayout.toPath( artifact );
+ return new File( repository.getUrl().getPath(), sourcePath );
+ }
+
+ private File toLocalFile( ArchivaRepository repository, ProjectReference metadata )
+ throws ProxyException
+ {
+ BidirectionalRepositoryLayout sourceLayout = getLayout( repository );
+ String sourcePath = sourceLayout.toPath( metadata );
+ return new File( repository.getUrl().getPath(), sourcePath );
+ }
+
+ private File toLocalFile( ArchivaRepository repository, VersionedReference metadata )
+ throws ProxyException
+ {
+ BidirectionalRepositoryLayout sourceLayout = getLayout( repository );
+ String sourcePath = sourceLayout.toPath( metadata );
+ return new File( repository.getUrl().getPath(), sourcePath );
+ }
+
+ /**
+ * Get the layout for the repository.
+ *
+ * @param repository the repository to get the layout from.
+ * @return the layout
+ * @throws ProxyException if there was a problem obtaining the layout from the repository (usually due to a bad
+ * configuration of the repository)
+ */
+ private BidirectionalRepositoryLayout getLayout( ArchivaRepository repository )
+ throws ProxyException
+ {
+ try
+ {
+ return layoutFactory.getLayout( repository.getLayoutType() );
+ }
+ catch ( LayoutException e )
+ {
+ throw new ProxyException( "Unable to proxy due to bad repository layout definition [" + repository.getId()
+ + "] had a layout defined as [" + repository.getLayoutType() + "] : " + e.getMessage(), e );
+ }
+ }
+
+ /**
+ * Simple method to test if the file exists on the local disk.
+ *
+ * @param file the file to test. (may be null)
+ * @return true if file exists. false if the file param is null, doesn't exist, or is not of type File.
+ */
private boolean fileExists( File file )
{
if ( file == null )
@@ -295,69 +392,69 @@
/**
* Perform the transfer of the file.
*
- * @param connector
- * @param targetRepository
- * @param targetPath
- * @param localFile
- * @param requestProperties
- * @return
- * @throws ProxyException
+ * @param connector the connector configuration to use.
+ * @param remoteRepository the remote repository get the resource from.
+ * @param remotePath the path in the remote repository to the resource to get.
+ * @param localFile the local file to place the downloaded resource into
+ * @param requestProperties the request properties to utilize for policy handling.
+ * @return the local file that was downloaded, or null if not downloaded.
+ * @throws ProxyException if transfer was unsuccessful.
*/
- private File transferFile( ProxyConnector connector, ArchivaRepository targetRepository, String targetPath,
+ private File transferFile( ProxyConnector connector, ArchivaRepository remoteRepository, String remotePath,
File localFile, Properties requestProperties )
throws ProxyException
{
- String url = targetRepository.getUrl().toString() + targetPath;
+ String url = remoteRepository.getUrl().toString() + remotePath;
requestProperties.setProperty( "url", url );
- // Handle pre-download policy
- if ( !applyPolicies( connector.getPolicies(), this.preDownloadPolicies, requestProperties, localFile ) )
- {
- getLogger().info( "Failed pre-download policies - " + localFile.getAbsolutePath() );
-
- if ( fileExists( localFile ) )
- {
- return localFile;
- }
-
- return null;
- }
-
// Is a whitelist defined?
if ( !isEmpty( connector.getWhitelist() ) )
{
// Path must belong to whitelist.
- if ( !matchesPattern( targetPath, connector.getWhitelist() ) )
+ if ( !matchesPattern( remotePath, connector.getWhitelist() ) )
{
- getLogger().debug( "Path [" + targetPath + "] is not part of defined whitelist (skipping transfer)." );
+ getLogger().debug( "Path [" + remotePath + "] is not part of defined whitelist (skipping transfer)." );
return null;
}
}
// Is target path part of blacklist?
- if ( matchesPattern( targetPath, connector.getBlacklist() ) )
+ if ( matchesPattern( remotePath, connector.getBlacklist() ) )
+ {
+ getLogger().debug( "Path [" + remotePath + "] is part of blacklist (skipping transfer)." );
+ return null;
+ }
+
+ // Handle pre-download policy
+ if ( !applyPolicies( this.preDownloadPolicies, connector.getPolicies(), requestProperties, localFile ) )
{
- getLogger().debug( "Path [" + targetPath + "] is part of blacklist (skipping transfer)." );
+ getLogger().info( "Failed pre-download policies - " + localFile.getAbsolutePath() );
+
+ if ( fileExists( localFile ) )
+ {
+ return localFile;
+ }
+
return null;
}
Wagon wagon = null;
try
{
- String protocol = targetRepository.getUrl().getProtocol();
+ String protocol = remoteRepository.getUrl().getProtocol();
wagon = (Wagon) wagons.get( protocol );
if ( wagon == null )
{
throw new ProxyException( "Unsupported target repository protocol: " + protocol );
}
- boolean connected = connectToRepository( connector, wagon, targetRepository );
+ boolean connected = connectToRepository( connector, wagon, remoteRepository );
if ( connected )
{
- localFile = transferSimpleFile( wagon, targetRepository, targetPath, localFile );
+ localFile = transferSimpleFile( wagon, remoteRepository, remotePath, localFile );
- transferChecksum( wagon, targetRepository, targetPath, localFile, ".sha1" );
- transferChecksum( wagon, targetRepository, targetPath, localFile, ".md5" );
+ transferChecksum( wagon, remoteRepository, remotePath, localFile, ".sha1" );
+ transferChecksum( wagon, remoteRepository, remotePath, localFile, ".md5" );
}
}
catch ( ResourceDoesNotExistException e )
@@ -386,7 +483,7 @@
}
// Handle post-download policies.
- if ( !applyPolicies( connector.getPolicies(), this.postDownloadPolicies, requestProperties, localFile ) )
+ if ( !applyPolicies( this.postDownloadPolicies, connector.getPolicies(), requestProperties, localFile ) )
{
getLogger().info( "Failed post-download policies - " + localFile.getAbsolutePath() );
@@ -402,11 +499,23 @@
return localFile;
}
- private void transferChecksum( Wagon wagon, ArchivaRepository targetRepository, String targetPath, File localFile,
+ /**
+ * Quietly transfer the checksum file from the remote repository to the local file.
+ *
+ * NOTE: This will not throw a WagonException if the checksum is unable to be downloaded.
+ *
+ * @param wagon the wagon instance (should already be connected) to use.
+ * @param remoteRepository the remote repository to transfer from.
+ * @param remotePath the remote path to the resource to get.
+ * @param localFile the local file that should contain the downloaded contents
+ * @param type the type of checksum to transfer (example: ".md5" or ".sha1")
+ * @throws ProxyException if copying the downloaded file into place did not succeed.
+ */
+ private void transferChecksum( Wagon wagon, ArchivaRepository remoteRepository, String remotePath, File localFile,
String type )
throws ProxyException
{
- String url = targetRepository.getUrl().toString() + targetPath;
+ String url = remoteRepository.getUrl().toString() + remotePath;
// Transfer checksum does not use the policy.
if ( urlFailureCache.hasFailedBefore( url + type ) )
@@ -417,7 +526,7 @@
try
{
File hashFile = new File( localFile.getAbsolutePath() + type );
- transferSimpleFile( wagon, targetRepository, targetPath + type, hashFile );
+ transferSimpleFile( wagon, remoteRepository, remotePath + type, hashFile );
getLogger().debug( "Checksum" + type + " Downloaded: " + hashFile );
}
catch ( ResourceDoesNotExistException e )
@@ -431,9 +540,22 @@
}
}
- private File transferSimpleFile( Wagon wagon, ArchivaRepository targetRepository, String targetPath, File localFile )
+ /**
+ * Perform the transfer of the remote file to the local file specified.
+ *
+ * @param wagon the wagon instance to use.
+ * @param remoteRepository the remote repository to use
+ * @param remotePath the remote path to attempt to get
+ * @param localFile the local file to save to
+ * @return The local file that was transfered.
+ * @throws ProxyException if there was a problem moving the downloaded file into place.
+ * @throws WagonException if there was a problem tranfering the file.
+ */
+ private File transferSimpleFile( Wagon wagon, ArchivaRepository remoteRepository, String remotePath, File localFile )
throws ProxyException, WagonException
{
+ assert ( remotePath != null );
+
// Transfer the file.
File temp = null;
@@ -445,8 +567,8 @@
if ( localFile.exists() )
{
- getLogger().debug( "Retrieving " + targetPath + " from " + targetRepository.getName() );
- wagon.get( targetPath, temp );
+ getLogger().debug( "Retrieving " + remotePath + " from " + remoteRepository.getName() );
+ wagon.get( remotePath, temp );
success = true;
if ( temp.exists() )
@@ -459,13 +581,13 @@
}
else
{
- getLogger().debug( "Retrieving " + targetPath + " from " + targetRepository.getName() + " if updated" );
- success = wagon.getIfNewer( targetPath, temp, localFile.lastModified() );
+ getLogger().debug( "Retrieving " + remotePath + " from " + remoteRepository.getName() + " if updated" );
+ success = wagon.getIfNewer( remotePath, temp, localFile.lastModified() );
if ( !success )
{
- getLogger().debug(
- "Not downloaded, as local file is newer than remote side: "
- + localFile.getAbsolutePath() );
+ getLogger().info(
+ "Not downloaded, as local file is newer than remote side: "
+ + localFile.getAbsolutePath() );
}
else if ( temp.exists() )
{
@@ -495,21 +617,30 @@
}
}
- private boolean applyPolicies( Map policySettings, Map downloadPolicies, Properties request, File localFile )
+ /**
+ * Apply the policies.
+ * @param policies the map of policies to execute. (Map of String policy keys, to {@link DownloadPolicy} objects)
+ * @param settings the map of settings for the policies to execute. (Map of String policy keys, to String policy setting)
+ * @param request the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)})
+ * @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)})
+ *
+ * @return true if all of the policies passed, false if a policy failed.
+ */
+ private boolean applyPolicies( Map policies, Map settings, Properties request, File localFile )
{
- Iterator it = downloadPolicies.entrySet().iterator();
+ Iterator it = policies.entrySet().iterator();
while ( it.hasNext() )
{
Map.Entry entry = (Entry) it.next();
String key = (String) entry.getKey();
DownloadPolicy policy = (DownloadPolicy) entry.getValue();
String defaultSetting = policy.getDefaultOption();
- String setting = StringUtils.defaultString( (String) policySettings.get( key ), defaultSetting );
+ String setting = StringUtils.defaultString( (String) settings.get( key ), defaultSetting );
getLogger().debug( "Applying [" + key + "] policy with [" + setting + "]" );
if ( !policy.applyPolicy( setting, request, localFile ) )
{
- getLogger().debug( "Didn't pass the [" + key + "] policy." );
+ getLogger().info( "Didn't pass the [" + key + "] policy." );
return false;
}
}
@@ -551,7 +682,15 @@
}
}
- private boolean connectToRepository( ProxyConnector connector, Wagon wagon, ArchivaRepository targetRepository )
+ /**
+ * Using wagon, connect to the remote repository.
+ *
+ * @param connector the connector configuration to utilize (for obtaining network proxy configuration from)
+ * @param wagon the wagon instance to establish the connection on.
+ * @param remoteRepository the remote repository to connect to.
+ * @return true if the connection was successful. false if not connected.
+ */
+ private boolean connectToRepository( ProxyConnector connector, Wagon wagon, ArchivaRepository remoteRepository )
{
boolean connected = false;
@@ -563,7 +702,7 @@
try
{
- Repository wagonRepository = new Repository( targetRepository.getId(), targetRepository.getUrl().toString() );
+ Repository wagonRepository = new Repository( remoteRepository.getId(), remoteRepository.getUrl().toString() );
if ( networkProxy != null )
{
wagon.connect( wagonRepository, networkProxy );
@@ -576,16 +715,25 @@
}
catch ( ConnectionException e )
{
- getLogger().info( "Could not connect to " + targetRepository.getName() + ": " + e.getMessage() );
+ getLogger().info( "Could not connect to " + remoteRepository.getName() + ": " + e.getMessage() );
+ connected = false;
}
catch ( AuthenticationException e )
{
- getLogger().info( "Could not connect to " + targetRepository.getName() + ": " + e.getMessage() );
+ getLogger().info( "Could not connect to " + remoteRepository.getName() + ": " + e.getMessage() );
+ connected = false;
}
return connected;
}
+ /**
+ * Tests whitelist and blacklist patterns against path.
+ *
+ * @param path the path to test.
+ * @param patterns the list of patterns to check.
+ * @return true if the path matches at least 1 pattern in the provided patterns list.
+ */
private boolean matchesPattern( String path, List patterns )
{
if ( isEmpty( patterns ) )
@@ -606,6 +754,9 @@
return false;
}
+ /**
+ * TODO: Ensure that list is correctly ordered based on configuration. See MRM-477
+ */
public List getProxyConnectors( ArchivaRepository repository )
{
synchronized ( this.proxyConnectorMap )
@@ -616,14 +767,6 @@
return Collections.EMPTY_LIST;
}
return ret;
- }
- }
-
- public boolean hasProxies( ArchivaRepository repository )
- {
- synchronized ( this.proxyConnectorMap )
- {
- return this.proxyConnectorMap.containsKey( repository.getId() );
}
}
Modified: maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java?rev=571008&r1=571007&r2=571008&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java Wed Aug 29 18:22:19 2007
@@ -28,6 +28,7 @@
import org.apache.maven.archiva.model.ArchivaRepository;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.ProjectReference;
+import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.policies.urlcache.UrlFailureCache;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
@@ -82,7 +83,7 @@
protected static final String REPOPATH_DEFAULT_MANAGED = "src/test/repositories/managed";
- protected static final String REPOPATH_DEFAULT_MANAGED_TARGET = "target/test-repository/managed";
+ // protected static final String REPOPATH_DEFAULT_MANAGED_TARGET = "target/test-repository/managed";
protected static final String REPOPATH_LEGACY_MANAGED = "src/test/repositories/legacy-managed";
@@ -255,7 +256,7 @@
"Test Managed (Legacy) Repository", "legacy" );
}
- protected ProjectReference createMetadataReference( String layoutType, String path )
+ protected ProjectReference createProjectReference( String layoutType, String path )
throws Exception
{
BidirectionalRepositoryLayout layout = layoutFactory.getLayout( layoutType );
@@ -263,6 +264,14 @@
return metadata;
}
+ protected VersionedReference createVersionedReference( String layoutType, String path )
+ throws Exception
+ {
+ BidirectionalRepositoryLayout layout = layoutFactory.getLayout( layoutType );
+ VersionedReference metadata = layout.toVersionedReference( path );
+ return metadata;
+ }
+
protected ArchivaRepository createProxiedLegacyRepository()
{
return createRepository( "src/test/repositories/legacy-proxied", "testProxiedLegacyRepo",
@@ -402,13 +411,11 @@
RepositoryConfiguration repoConfig;
// Setup source repository (using default layout)
- File repoLocation = getTestFile( REPOPATH_DEFAULT_MANAGED_TARGET );
- // faster only to delete this one before copying, the others are done case by case
- FileUtils.deleteDirectory( new File( repoLocation, "org/apache/maven/test/get-merged-metadata" ) );
- copyDirectoryStructure( getTestFile( REPOPATH_DEFAULT_MANAGED ), repoLocation );
+ String repoPath = "target/test-repository/managed/" + getName();
+ File repoLocation = getTestFile( repoPath );
- managedDefaultRepository = createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository",
- REPOPATH_DEFAULT_MANAGED_TARGET, "default" );
+ managedDefaultRepository = createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath,
+ "default" );
managedDefaultDir = new File( managedDefaultRepository.getUrl().getPath() );
@@ -449,6 +456,58 @@
delegate.setDelegate( wagonMock );
System.out.println( "\n.\\ " + getName() + "() \\._________________________________________\n" );
+ }
+
+ /**
+ * Copy the specified resource directory from the src/test/repository/managed/ to
+ * the testable directory under target/test-repository/managed/${testName}/
+ *
+ * @param resourceDir
+ * @throws IOException
+ */
+ protected void setupTestableManagedRepository( String resourcePath )
+ throws IOException
+ {
+ String resourceDir = resourcePath;
+
+ if( !resourcePath.endsWith( "/" ) )
+ {
+ int idx = resourcePath.lastIndexOf( '/' );
+ resourceDir = resourcePath.substring( 0, idx );
+ }
+
+ File sourceRepoDir = new File( REPOPATH_DEFAULT_MANAGED );
+ File sourceDir = new File( sourceRepoDir, resourceDir );
+
+ File destRepoDir = managedDefaultDir;
+ File destDir = new File( destRepoDir, resourceDir );
+
+ // Cleanout destination dirs.
+ if ( destDir.exists() )
+ {
+ FileUtils.deleteDirectory( destDir );
+ }
+
+ // Test the source dir.
+ if ( !sourceDir.exists() )
+ {
+ // This is just a warning.
+ System.err.println( "Skipping setup of testable managed repsoitory, source dir does not exist: "
+ + sourceDir );
+ return;
+ }
+
+ // Test that the source is a dir.
+ if ( !sourceDir.isDirectory() )
+ {
+ fail( "Unable to setup testable managed repository, source is not a directory: " + sourceDir );
+ }
+
+ // Make the destination dir.
+ destDir.mkdirs();
+
+ // Copy directory structure.
+ copyDirectoryStructure( sourceDir, destDir );
}
protected static Date getFutureDate()
Modified: maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java?rev=571008&r1=571007&r2=571008&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java Wed Aug 29 18:22:19 2007
@@ -43,6 +43,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -66,6 +68,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -88,6 +92,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -110,6 +116,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -132,6 +140,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -154,6 +164,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -174,6 +186,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -197,6 +211,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -217,6 +233,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -240,6 +258,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -260,6 +280,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -283,6 +305,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -306,6 +330,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -329,6 +355,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -352,6 +380,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -394,6 +424,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -416,6 +448,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -438,6 +472,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -455,5 +491,4 @@
assertChecksums( expectedFile, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4 get-bad-local-checksum-1.0.jar",
"46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );
}
-
}
Modified: maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java?rev=571008&r1=571007&r2=571008&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java Wed Aug 29 18:22:19 2007
@@ -44,6 +44,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -74,6 +76,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -102,6 +106,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
long originalModificationTime = expectedFile.lastModified();
@@ -154,6 +160,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -176,6 +184,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-in-both-proxies/1.0/get-in-both-proxies-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -207,6 +217,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -231,6 +243,8 @@
throws Exception
{
String path = "org/apache/maven/test/does-not-exist/1.0/does-not-exist-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -255,6 +269,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -288,6 +304,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -327,6 +345,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -352,6 +372,8 @@
String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );
@@ -373,6 +395,8 @@
throws Exception
{
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+ setupTestableManagedRepository( path );
+
File expectedFile = new File( managedDefaultDir, path );
ArtifactReference artifact = createArtifactReference( "default", path );