use of org.apache.maven.index_shaded.lucene.search.TopDocs in project archiva by apache.
the class ArchivaIndexingTaskExecutorTest method testUpdateArtifactInIndex.
@Test
public void testUpdateArtifactInIndex() throws Exception {
Path basePath = repo.getLocalPath();
Path artifactFile = basePath.resolve("org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar");
ArtifactIndexingTask task = new ArtifactIndexingTask(repo, artifactFile, ArtifactIndexingTask.Action.ADD, repo.getIndexingContext());
indexingExecutor.executeTask(task);
indexingExecutor.executeTask(task);
BooleanQuery.Builder qb = new BooleanQuery.Builder();
qb.add(indexer.constructQuery(MAVEN.GROUP_ID, new StringSearchExpression("org.apache.archiva")), BooleanClause.Occur.SHOULD);
qb.add(indexer.constructQuery(MAVEN.ARTIFACT_ID, new StringSearchExpression("archiva-index-methods-jar-test")), BooleanClause.Occur.SHOULD);
IndexingContext ctx = getIndexingContext();
IndexSearcher searcher = ctx.acquireIndexSearcher();
TopDocs topDocs = searcher.search(qb.build(), 10);
// searcher.close();
ctx.releaseIndexSearcher(searcher);
assertTrue(Files.exists(basePath.resolve(".indexer")));
assertTrue(Files.exists(basePath.resolve(".index")));
// should only return 1 hit!
assertEquals(1, topDocs.totalHits);
}
Aggregations