use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchOSGITest method searchFelixWithSymbolicName.
@Test
public void searchFelixWithSymbolicName() throws Exception {
createIndex(TEST_REPO_1, Collections.<Path>emptyList(), true);
List<String> selectedRepos = Arrays.asList(TEST_REPO_1);
// search artifactId
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchFields searchFields = new SearchFields();
searchFields.setBundleSymbolicName("org.apache.felix.bundlerepository");
searchFields.setBundleVersion("1.6.6");
searchFields.setRepositories(selectedRepos);
SearchResults results = search.search("user", searchFields, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals(1, results.getTotalHits());
SearchResultHit hit = results.getHits().get(0);
assertEquals("org.apache.felix", hit.getGroupId());
assertEquals("org.apache.felix.bundlerepository", hit.getArtifactId());
assertEquals("1.6.6", hit.getVersions().get(0));
assertEquals("org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"", hit.getBundleExportPackage());
assertEquals("org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin", hit.getBundleExportService());
assertEquals("org.apache.felix.bundlerepository", hit.getBundleSymbolicName());
assertEquals("1.6.6", hit.getBundleVersion());
}
use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchTest method nolimitedResult.
@Test
public void nolimitedResult() throws Exception {
Path repo = Paths.get("target/repo-release");
FileUtils.deleteDirectory(repo.toFile());
Path indexDirectory = repo.resolve(".index");
FileUtils.copyDirectoryStructure(Paths.get("src/test/repo-release").toFile(), repo.toFile());
IndexUpgrader.main(new String[] { indexDirectory.toAbsolutePath().toString() });
createIndex(REPO_RELEASE, Collections.emptyList(), false, indexDirectory);
// indexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo.toFile(), indexDirectory.toFile(),
// repo.toUri().toURL().toExternalForm(),
// indexDirectory.toUri().toURL().toString(), indexCreators );
SearchResultLimits limits = new SearchResultLimits(SearchResultLimits.ALL_PAGES);
limits.setPageSize(300);
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults searchResults = //
search.search(//
null, //
Arrays.asList(REPO_RELEASE), //
"org.example", //
limits, Collections.emptyList());
log.info("results: {}", searchResults.getHits().size());
assertEquals(255, searchResults.getHits().size());
SearchFields searchFields = new SearchFields();
searchFields.setGroupId("org.example");
searchFields.setRepositories(Arrays.asList(REPO_RELEASE));
searchResults = search.search(null, searchFields, limits);
log.info("results: {}", searchResults.getHits().size());
assertEquals(255, searchResults.getHits().size());
archivaConfigControl.verify();
}
use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchTest method testAdvancedSearchJarArtifacts.
@Test
public void testAdvancedSearchJarArtifacts() throws Exception {
createIndexContainingMoreArtifacts(true);
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setPackaging("jar");
searchFields.setRepositories(selectedRepos);
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults results = search.search("user", searchFields, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals("not 8 but " + results.getTotalHits() + ":" + niceDisplay(results), 8, results.getTotalHits());
}
use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchTest method testAdvancedSearchSearchFieldsAreBlank.
@Test
public void testAdvancedSearchSearchFieldsAreBlank() throws Exception {
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setGroupId("");
searchFields.setArtifactId("");
searchFields.setVersion("");
searchFields.setPackaging("");
searchFields.setClassName("");
searchFields.setRepositories(selectedRepos);
try {
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
search.search("user", searchFields, null);
archivaConfigControl.verify();
fail("A RepositorySearchException should have been thrown.");
} catch (RepositorySearchException e) {
assertEquals("No search fields set.", e.getMessage());
}
}
use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchTest method testAdvancedSearchClassname.
@Test
public void testAdvancedSearchClassname() throws Exception {
createIndexContainingMoreArtifacts(true);
List<String> selectedRepos = Arrays.asList(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setClassName("com.classname.search.App");
searchFields.setRepositories(selectedRepos);
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults results = search.search("user", searchFields, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals("totalHits not 1 results " + results, 1, results.getTotalHits());
SearchResultHit hit = results.getHits().get(0);
assertEquals("groupId not com", "com", hit.getGroupId());
assertEquals("arttifactId not classname-search", "classname-search", hit.getArtifactId());
assertEquals(" hits.version(0) not 1.0", "1.0", hit.getVersions().get(0));
}
Aggregations