use of org.apache.maven.index_shaded.lucene.search.Query in project archiva by apache.
the class MavenIndexManagerTest method scan.
@Test
public void scan() throws Exception {
createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-webapp/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-webapp/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
mavenIndexManager.scan(ctx);
IndexingContext mvnCtx = mavenIndexManager.getMvnContext(ctx);
String term = "org.apache.archiva";
Query q = new BooleanQuery.Builder().add(queryCreator.constructQuery(MAVEN.GROUP_ID, new UserInputSearchExpression(term)), BooleanClause.Occur.SHOULD).build();
assertEquals(4, mvnCtx.acquireIndexSearcher().count(q));
}
use of org.apache.maven.index_shaded.lucene.search.Query in project archiva by apache.
the class MavenIndexManagerTest method addArtifactsToIndex.
@Test
public void addArtifactsToIndex() throws Exception {
ArchivaIndexingContext ctx = createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-search/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-search/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
List<URI> uriList = new ArrayList<>();
uriList.add(destDir.resolve("archiva-search-1.0.jar").toUri());
uriList.add(destDir.resolve("archiva-search-1.0-sources.jar").toUri());
mavenIndexManager.addArtifactsToIndex(ctx, uriList);
IndexingContext mvnCtx = mavenIndexManager.getMvnContext(ctx);
String term = "org.apache.archiva";
Query q = new BooleanQuery.Builder().add(queryCreator.constructQuery(MAVEN.GROUP_ID, new UserInputSearchExpression(term)), BooleanClause.Occur.SHOULD).build();
assertEquals(2, mvnCtx.acquireIndexSearcher().count(q));
}
use of org.apache.maven.index_shaded.lucene.search.Query in project archiva by apache.
the class MavenIndexManagerTest method removeArtifactsFromIndex.
@Test
public void removeArtifactsFromIndex() throws Exception {
ArchivaIndexingContext ctx = createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-search/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-search/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
List<URI> uriList = new ArrayList<>();
uriList.add(destDir.resolve("archiva-search-1.0.jar").toUri());
uriList.add(destDir.resolve("archiva-search-1.0-sources.jar").toUri());
mavenIndexManager.addArtifactsToIndex(ctx, uriList);
IndexingContext mvnCtx = mavenIndexManager.getMvnContext(ctx);
String term = "org.apache.archiva";
Query q = new BooleanQuery.Builder().add(queryCreator.constructQuery(MAVEN.GROUP_ID, new UserInputSearchExpression(term)), BooleanClause.Occur.SHOULD).build();
assertEquals(2, mvnCtx.acquireIndexSearcher().count(q));
uriList.remove(0);
mavenIndexManager.removeArtifactsFromIndex(ctx, uriList);
assertEquals(1, mvnCtx.acquireIndexSearcher().count(q));
}
Aggregations