mirror of https://github.com/apache/maven.git
[MNG-3849] test harness
- abstract test for testing all repository system implementations - mercury implementation test git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@749864 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
245ff008fc
commit
9ef5c6edbe
|
@ -99,6 +99,14 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-metadata</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate-metadata</goal>
|
||||
<goal>generate-test-metadata</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -36,17 +36,10 @@ under the License.
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-repository</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-repository</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -68,56 +61,73 @@ under the License.
|
|||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-external</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-util</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-md-sat</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-repo-api</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-repo-local-m2</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-repo-remote-m2</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-artifact</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-plexus</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-transport-http</artifactId>
|
||||
<version>${mercury.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-repository</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sonatype.plexus</groupId>
|
||||
<artifactId>plexus-jetty6</artifactId>
|
||||
|
|
|
@ -51,13 +51,54 @@ under the License.
|
|||
<artifactId>wagon-file</artifactId>
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-util</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-metadata</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate-metadata</goal>
|
||||
<goal>generate-test-metadata</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>package-tests</id>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.mercury.util.FileUtil;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Oleg Gusakov
|
||||
* @version $Id$
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractMavenRepositorySystemTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
File _localBase;
|
||||
protected ArtifactRepository _localRepo;
|
||||
|
||||
File _remoteBase;
|
||||
protected List<ArtifactRepository> _remoteRepos;
|
||||
|
||||
String _port = "32825"; // from src/test/plexus/webdav.xml
|
||||
|
||||
ArtifactFactory _artifactFactory;
|
||||
|
||||
protected MavenRepositorySystem _mrs;
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
_remoteBase = new File("./target/remote-repo");
|
||||
FileUtil.delete( _remoteBase );
|
||||
FileUtil.unZip( getClassLoader().getResourceAsStream( "remoteRepo.jar" ), new File("target") );
|
||||
|
||||
assertTrue( _remoteBase.exists() );
|
||||
|
||||
// context comes from src/test/plexus/webdav.xml
|
||||
ArtifactRepository remoteRepo = new DefaultArtifactRepository("remote", "http://localhost:"+_port+"/webdav", new DefaultRepositoryLayout() );
|
||||
|
||||
_remoteRepos = new ArrayList<ArtifactRepository>(1);
|
||||
|
||||
_remoteRepos.add( remoteRepo );
|
||||
|
||||
_localBase = new File("./target/local-repo");
|
||||
FileUtil.delete( _localBase );
|
||||
_localBase.mkdirs();
|
||||
|
||||
_localRepo = new DefaultArtifactRepository("local", _localBase.getCanonicalPath(), new DefaultRepositoryLayout() );
|
||||
|
||||
_artifactFactory = getContainer().lookup( ArtifactFactory.class );
|
||||
}
|
||||
|
||||
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
|
||||
{
|
||||
URL url = getClassLoader().getResource( "webdav.xml" );
|
||||
containerConfiguration.setContainerConfigurationURL( url );
|
||||
}
|
||||
|
||||
private boolean checkExists( Collection<Artifact> arts, String name )
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer( name, ":" );
|
||||
|
||||
String groupId = st.nextToken();
|
||||
|
||||
String artifactId = st.nextToken();
|
||||
|
||||
String version = st.nextToken();
|
||||
|
||||
for( Artifact a : arts )
|
||||
if( groupId.equals( a.getGroupId() )
|
||||
&& artifactId.equals( a.getArtifactId() )
|
||||
&& version.equals( a.getVersion() )
|
||||
)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void testRetrieve() throws IOException
|
||||
{
|
||||
Artifact artifact = _artifactFactory.createArtifact( "asm", "asm-xml", "3.0", "compile", "jar" );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
|
||||
request.setLocalRepository( _localRepo );
|
||||
request.setRemoteRepostories( _remoteRepos );
|
||||
request.setArtifact( artifact );
|
||||
|
||||
ArtifactResolutionResult res = _mrs.resolve( request );
|
||||
|
||||
assertNotNull( res );
|
||||
|
||||
Set<Artifact> as = res.getArtifacts();
|
||||
|
||||
assertNotNull( as );
|
||||
|
||||
assertEquals( 4, as.size() );
|
||||
|
||||
assertTrue( checkExists( as, "asm:asm-xml:3.0" ) );
|
||||
|
||||
assertTrue( checkExists( as, "asm:asm-util:3.0" ) );
|
||||
|
||||
assertTrue( checkExists( as, "asm:asm-tree:3.0" ) );
|
||||
|
||||
assertTrue( checkExists( as, "asm:asm:3.0" ) );
|
||||
|
||||
assertFalse( checkExists( as, "asm:asm-parent:3.0" ) );
|
||||
|
||||
for( Artifact a : as )
|
||||
{
|
||||
assertTrue( a.getFile().exists() );
|
||||
|
||||
System.out.println( a.getFile().getCanonicalPath()+ " : "+ a.getFile().length()+" bytes");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
<plexus>
|
||||
<load-on-start>
|
||||
<component>
|
||||
<role>org.sonatype.plexus.webcontainer.ServletContainer</role>
|
||||
</component>
|
||||
</load-on-start>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.sonatype.plexus.webcontainer.ServletContainer</role>
|
||||
<implementation> org.sonatype.plexus.webcontainer.DefaultServletContainer</implementation>
|
||||
<configuration>
|
||||
<host>*</host>
|
||||
<port>32825</port>
|
||||
<servlets>
|
||||
<servlet>
|
||||
<clazz>org.sonatype.webdav.WebdavServlet</clazz>
|
||||
<resourceBase>${basedir}/target/remote-repo</resourceBase>
|
||||
<contextPath>/webdav</contextPath>
|
||||
</servlet>
|
||||
</servlets>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
Loading…
Reference in New Issue