You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/03/04 01:48:35 UTC

svn commit: r749864 - in /maven/components/trunk: maven-mercury/ maven-repository-mercury/ maven-repository/ maven-repository/src/test/java/org/apache/maven/repository/ maven-repository/src/test/resources/

Author: ogusakov
Date: Wed Mar  4 00:48:34 2009
New Revision: 749864

URL: http://svn.apache.org/viewvc?rev=749864&view=rev
Log:
[MNG-3849] test harness
- abstract test for testing all repository system implementations
- mercury implementation test

Added:
    maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java   (with props)
    maven/components/trunk/maven-repository/src/test/resources/
    maven/components/trunk/maven-repository/src/test/resources/remoteRepo.jar   (with props)
    maven/components/trunk/maven-repository/src/test/resources/webdav.xml   (with props)
Modified:
    maven/components/trunk/maven-mercury/pom.xml
    maven/components/trunk/maven-repository-mercury/pom.xml
    maven/components/trunk/maven-repository/pom.xml

Modified: maven/components/trunk/maven-mercury/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/pom.xml?rev=749864&r1=749863&r2=749864&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/pom.xml (original)
+++ maven/components/trunk/maven-mercury/pom.xml Wed Mar  4 00:48:34 2009
@@ -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>

Modified: maven/components/trunk/maven-repository-mercury/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-repository-mercury/pom.xml?rev=749864&r1=749863&r2=749864&view=diff
==============================================================================
--- maven/components/trunk/maven-repository-mercury/pom.xml (original)
+++ maven/components/trunk/maven-repository-mercury/pom.xml Wed Mar  4 00:48:34 2009
@@ -39,14 +39,7 @@
     <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,57 +61,74 @@
       <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>                                                                                
       <scope>test</scope>

Modified: maven/components/trunk/maven-repository/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-repository/pom.xml?rev=749864&r1=749863&r2=749864&view=diff
==============================================================================
--- maven/components/trunk/maven-repository/pom.xml (original)
+++ maven/components/trunk/maven-repository/pom.xml Wed Mar  4 00:48:34 2009
@@ -51,13 +51,54 @@
       <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>

Added: maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java?rev=749864&view=auto
==============================================================================
--- maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java (added)
+++ maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java Wed Mar  4 00:48:34 2009
@@ -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");
+        }
+
+    }
+
+    
+}

Propchange: maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-repository/src/test/java/org/apache/maven/repository/AbstractMavenRepositorySystemTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-repository/src/test/resources/remoteRepo.jar
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-repository/src/test/resources/remoteRepo.jar?rev=749864&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/components/trunk/maven-repository/src/test/resources/remoteRepo.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/components/trunk/maven-repository/src/test/resources/webdav.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-repository/src/test/resources/webdav.xml?rev=749864&view=auto
==============================================================================
--- maven/components/trunk/maven-repository/src/test/resources/webdav.xml (added)
+++ maven/components/trunk/maven-repository/src/test/resources/webdav.xml Wed Mar  4 00:48:34 2009
@@ -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>

Propchange: maven/components/trunk/maven-repository/src/test/resources/webdav.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-repository/src/test/resources/webdav.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision