mirror of https://github.com/apache/archiva.git
fix unit test, ArtifactIndexingTask has now a new field onlyUpdate to prevent full scan after only adding a file
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1159077 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3652f4c6e4
commit
0ea6774509
|
@ -112,11 +112,9 @@ public class ArchivaIndexingTaskExecutor
|
|||
if ( ArtifactIndexingTask.Action.FINISH.equals( indexingTask.getAction() )
|
||||
&& indexingTask.isExecuteOnEntireRepo() )
|
||||
{
|
||||
// TODO update or not !!
|
||||
// olamy currently do the full scan
|
||||
try
|
||||
{
|
||||
nexusIndexer.scan( context, null, false );
|
||||
nexusIndexer.scan( context, null, indexingTask.isOnlyUpdate() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -51,6 +51,11 @@ public class ArtifactIndexingTask
|
|||
|
||||
private boolean executeOnEntireRepo = true;
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
private boolean onlyUpdate = false;
|
||||
|
||||
public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action,
|
||||
IndexingContext context )
|
||||
{
|
||||
|
@ -67,6 +72,13 @@ public class ArtifactIndexingTask
|
|||
this.executeOnEntireRepo = executeOnEntireRepo;
|
||||
}
|
||||
|
||||
public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action,
|
||||
IndexingContext context, boolean executeOnEntireRepo, boolean onlyUpdate )
|
||||
{
|
||||
this( repository, resourceFile, action, context, executeOnEntireRepo );
|
||||
this.onlyUpdate = onlyUpdate;
|
||||
}
|
||||
|
||||
public boolean isExecuteOnEntireRepo()
|
||||
{
|
||||
return executeOnEntireRepo;
|
||||
|
@ -92,13 +104,6 @@ public class ArtifactIndexingTask
|
|||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "ArtifactIndexingTask [action=" + action + ", repositoryId=" + repository.getId() + ", resourceFile="
|
||||
+ resourceFile + "]";
|
||||
}
|
||||
|
||||
public ManagedRepositoryConfiguration getRepository()
|
||||
{
|
||||
return repository;
|
||||
|
@ -109,6 +114,16 @@ public class ArtifactIndexingTask
|
|||
return context;
|
||||
}
|
||||
|
||||
public boolean isOnlyUpdate()
|
||||
{
|
||||
return onlyUpdate;
|
||||
}
|
||||
|
||||
public void setOnlyUpdate( boolean onlyUpdate )
|
||||
{
|
||||
this.onlyUpdate = onlyUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
@ -158,6 +173,23 @@ public class ArtifactIndexingTask
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "ArtifactIndexingTask [action=" + action + ", repositoryId=" + repository.getId() + ", resourceFile="
|
||||
+ resourceFile + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME remove this static somewhere else !
|
||||
* @param repository
|
||||
* @param indexer
|
||||
* @param indexCreators
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws UnsupportedExistingLuceneIndexException
|
||||
*/
|
||||
public static IndexingContext createContext( ManagedRepositoryConfiguration repository, NexusIndexer indexer,
|
||||
List<? extends IndexCreator> indexCreators )
|
||||
throws IOException, UnsupportedExistingLuceneIndexException
|
||||
|
|
|
@ -278,12 +278,15 @@ public class ArchivaIndexingTaskExecutorTest
|
|||
ArtifactIndexingTask task =
|
||||
new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD,
|
||||
getIndexingContext() );
|
||||
task.setExecuteOnEntireRepo( false );
|
||||
|
||||
indexingExecutor.executeTask( task );
|
||||
|
||||
task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH,
|
||||
getIndexingContext() );
|
||||
|
||||
task.setExecuteOnEntireRepo( false );
|
||||
|
||||
indexingExecutor.executeTask( task );
|
||||
|
||||
assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() );
|
||||
|
@ -303,14 +306,14 @@ public class ArchivaIndexingTaskExecutorTest
|
|||
FlatSearchRequest request = new FlatSearchRequest( q, getIndexingContext() );
|
||||
FlatSearchResponse response = indexer.searchFlat( request );
|
||||
|
||||
assertEquals( 1, response.getTotalHits() );
|
||||
|
||||
Set<ArtifactInfo> results = response.getResults();
|
||||
|
||||
ArtifactInfo artifactInfo = (ArtifactInfo) results.iterator().next();
|
||||
ArtifactInfo artifactInfo = results.iterator().next();
|
||||
assertEquals( "org.apache.archiva", artifactInfo.groupId );
|
||||
assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
|
||||
assertEquals( "test-repo", artifactInfo.repository );
|
||||
|
||||
assertEquals( 1, response.getTotalHits() );
|
||||
}
|
||||
|
||||
private void unzipIndex( String indexDir, String destDir )
|
||||
|
|
Loading…
Reference in New Issue