From c9d2f469d0673db702df2d4cf373081ea5389a76 Mon Sep 17 00:00:00 2001 From: "Edwin L. Punzalan" Date: Thu, 22 Dec 2005 07:58:42 +0000 Subject: [PATCH] Added plexus component.xml Added unit test and files. git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@358523 13f79535-47bb-0310-9956-ffa450edef68 --- maven-repository-indexer/pom.xml | 9 +++ .../indexing/AbstractRepositoryIndexer.java | 2 + .../indexing/ArtifactRepositoryIndexer.java | 1 + .../resources/META-INF/plexus/components.xml | 8 ++ .../ArtifactRepositoryIndexingTest.java | 74 ++++++++++++++++++ .../1.0/test-artifactId-1.0.jar | Bin 0 -> 2467 bytes 6 files changed, 94 insertions(+) create mode 100644 maven-repository-indexer/src/main/resources/META-INF/plexus/components.xml create mode 100644 maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java create mode 100644 maven-repository-indexer/src/test/repository/test/test-artifactId/1.0/test-artifactId-1.0.jar diff --git a/maven-repository-indexer/pom.xml b/maven-repository-indexer/pom.xml index 81a8d7e28..ba6eea996 100644 --- a/maven-repository-indexer/pom.xml +++ b/maven-repository-indexer/pom.xml @@ -14,11 +14,20 @@ org.apache.maven maven-artifact + + org.apache.maven + maven-artifact-manager + test + lucene lucene 1.4.3 + + org.codehaus.plexus + plexus-container-default + junit junit diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java index 428f6d41e..79ba90b25 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java @@ -131,6 +131,8 @@ public abstract class AbstractRepositoryIndexer protected void validateIndex() throws RepositoryIndexerException { + indexOpen = true; + if ( true ) return; try { getIndexReader(); diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexer.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexer.java index 82708f8fc..c8382945a 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexer.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexer.java @@ -180,6 +180,7 @@ public class ArtifactRepositoryIndexer for ( Enumeration entries = jar.entries(); entries.hasMoreElements(); ) { ZipEntry entry = (ZipEntry) entries.nextElement(); + System.out.println( entry.getName() ); if ( addIfClassEntry( entry ) ) { addClassPackage( entry.getName() ); diff --git a/maven-repository-indexer/src/main/resources/META-INF/plexus/components.xml b/maven-repository-indexer/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..addf6b3c2 --- /dev/null +++ b/maven-repository-indexer/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,8 @@ + + + + org.apache.maven.repository.indexing.RepositoryIndexerFactory + org.apache.maven.repository.indexing.DefaultRepositoryIndexerFactory + + + diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java new file mode 100644 index 000000000..0a5ded391 --- /dev/null +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java @@ -0,0 +1,74 @@ +package org.apache.maven.repository.indexing; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import java.io.File; +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.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; + +import org.codehaus.plexus.PlexusTestCase; + +/** + * + * @author Edwin Punzalan + */ +public class ArtifactRepositoryIndexingTest + extends PlexusTestCase +{ + protected ArtifactRepositoryIndexer indexer; + protected ArtifactFactory artifactFactory; + protected ArtifactRepository repository; + protected String indexPath; + + protected void setUp() + throws Exception + { + super.setUp(); + + File repositoryDirectory = getTestFile( "src/test/repository" ); + String repoDir = repositoryDirectory.toURL().toString(); + + ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); + ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); + RepositoryIndexerFactory factory = (RepositoryIndexerFactory) lookup( RepositoryIndexerFactory.ROLE ); + + String indexPath = "target/index"; + repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null ); + indexer = (ArtifactRepositoryIndexer) factory.getArtifactRepositoryIndexer( indexPath, repository ); + artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + } + + public void testIndex() + throws Exception + { + Artifact artifact = getArtifact( "test", "test-artifactId", "1.0" ); + artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) ); + indexer.addArtifactIndex( artifact ); + //indexer.optimize(); + indexer.close(); + } + + protected Artifact getArtifact( String groupId, String artifactId, String version ) + { + return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" ); + } +} diff --git a/maven-repository-indexer/src/test/repository/test/test-artifactId/1.0/test-artifactId-1.0.jar b/maven-repository-indexer/src/test/repository/test/test-artifactId/1.0/test-artifactId-1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..00eb58b70ab2fe7e99c2dbefada0757a4fd6dd12 GIT binary patch literal 2467 zcmWIWW@h1H00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