1 package org.apache.maven.archiva.discoverer;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.apache.maven.artifact.Artifact;
20 import org.apache.maven.artifact.factory.ArtifactFactory;
21 import org.apache.maven.artifact.repository.ArtifactRepository;
22 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
23 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
24 import org.codehaus.plexus.PlexusTestCase;
29 * @author Edwin Punzalan
31 public abstract class AbstractArtifactDiscovererTest
32 extends PlexusTestCase
34 protected ArtifactDiscoverer discoverer;
36 private ArtifactFactory factory;
38 protected ArtifactRepository repository;
40 protected abstract String getLayout();
42 protected abstract File getRepositoryFile();
44 protected void setUp()
49 discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, getLayout() );
51 factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
53 repository = getRepository();
56 protected ArtifactRepository getRepository()
59 File basedir = getRepositoryFile();
61 ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
63 ArtifactRepositoryLayout layout =
64 (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, getLayout() );
66 return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
69 protected Artifact createArtifact( String groupId, String artifactId, String version )
71 Artifact artifact = factory.createArtifact( groupId, artifactId, version, null, "jar" );
72 artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
73 artifact.setRepository( repository );
77 protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
79 return factory.createArtifact( groupId, artifactId, version, null, type );
82 protected Artifact createArtifact( String groupId, String artifactId, String version, String type,
85 return factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );