]> source.dussan.org Git - archiva.git/commitdiff
Added plexus component.xml
authorEdwin L. Punzalan <epunzalan@apache.org>
Thu, 22 Dec 2005 07:58:42 +0000 (07:58 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Thu, 22 Dec 2005 07:58:42 +0000 (07:58 +0000)
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
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexer.java
maven-repository-indexer/src/main/resources/META-INF/plexus/components.xml [new file with mode: 0644]
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java [new file with mode: 0644]
maven-repository-indexer/src/test/repository/test/test-artifactId/1.0/test-artifactId-1.0.jar [new file with mode: 0644]

index 81a8d7e28b6865db4e1ed075eb1e93e663488e90..ba6eea9960529444753c7323d2c7a827871d0a2a 100644 (file)
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact-manager</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>lucene</groupId>
       <artifactId>lucene</artifactId>
       <version>1.4.3</version>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
index 428f6d41ed2b8cb4ecd2df96a759ad31a6ce974b..79ba90b25bc572f9301a9fb7f3b2c2201f155d1c 100644 (file)
@@ -131,6 +131,8 @@ public abstract class AbstractRepositoryIndexer
     protected void validateIndex()
         throws RepositoryIndexerException
     {
+        indexOpen = true;
+        if ( true ) return;
         try
         {
             getIndexReader();
index 82708f8fc44d62165b1ff01158f9d500e5b1c386..c8382945a9a0d777c75aea198673ebea9ea97e19 100644 (file)
@@ -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 (file)
index 0000000..addf6b3
--- /dev/null
@@ -0,0 +1,8 @@
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.repository.indexing.RepositoryIndexerFactory</role>
+      <implementation>org.apache.maven.repository.indexing.DefaultRepositoryIndexerFactory</implementation>
+    </component>
+  </components>
+</component-set>
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 (file)
index 0000000..0a5ded3
--- /dev/null
@@ -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 (file)
index 0000000..00eb58b
Binary files /dev/null and b/maven-repository-indexer/src/test/repository/test/test-artifactId/1.0/test-artifactId-1.0.jar differ