use of org.apache.archiva.rest.api.model.SearchRequest in project archiva by apache.
the class SearchServiceTest method searchWithSearchNoRepos.
@Test
public /**
* ensure we revert to all observable repos in case of no repo in the request
*/
void searchWithSearchNoRepos() throws Exception {
SearchService searchService = getSearchService(authorizationHeader);
SearchRequest searchRequest = new SearchRequest();
searchRequest.setBundleExportPackage("org.apache.karaf.features.command.completers");
List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
assertNotNull(artifacts);
assertTrue(" not 0 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " + artifacts.size() + ":" + artifacts, artifacts.size() == 1);
log.info("artifact url {}", artifacts.get(0).getUrl());
}
use of org.apache.archiva.rest.api.model.SearchRequest in project archiva by apache.
the class SearchServiceTest method getSearchArtifactsWithOnlyClassifier.
@Test
public /**
* test we don't return 2 artifacts pom + zip one
*/
void getSearchArtifactsWithOnlyClassifier() throws Exception {
// force guest user creation if not exists
if (getUserService(authorizationHeader).getGuestUser() == null) {
assertNotNull(getUserService(authorizationHeader).createGuestUser());
}
createAndIndexRepo(TEST_REPO, "src/test/repo-with-classifier-only");
SearchService searchService = getSearchService(authorizationHeader);
SearchRequest searchRequest = new SearchRequest("org.foo", "studio-all-update-site", null, null, null, Arrays.asList(TEST_REPO));
List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
log.info("artifacts: {}", artifacts);
assertEquals(1, artifacts.size());
}
use of org.apache.archiva.rest.api.model.SearchRequest in project archiva by apache.
the class SearchServiceTest method searchWithSearchRequestExportPackageOneVersion.
@Test
public void searchWithSearchRequestExportPackageOneVersion() throws Exception {
SearchService searchService = getSearchService(authorizationHeader);
SearchRequest searchRequest = new SearchRequest();
searchRequest.setBundleExportPackage("org.apache.karaf.features.command.completers");
searchRequest.setRepositories(Arrays.asList(TEST_REPO));
List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
assertNotNull(artifacts);
assertTrue(" not 1 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " + artifacts.size() + ":" + artifacts, artifacts.size() == 1);
log.info("artifact url {}", artifacts.get(0).getUrl());
}
use of org.apache.archiva.rest.api.model.SearchRequest in project archiva by apache.
the class SearchServiceTest method searchWithSearchRequestBundleSymbolicNameTwoVersion.
@Test
public void searchWithSearchRequestBundleSymbolicNameTwoVersion() throws Exception {
UiConfiguration uiConfiguration = new UiConfiguration();
uiConfiguration.setApplicationUrl(null);
getArchivaAdministrationService().setUiConfiguration(uiConfiguration);
SearchService searchService = getSearchService(authorizationHeader);
SearchRequest searchRequest = new SearchRequest();
searchRequest.setBundleSymbolicName("org.apache.karaf.features.core");
List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
assertThat(artifacts).isNotNull().hasSize(2);
for (Artifact artifact : artifacts) {
log.info("url: {}", artifact.getUrl());
String version = artifact.getVersion();
//
Assertions.assertThat(artifact.getUrl()).isEqualTo("http://localhost:" + port + "/repository/test-repo/org/apache/karaf/features/org.apache.karaf.features.core/" + version + "/org.apache.karaf.features.core-" + version + ".jar");
}
}
use of org.apache.archiva.rest.api.model.SearchRequest in project archiva by apache.
the class DownloadMergedIndexNonDefaultPathTest method downloadMergedIndexWithNonDefaultPath.
@Test
public void downloadMergedIndexWithNonDefaultPath() throws Exception {
Path indexBaseDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("archiva").resolve("remotedownloadtest");
String indexBase = indexBaseDir.toString();
FileUtils.deleteQuietly(indexBaseDir);
if (!Files.exists(indexBaseDir)) {
Files.createDirectories(indexBaseDir);
}
String id = Long.toString(System.currentTimeMillis());
ManagedRepository managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId(id);
managedRepository.setName("name of " + id);
managedRepository.setLocation(System.getProperty("basedir") + "/src/test/repositories/test-repo");
managedRepository.setIndexDirectory(indexBase + "/index-" + id);
managedRepository.setPackedIndexDirectory(indexBase + "/indexPacked-" + id);
ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
if (managedRepositoriesService.getManagedRepository(id) != null) {
managedRepositoriesService.deleteManagedRepository(id, false);
}
getManagedRepositoriesService().addManagedRepository(managedRepository);
RepositoriesService repositoriesService = getRepositoriesService();
repositoriesService.scanRepositoryNow(id, true);
// wait a bit to ensure index is finished
int timeout = 20000;
while (timeout > 0 && repositoriesService.alreadyScanning(id)) {
Thread.sleep(500);
timeout -= 500;
}
RepositoryGroupService repositoryGroupService = getRepositoryGroupService();
String repoGroupId = "test-group";
if (repositoryGroupService.getRepositoryGroup(repoGroupId) != null) {
repositoryGroupService.deleteRepositoryGroup(repoGroupId);
}
RepositoryGroup repositoryGroup = new RepositoryGroup();
repositoryGroup.setId(repoGroupId);
String path = ".fooooo";
repositoryGroup.setRepositories(Arrays.asList(id));
repositoryGroup.setMergedIndexPath(path);
repositoryGroupService.addRepositoryGroup(repositoryGroup);
// create a repo with a remote on the one with index
id = Long.toString(System.currentTimeMillis());
managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId(id);
managedRepository.setName("name of " + id);
managedRepository.setLocation(System.getProperty("basedir") + "/src/test/repositories/test-repo");
managedRepository.setIndexDirectory(indexBaseDir + "/index-" + id);
managedRepository.setPackedIndexDirectory(indexBase + "/tmpIndexPacked-" + id);
if (managedRepositoriesService.getManagedRepository(id) != null) {
managedRepositoriesService.deleteManagedRepository(id, false);
}
getManagedRepositoriesService().addManagedRepository(managedRepository);
String remoteId = Long.toString(System.currentTimeMillis());
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setId(remoteId);
remoteRepository.setName(remoteId);
remoteRepository.setDownloadRemoteIndex(true);
remoteRepository.setUrl("http://localhost:" + port + "/repository/test-group");
remoteRepository.setRemoteIndexUrl("http://localhost:" + port + "/repository/test-group/" + path);
remoteRepository.setUserName(RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME);
remoteRepository.setPassword(FakeCreateAdminService.ADMIN_TEST_PWD);
getRemoteRepositoriesService().addRemoteRepository(remoteRepository);
ProxyConnectorService proxyConnectorService = getProxyConnectorService();
ProxyConnector proxyConnector = new ProxyConnector();
proxyConnector.setProxyId("foo-bar2");
proxyConnector.setSourceRepoId(id);
proxyConnector.setTargetRepoId(remoteId);
proxyConnectorService.addProxyConnector(proxyConnector);
repositoriesService.scheduleDownloadRemoteIndex(remoteId, true, true);
// wait the end
while (!repositoriesService.getRunningRemoteDownloadIds().getStrings().isEmpty()) {
Thread.sleep(500);
log.debug("still running remote download");
}
SearchService searchService = getSearchService();
SearchRequest request = new SearchRequest();
request.setRepositories(Arrays.asList(id));
request.setGroupId("org.apache.felix");
List<Artifact> artifacts = searchService.searchArtifacts(request);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(1);
}
Aggregations