archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r746169 - in /archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src: main/java/org/apache/archiva/consumers/lucene/ main/resources/META-INF/ test/java/org/apache/archiva/consumers/lucene/
Date Fri, 20 Feb 2009 06:52:42 GMT
Author: oching
Date: Fri Feb 20 06:52:41 2009
New Revision: 746169

URL: http://svn.apache.org/viewvc?rev=746169&view=rev
Log:
[MRM-1079]
o updated and activated tests for index cleanup consumer
o cleaned up index cleanup consumer

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
    archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
    archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java?rev=746169&r1=746168&r2=746169&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
Fri Feb 20 06:52:41 2009
@@ -41,7 +41,6 @@
 import org.sonatype.nexus.index.context.IndexingContext;
 import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException;
 import org.sonatype.nexus.index.creator.AbstractIndexCreator;
-import org.sonatype.nexus.index.creator.IndexerEngine;
 
 import java.io.File;
 import java.io.IOException;
@@ -64,22 +63,17 @@
 
     private ArtifactContextProducer artifactContextProducer;
 
-    private IndexerEngine indexerEngine;
-
     private IndexingContext context;
 
-    public LuceneCleanupRemoveIndexedConsumer( RepositoryContentFactory repoFactory, NexusIndexer
indexer,
-                                               IndexerEngine indexerEngine )
+    public LuceneCleanupRemoveIndexedConsumer( RepositoryContentFactory repoFactory, NexusIndexer
indexer )
     {
         this.repoFactory = repoFactory;
         this.indexer = indexer;
-        this.indexerEngine = indexerEngine;
         this.artifactContextProducer = new DefaultArtifactContextProducer();
     }
 
     public void beginScan()
     {
-        // TODO Auto-generated method stub
 
     }
 
@@ -136,7 +130,6 @@
                     context.setSearchable( repository.isScanned() );
 
                     File artifactFile = new File( repoContent.getRepoRoot(), repoContent.toPath(
artifact ) );
-                    System.out.println( "artifactFile :: " + artifactFile.getAbsolutePath()
);
 
                     if ( !artifactFile.exists() )
                     {
@@ -147,7 +140,7 @@
                         {
                             //indexerEngine.remove( context, artifactContext );
 
-                            // hack for deleting documents - indexer engine's isn't working
for me
+                            // hack for deleting documents - indexer engine's remove(...)
isn't working for me
                             removeDocuments( artifactContext );
                         }
                     }
@@ -167,7 +160,7 @@
             throw new ConsumerException( "Can't run index cleanup consumer: " + e.getMessage()
);
         }
     }
-    
+
     private void removeDocuments( ArtifactContext ac )
         throws IOException
     {
@@ -209,4 +202,9 @@
     {
         this.repoFactory = repoFactory;
     }
+
+    public void setArtifactContextProducer( ArtifactContextProducer artifactContextProducer
)
+    {
+        this.artifactContextProducer = artifactContextProducer;
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml?rev=746169&r1=746168&r2=746169&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
Fri Feb 20 06:52:41 2009
@@ -12,6 +12,5 @@
     <bean id="indexCleanupConsumer" class="org.apache.archiva.consumers.lucene.LuceneCleanupRemoveIndexedConsumer">
         <constructor-arg ref="repositoryContentFactory"/>
         <constructor-arg ref="nexusIndexer#archiva"/>
-        <constructor-arg ref="indexerEngine"/>
     </bean>
 </beans>
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java?rev=746169&r1=746168&r2=746169&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java
Fri Feb 20 06:52:41 2009
@@ -32,47 +32,48 @@
 import org.easymock.classextension.MockClassControl;
 import org.sonatype.nexus.index.ArtifactContext;
 import org.sonatype.nexus.index.ArtifactContextProducer;
-import org.sonatype.nexus.index.DefaultArtifactContextProducer;
+import org.sonatype.nexus.index.ArtifactInfo;
 import org.sonatype.nexus.index.NexusIndexer;
 import org.sonatype.nexus.index.context.DefaultIndexingContext;
 import org.sonatype.nexus.index.context.IndexingContext;
-import org.sonatype.nexus.index.creator.IndexerEngine;
 
 public class LuceneCleanupRemoveIndexedConsumerTest
     extends PlexusInSpringTestCase
 {
     private LuceneCleanupRemoveIndexedConsumer consumer;
-    
+
     private MockControl indexerControl;
-    
+
     private NexusIndexer indexer;
-    
+
     private RepositoryContentFactory repoFactory;
-    
+
     private MockControl repoFactoryControl;
-    
+
     private ManagedRepositoryConfiguration repositoryConfig;
-    
+
+    private MockControl contextProducerControl;
+
     private ArtifactContextProducer artifactContextProducer;
-    
-    private IndexerEngine indexerEngine;
-    
+
+    private MockControl acControl;
+
+    private ArtifactContext ac;
+
     public void setUp()
-        throws Exception 
+        throws Exception
     {
         super.setUp();
-        
+
         indexerControl = MockControl.createControl( NexusIndexer.class );
         indexerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
-        indexer = ( NexusIndexer ) indexerControl.getMock();
-        
+        indexer = (NexusIndexer) indexerControl.getMock();
+
         repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class
);
-        repoFactory = ( RepositoryContentFactory ) repoFactoryControl.getMock();
-        
-        indexerEngine = ( IndexerEngine ) lookup( IndexerEngine.class );
-        
-        consumer = new LuceneCleanupRemoveIndexedConsumer( repoFactory, indexer, indexerEngine
);
-        
+        repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
+
+        consumer = new LuceneCleanupRemoveIndexedConsumer( repoFactory, indexer );
+
         repositoryConfig = new ManagedRepositoryConfiguration();
         repositoryConfig.setId( "test-repo" );
         repositoryConfig.setLocation( getBasedir() + "/target/test-classes/test-repo" );
@@ -80,28 +81,34 @@
         repositoryConfig.setName( "Test Repository" );
         repositoryConfig.setScanned( true );
         repositoryConfig.setSnapshots( false );
-        repositoryConfig.setReleases( true ); 
+        repositoryConfig.setReleases( true );
         repositoryConfig.setIndexDir( getBasedir() + "/target/test-classes/test-repo/.cleanup-index"
);
-        
-        artifactContextProducer = new DefaultArtifactContextProducer();
+
+        contextProducerControl = MockControl.createControl( ArtifactContextProducer.class
);
+        artifactContextProducer = (ArtifactContextProducer) contextProducerControl.getMock();
+
+        consumer.setArtifactContextProducer( artifactContextProducer );
+
+        acControl = MockClassControl.createControl( ArtifactContext.class );
+        ac = (ArtifactContext) acControl.getMock();
     }
-    
-    public void tearDown() 
+
+    public void tearDown()
         throws Exception
     {
         FileUtils.deleteDirectory( new File( repositoryConfig.getIndexDir() ) );
-        
+
         super.tearDown();
     }
-    
+
     public void testProcessArtifactArtifactDoesNotExist()
         throws Exception
     {
-        /*ArchivaArtifact artifact =
+        ArchivaArtifact artifact =
             new ArchivaArtifact( "org.apache.archiva", "archiva-lucene-consumers", "1.2",
null, "jar", "test-repo" );
         ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
         repoContent.setRepository( repositoryConfig );
-        
+
         IndexingContext context =
             new DefaultIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(),
                                         new File( repositoryConfig.getLocation() ),
@@ -111,51 +118,57 @@
         File artifactFile =
             new File( repositoryConfig.getLocation(),
                       "org/apache/archiva/archiva-lucene-consumers/1.2/archiva-lucene-consumers-1.2.jar"
);
-        ArtifactContext artifactContext = artifactContextProducer.getArtifactContext( context,
artifactFile );
-        
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( repositoryConfig.getId()
), repoContent );
+        ArtifactInfo ai = new ArtifactInfo( "test-repo", "org.apache.archiva", "archiva-lucene-consumers",
"1.2", null );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( repositoryConfig.getId()
),
+                                            repoContent );
         indexerControl.expectAndReturn( indexer.addIndexingContext( repositoryConfig.getId(),
repositoryConfig.getId(),
-                                        new File( repositoryConfig.getLocation() ),
-                                        new File( repositoryConfig.getIndexDir() ), null,
null,
-                                        NexusIndexer.FULL_INDEX ), context );
-        indexer.deleteArtifactFromIndex( artifactContext, context );
-        indexerControl.setVoidCallable();
-        
+                                                                    new File( repositoryConfig.getLocation()
),
+                                                                    new File( repositoryConfig.getIndexDir()
), null,
+                                                                    null, NexusIndexer.FULL_INDEX
), context );
+        contextProducerControl.expectAndReturn( artifactContextProducer.getArtifactContext(
context, artifactFile ), ac );
+        acControl.expectAndReturn( ac.getArtifactInfo(), ai );
+
         repoFactoryControl.replay();
         indexerControl.replay();
-        
+        contextProducerControl.replay();
+        acControl.replay();
+
         consumer.processArchivaArtifact( artifact );
-        
+
         repoFactoryControl.verify();
-        indexerControl.verify();    */    
-    }    
-    
+        indexerControl.verify();
+        contextProducerControl.verify();
+        acControl.verify();
+    }
+
     public void testProcessArtifactArtifactExists()
         throws Exception
     {
-        /*ArchivaArtifact artifact =
+        ArchivaArtifact artifact =
             new ArchivaArtifact( "org.apache.maven.archiva", "archiva-lucene-cleanup", "1.0",
null, "jar", "test-repo" );
         ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
         repoContent.setRepository( repositoryConfig );
-        
+
         IndexingContext context =
             new DefaultIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(),
                                         new File( repositoryConfig.getLocation() ),
                                         new File( repositoryConfig.getIndexDir() ), null,
null,
                                         NexusIndexer.FULL_INDEX, false );
-        
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( repositoryConfig.getId()
), repoContent );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( repositoryConfig.getId()
),
+                                            repoContent );
         indexerControl.expectAndReturn( indexer.addIndexingContext( repositoryConfig.getId(),
repositoryConfig.getId(),
-                                        new File( repositoryConfig.getLocation() ),
-                                        new File( repositoryConfig.getIndexDir() ), null,
null,
-                                        NexusIndexer.FULL_INDEX ), context );
-        
+                                                                    new File( repositoryConfig.getLocation()
),
+                                                                    new File( repositoryConfig.getIndexDir()
), null,
+                                                                    null, NexusIndexer.FULL_INDEX
), context );
+
         repoFactoryControl.replay();
         indexerControl.replay();
-        
+
         consumer.processArchivaArtifact( artifact );
-        
+
         repoFactoryControl.verify();
-        indexerControl.verify();        */
-    }    
+        indexerControl.verify();
+    }
 }



Mime
View raw message