1 package org.apache.maven.archiva.consumers;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.model.ArchivaRepository;
23 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
24 import org.codehaus.plexus.PlexusTestCase;
25 import org.codehaus.plexus.util.FileUtils;
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.Iterator;
31 import java.util.List;
34 * AbstractConsumerTestCase
36 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
39 public class AbstractConsumerTestCase extends PlexusTestCase
41 protected ArchivaRepository getLegacyRepository() throws Exception
43 File repoBaseDir = new File( getBasedir(), "src/test/legacy-repository" );
44 ArchivaRepository repository = createRepository( repoBaseDir, "legacy" );
45 resetRepositoryState( repository );
49 protected ArchivaRepository getDefaultRepository() throws Exception
51 File repoBaseDir = new File( getBasedir(), "src/test/repository" );
52 ArchivaRepository repository = createRepository( repoBaseDir, "default" );
53 resetRepositoryState( repository );
57 private void resetRepositoryState( ArchivaRepository repository ) throws IOException
59 File repoBaseDir = new File( repository.getRepositoryURL().getPath() );
61 List tmpfiles = FileUtils.getFiles( repoBaseDir, ".*", "" );
62 for ( Iterator it = tmpfiles.iterator(); it.hasNext(); )
64 File hit = (File) it.next();
72 if ( hit.isDirectory() )
74 FileUtils.deleteDirectory( hit );
80 protected ArchivaRepository createRepository( File basedir, String layout ) throws Exception
82 ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, layout );
84 ArchivaRepository repo = new ArchivaRepository();
85 repo.setId( "discoveryRepo" );
86 repo.setUrl( "file://" + basedir );
87 repo.setLayout( repoLayout );
92 public List getLegacyLayoutArtifactPaths()
94 List files = new ArrayList();
96 files.add( "invalid/jars/1.0/invalid-1.0.jar" );
97 files.add( "invalid/jars/invalid-1.0.rar" );
98 files.add( "invalid/jars/invalid.jar" );
99 files.add( "invalid/invalid-1.0.jar" );
100 files.add( "javax.sql/jars/jdbc-2.0.jar" );
101 files.add( "org.apache.maven/jars/some-ejb-1.0-client.jar" );
102 files.add( "org.apache.maven/jars/testing-1.0.jar" );
103 files.add( "org.apache.maven/jars/testing-1.0-sources.jar" );
104 files.add( "org.apache.maven/jars/testing-UNKNOWN.jar" );
105 files.add( "org.apache.maven/jars/testing-1.0.zip" );
106 files.add( "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar" );
107 files.add( "org.apache.maven/jars/testing-1.0.tar.gz" );
108 files.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" );
109 files.add( "org.apache.maven.update/jars/test-updated-1.0.jar" );
114 public List getDefaultLayoutArtifactPaths()
116 List files = new ArrayList();
118 files.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
119 files.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
120 files.add( "invalid/invalid/1.0/invalid-1.0b.jar" );
121 files.add( "invalid/invalid/1.0/invalid-2.0.jar" );
122 files.add( "invalid/invalid-1.0.jar" );
123 files.add( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" );
124 files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" );
125 files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" );
126 files.add( "org/apache/maven/A/1.0/A-1.0.war" );
127 files.add( "org/apache/maven/A/1.0/A-1.0.pom" );
128 files.add( "org/apache/maven/B/2.0/B-2.0.pom" );
129 files.add( "org/apache/maven/B/1.0/B-1.0.pom" );
130 files.add( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" );
131 files.add( "org/apache/maven/C/1.0/C-1.0.war" );
132 files.add( "org/apache/maven/C/1.0/C-1.0.pom" );
133 files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" );
134 files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar" );
135 files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" );
136 files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar" );
137 files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" );
138 files.add( "org/apache/maven/testing/1.0/testing-1.0-test-sources.jar" );
139 files.add( "org/apache/maven/testing/1.0/testing-1.0.jar" );
140 files.add( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" );
141 files.add( "org/apache/maven/testing/1.0/testing-1.0.zip" );
142 files.add( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" );
143 files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" );
144 files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.jar" );
145 files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" );
146 files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" );
147 files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );
148 files.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" );