[MNG-3849]

- abstract test for testing all repository system implementations
- mercury implementation test

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@749858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Gusakov 2009-03-04 00:28:50 +00:00
parent 892ade6462
commit fca57c3241
5 changed files with 153 additions and 28 deletions

View File

@ -29,12 +29,11 @@ under the License.
<artifactId>maven-repository-mercury</artifactId> <artifactId>maven-repository-mercury</artifactId>
<name>Mercury Repository </name> <name>Mercury Repository </name>
<description>Mercury implementation for the Maven Repository System</description> <description>Mercury implementation for the Maven Repository System</description>
<properties> <properties>
<mercury.version>1.0-alpha-6-SNAPSHOT</mercury.version> <mercury.version>1.0-alpha-6-SNAPSHOT</mercury.version>
<plexus.lang.version>1.1</plexus.lang.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -42,6 +41,18 @@ under the License.
<artifactId>maven-repository</artifactId> <artifactId>maven-repository</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-mercury</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId> <artifactId>plexus-utils</artifactId>
@ -54,7 +65,31 @@ under the License.
<dependency> <dependency>
<groupId>org.apache.maven.mercury</groupId> <groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-plexus</artifactId> <artifactId>mercury-external</artifactId>
<version>${mercury.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-util</artifactId>
<version>${mercury.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-md-sat</artifactId>
<version>${mercury.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-repo-api</artifactId>
<version>${mercury.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-repo-local-m2</artifactId>
<version>${mercury.version}</version> <version>${mercury.version}</version>
</dependency> </dependency>
@ -63,20 +98,54 @@ under the License.
<artifactId>mercury-repo-remote-m2</artifactId> <artifactId>mercury-repo-remote-m2</artifactId>
<version>${mercury.version}</version> <version>${mercury.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.apache.maven.mercury</groupId>
<artifactId>plexus-lang</artifactId> <artifactId>mercury-artifact</artifactId>
<version>${plexus.lang.version}</version> <version>${mercury.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-plexus</artifactId>
<version>${mercury.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury-transport-http</artifactId>
<version>${mercury.version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-jetty6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonatype.spice</groupId>
<artifactId>plexus-webdav</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId> <artifactId>plexus-component-metadata</artifactId>
<executions>
<execution>
<goals>
<goal>generate-metadata</goal>
<goal>generate-test-metadata</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -26,10 +26,8 @@ Licensed to the Apache Software Foundation (ASF) under one
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.mercury.artifact.ArtifactBasicMetadata; import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
import org.apache.maven.mercury.artifact.ArtifactMetadata; import org.apache.maven.mercury.artifact.ArtifactMetadata;
import org.apache.maven.mercury.builder.api.DependencyProcessor; import org.apache.maven.mercury.builder.api.DependencyProcessor;
@ -60,7 +58,7 @@ public static List<Repository> toMercuryRepos( ArtifactRepository localRepositor
if ( localRepository != null ) if ( localRepository != null )
{ {
LocalRepositoryM2 lr = LocalRepositoryM2 lr =
new LocalRepositoryM2( localRepository.getId(), new File( localRepository.getBasedir() ), new LocalRepositoryM2( localRepository.getId(), new File( localRepository.getUrl() ),
dependencyProcessor ); dependencyProcessor );
res.add( lr ); res.add( lr );
} }
@ -111,14 +109,33 @@ public static ArtifactMetadata toMercuryMetadata( Artifact a )
return md; return md;
} }
public static Artifact toMavenArtifact( org.apache.maven.mercury.artifact.Artifact a ) public static Artifact toMavenArtifact( ArtifactFactory af, org.apache.maven.mercury.artifact.Artifact a )
{ {
VersionRange vr = VersionRange.createFromVersion( a.getVersion() ); Artifact ma = a.getClassifier() == null
Artifact ma = ? af.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), a.getType() )
new DefaultArtifact( a.getGroupId(), a.getArtifactId(), vr, a.getScope(), a.getType(), a.getClassifier(), : af.createArtifactWithClassifier( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier() )
null ); ;
ma.setScope( a.getScope() );
ma.setFile( a.getFile() );
return ma; return ma;
} }
public static Artifact toMavenArtifact( ArtifactFactory af, org.apache.maven.mercury.artifact.ArtifactBasicMetadata a )
{
Artifact ma = a.getClassifier() == null
? af.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), a.getType() )
: af.createArtifactWithClassifier( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier() )
;
ma.setScope( a.getScope() );
return ma;
}
public static Artifact toMavenArtifact( ArtifactFactory af, String name )
{
return toMavenArtifact( af, new ArtifactBasicMetadata(name) );
}
} }

View File

@ -19,13 +19,10 @@ Licensed to the Apache Software Foundation (ASF) under one
package org.apache.maven.repository.mercury; package org.apache.maven.repository.mercury;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -37,9 +34,6 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.apache.maven.mercury.plexus.PlexusMercury; import org.apache.maven.mercury.plexus.PlexusMercury;
import org.apache.maven.mercury.repository.api.Repository; import org.apache.maven.mercury.repository.api.Repository;
import org.apache.maven.mercury.repository.api.RepositoryException; import org.apache.maven.mercury.repository.api.RepositoryException;
import org.apache.maven.mercury.repository.local.m2.LocalRepositoryM2;
import org.apache.maven.mercury.repository.remote.m2.RemoteRepositoryM2;
import org.apache.maven.mercury.transport.api.Server;
import org.apache.maven.mercury.util.Util; import org.apache.maven.mercury.util.Util;
import org.apache.maven.repository.LegacyMavenRepositorySystem; import org.apache.maven.repository.LegacyMavenRepositorySystem;
import org.apache.maven.repository.MavenRepositorySystem; import org.apache.maven.repository.MavenRepositorySystem;
@ -65,6 +59,9 @@ public class MercuryRepositorySystem
@Requirement @Requirement
PlexusMercury _mercury; PlexusMercury _mercury;
@Requirement
ArtifactFactory _artifactFactory;
@Override @Override
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{ {
@ -90,7 +87,7 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
if ( !Util.isEmpty( mercuryArtifactList ) ) if ( !Util.isEmpty( mercuryArtifactList ) )
for ( org.apache.maven.mercury.artifact.Artifact a : mercuryArtifactList ) for ( org.apache.maven.mercury.artifact.Artifact a : mercuryArtifactList )
result.addArtifact( MercuryAdaptor.toMavenArtifact( a ) ); result.addArtifact( MercuryAdaptor.toMavenArtifact( _artifactFactory, a ) );
} }
catch ( RepositoryException e ) catch ( RepositoryException e )
{ {

View File

@ -0,0 +1,42 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.maven.repository.mercury;
import org.apache.maven.repository.AbstractMavenRepositorySystemTest;
import org.apache.maven.repository.MavenRepositorySystem;
/**
*
*
* @author Oleg Gusakov
* @version $Id$
*
*/
public class MercuryRepositorySystemTest
extends AbstractMavenRepositorySystemTest
{
protected void setUp()
throws Exception
{
super.setUp();
_mrs = getContainer().lookup( MavenRepositorySystem.class, "mercury" );
}
}