mirror of https://github.com/apache/archiva.git
[MRM-1079]
o updated and activated tests for index cleanup consumer o cleaned up index cleanup consumer git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@746169 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
57ebe9526a
commit
48e96d554f
|
@ -41,7 +41,6 @@ import org.sonatype.nexus.index.NexusIndexer;
|
|||
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 @@ public class LuceneCleanupRemoveIndexedConsumer
|
|||
|
||||
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 @@ public class LuceneCleanupRemoveIndexedConsumer
|
|||
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 @@ public class LuceneCleanupRemoveIndexedConsumer
|
|||
{
|
||||
//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 );
|
||||
}
|
||||
}
|
||||
|
@ -209,4 +202,9 @@ public class LuceneCleanupRemoveIndexedConsumer
|
|||
{
|
||||
this.repoFactory = repoFactory;
|
||||
}
|
||||
|
||||
public void setArtifactContextProducer( ArtifactContextProducer artifactContextProducer )
|
||||
{
|
||||
this.artifactContextProducer = artifactContextProducer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
|
@ -32,11 +32,10 @@ import org.easymock.MockControl;
|
|||
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
|
||||
|
@ -53,9 +52,13 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
|
||||
private ManagedRepositoryConfiguration repositoryConfig;
|
||||
|
||||
private MockControl contextProducerControl;
|
||||
|
||||
private ArtifactContextProducer artifactContextProducer;
|
||||
|
||||
private IndexerEngine indexerEngine;
|
||||
private MockControl acControl;
|
||||
|
||||
private ArtifactContext ac;
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
|
@ -69,9 +72,7 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
|
||||
repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
|
||||
|
||||
indexerEngine = ( IndexerEngine ) lookup( IndexerEngine.class );
|
||||
|
||||
consumer = new LuceneCleanupRemoveIndexedConsumer( repoFactory, indexer, indexerEngine );
|
||||
consumer = new LuceneCleanupRemoveIndexedConsumer( repoFactory, indexer );
|
||||
|
||||
repositoryConfig = new ManagedRepositoryConfiguration();
|
||||
repositoryConfig.setId( "test-repo" );
|
||||
|
@ -83,7 +84,13 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
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()
|
||||
|
@ -97,7 +104,7 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
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 );
|
||||
|
@ -111,29 +118,34 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
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 );
|
||||
ArtifactInfo ai = new ArtifactInfo( "test-repo", "org.apache.archiva", "archiva-lucene-consumers", "1.2", null );
|
||||
|
||||
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 );
|
||||
indexer.deleteArtifactFromIndex( artifactContext, context );
|
||||
indexerControl.setVoidCallable();
|
||||
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 );
|
||||
|
@ -144,11 +156,12 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
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.getIndexDir() ), null,
|
||||
null, NexusIndexer.FULL_INDEX ), context );
|
||||
|
||||
repoFactoryControl.replay();
|
||||
indexerControl.replay();
|
||||
|
@ -156,6 +169,6 @@ public class LuceneCleanupRemoveIndexedConsumerTest
|
|||
consumer.processArchivaArtifact( artifact );
|
||||
|
||||
repoFactoryControl.verify();
|
||||
indexerControl.verify(); */
|
||||
indexerControl.verify();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue