1 package org.apache.maven.archiva.common;
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.artifact.repository.ArtifactRepository;
23 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
24 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
25 import org.codehaus.plexus.PlexusTestCase;
26 import org.codehaus.plexus.util.FileUtils;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.Iterator;
32 import java.util.List;
35 * AbstractArchivaCommonTestCase
37 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
40 public abstract class AbstractArchivaCommonTestCase
41 extends PlexusTestCase
43 protected ArtifactRepository getLegacyRepository()
46 File repoBaseDir = new File( getBasedir(), "src/test/legacy-repository" );
47 ArtifactRepository repository = createRepository( repoBaseDir, "legacy" );
48 resetRepositoryState( repository );
52 protected ArtifactRepository getDefaultRepository()
55 File repoBaseDir = new File( getBasedir(), "src/test/repository" );
56 ArtifactRepository repository = createRepository( repoBaseDir, "default" );
57 resetRepositoryState( repository );
61 private void resetRepositoryState( ArtifactRepository repository )
64 File repoBaseDir = new File( repository.getBasedir() );
66 List tmpfiles = FileUtils.getFiles( repoBaseDir, ".*", "" );
67 for ( Iterator it = tmpfiles.iterator(); it.hasNext(); )
69 File hit = (File) it.next();
77 if ( hit.isDirectory() )
79 FileUtils.deleteDirectory( hit );
85 protected ArtifactRepository createRepository( File basedir, String layout )
88 ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
90 ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, layout );
92 return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, repoLayout, null, null );
95 public List getLegacyLayoutArtifactPaths()
97 List files = new ArrayList();
99 files.add( "invalid/jars/1.0/invalid-1.0.jar" );
100 files.add( "invalid/jars/invalid-1.0.rar" );
101 files.add( "invalid/jars/invalid.jar" );
102 files.add( "invalid/invalid-1.0.jar" );
103 files.add( "javax.sql/jars/jdbc-2.0.jar" );
104 files.add( "org.apache.maven/jars/some-ejb-1.0-client.jar" );
105 files.add( "org.apache.maven/jars/testing-1.0.jar" );
106 files.add( "org.apache.maven/jars/testing-1.0-sources.jar" );
107 files.add( "org.apache.maven/jars/testing-UNKNOWN.jar" );
108 files.add( "org.apache.maven/jars/testing-1.0.zip" );
109 files.add( "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar" );
110 files.add( "org.apache.maven/jars/testing-1.0.tar.gz" );
111 files.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" );
112 files.add( "org.apache.maven.update/jars/test-updated-1.0.jar" );
117 public List getDefaultLayoutArtifactPaths()
119 List files = new ArrayList();
121 files.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
122 files.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
123 files.add( "invalid/invalid/1.0/invalid-1.0b.jar" );
124 files.add( "invalid/invalid/1.0/invalid-2.0.jar" );
125 files.add( "invalid/invalid-1.0.jar" );
126 files.add( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" );
127 files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" );
128 files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" );
129 files.add( "org/apache/maven/A/1.0/A-1.0.war" );
130 files.add( "org/apache/maven/A/1.0/A-1.0.pom" );
131 files.add( "org/apache/maven/B/2.0/B-2.0.pom" );
132 files.add( "org/apache/maven/B/1.0/B-1.0.pom" );
133 files.add( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" );
134 files.add( "org/apache/maven/C/1.0/C-1.0.war" );
135 files.add( "org/apache/maven/C/1.0/C-1.0.pom" );
136 files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" );
137 files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar" );
138 files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" );
139 files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar" );
140 files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" );
141 files.add( "org/apache/maven/testing/1.0/testing-1.0-test-sources.jar" );
142 files.add( "org/apache/maven/testing/1.0/testing-1.0.jar" );
143 files.add( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" );
144 files.add( "org/apache/maven/testing/1.0/testing-1.0.zip" );
145 files.add( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" );
146 files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" );
147 files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.jar" );
148 files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" );
149 files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" );
150 files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );
151 files.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" );
156 public List getDefaultLayoutMetadataPaths()
158 List files = new ArrayList();
160 files.add( "org/apache/maven/some-ejb/1.0/maven-metadata.xml" );
161 files.add( "org/apache/maven/update/test-not-updated/maven-metadata.xml" );
162 files.add( "org/apache/maven/update/test-updated/maven-metadata.xml" );
163 files.add( "org/apache/maven/maven-metadata.xml" );
164 files.add( "org/apache/testgroup/discovery/1.0/maven-metadata.xml" );
165 files.add( "org/apache/testgroup/discovery/maven-metadata.xml" );
166 files.add( "javax/sql/jdbc/2.0/maven-metadata-repository.xml" );
167 files.add( "javax/sql/jdbc/maven-metadata-repository.xml" );
168 files.add( "javax/sql/maven-metadata-repository.xml" );
169 files.add( "javax/maven-metadata.xml" );
174 public List getDefaultLayoutModelPaths()
176 List files = new ArrayList();
178 files.add( "org/apache/maven/A/1.0/A-1.0.pom" );
179 files.add( "org/apache/maven/B/2.0/B-2.0.pom" );
180 files.add( "org/apache/maven/B/1.0/B-1.0.pom" );
181 files.add( "org/apache/maven/C/1.0/C-1.0.pom" );
182 files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" );
183 files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" );
184 files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" );
185 files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" );
186 files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" );
187 files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );