1 package org.apache.maven.repository.indexing;
4 * Copyright 2001-2005 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
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 import org.apache.maven.artifact.Artifact;
22 import org.apache.maven.artifact.factory.ArtifactFactory;
23 import org.apache.maven.artifact.repository.ArtifactRepository;
25 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
26 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
28 import org.codehaus.plexus.PlexusTestCase;
32 * @author Edwin Punzalan
34 public class ArtifactRepositoryIndexingTest
35 extends PlexusTestCase
37 protected ArtifactRepositoryIndexer indexer;
38 protected ArtifactFactory artifactFactory;
39 protected ArtifactRepository repository;
40 protected String indexPath;
42 protected void setUp()
47 File repositoryDirectory = getTestFile( "src/test/repository" );
48 String repoDir = repositoryDirectory.toURL().toString();
50 ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
51 ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
52 RepositoryIndexerFactory factory = (RepositoryIndexerFactory) lookup( RepositoryIndexerFactory.ROLE );
54 String indexPath = "target/index";
55 repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
56 indexer = (ArtifactRepositoryIndexer) factory.getArtifactRepositoryIndexer( indexPath, repository );
57 artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
60 public void testIndex()
63 Artifact artifact = getArtifact( "test", "test-artifactId", "1.0" );
64 artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
65 indexer.addArtifactIndex( artifact );
70 protected Artifact getArtifact( String groupId, String artifactId, String version )
72 return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );