use of org.apache.archiva.rest.api.services.BrowseService in project archiva by apache.
the class BrowseServiceTest method versionsList.
@Test
public void versionsList() throws Exception {
BrowseService browseService = getBrowseService(authorizationHeader, false);
VersionsList versions = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", TEST_REPO_ID);
assertThat(versions).isNotNull();
//
assertThat(versions.getVersions()).isNotNull().isNotEmpty().hasSize(//
2).contains("2.2.1", "2.2.2");
}
use of org.apache.archiva.rest.api.services.BrowseService in project archiva by apache.
the class AbstractArchivaRestTest method getBrowseService.
protected BrowseService getBrowseService(String authzHeader, boolean useXml) {
// START SNIPPET: cxf-browseservice-creation
BrowseService service = JAXRSClientFactory.create(getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", BrowseService.class, Collections.singletonList(new JacksonJaxbJsonProvider()));
// to add authentification
if (authzHeader != null) {
WebClient.client(service).header("Authorization", authzHeader);
}
// Set the Referer header to your archiva server url
WebClient.client(service).header("Referer", "http://localhost:" + port);
WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(100000000);
if (useXml) {
WebClient.client(service).accept(MediaType.APPLICATION_XML_TYPE);
WebClient.client(service).type(MediaType.APPLICATION_XML_TYPE);
} else {
WebClient.client(service).accept(MediaType.APPLICATION_JSON_TYPE);
WebClient.client(service).type(MediaType.APPLICATION_JSON_TYPE);
}
return service;
// END SNIPPET: cxf-browseservice-creation
}
use of org.apache.archiva.rest.api.services.BrowseService in project archiva by apache.
the class RepositoriesServiceTest method deleteArtifactWithClassifier.
@Test
public void deleteArtifactWithClassifier() throws Exception {
initSourceTargetRepo();
BrowseService browseService = getBrowseService(authorizationHeader, false);
List<Artifact> artifacts = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(3);
VersionsList versionsList = browseService.getVersionsList("commons-logging", "commons-logging", SOURCE_REPO_ID);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(6);
log.info("artifacts.size: {}", artifacts.size());
try {
Path artifactFile = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar");
Path artifactFilemd5 = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.md5");
Path artifactFilesha1 = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.sha1");
assertTrue("artifact not exists:" + artifactFile, Files.exists(artifactFile));
assertTrue("md5 not exists:" + artifactFilemd5, Files.exists(artifactFilemd5));
assertTrue("sha1 not exists:" + artifactFilesha1, Files.exists(artifactFilesha1));
Artifact artifact = new Artifact();
artifact.setGroupId("commons-logging");
artifact.setArtifactId("commons-logging");
artifact.setVersion("1.0.1");
artifact.setClassifier("javadoc");
artifact.setPackaging("jar");
artifact.setContext(SOURCE_REPO_ID);
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
repositoriesService.deleteArtifact(artifact);
assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
assertFalse("md5 still exists:" + artifactFilemd5, Files.exists(artifactFilemd5));
assertFalse("sha1 still exists:" + artifactFilesha1, Files.exists(artifactFilesha1));
artifacts = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID);
log.info("artifact: {}", artifacts);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
versionsList = browseService.getVersionsList("commons-logging", "commons-logging", SOURCE_REPO_ID);
log.info("versionsList: {}", versionsList);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(6);
} finally {
cleanRepos();
}
}
use of org.apache.archiva.rest.api.services.BrowseService in project archiva by apache.
the class RepositoriesServiceTest method deleteGroupId.
@Test
public void deleteGroupId() throws Exception {
initSourceTargetRepo();
try {
BrowseService browseService = getBrowseService(authorizationHeader, false);
BrowseResult browseResult = browseService.browseGroupId("org.apache.karaf.features", SOURCE_REPO_ID);
assertNotNull(browseResult);
log.info("browseResult: {}", browseResult);
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isNotEmpty().contains(new BrowseResultEntry("org.apache.karaf.features.org.apache.karaf.features.command", true), new BrowseResultEntry("org.apache.karaf.features.org.apache.karaf.features.core", true));
Path directory = Paths.get("target/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.command");
assertTrue("directory not exists", Files.exists(directory));
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
repositoriesService.deleteGroupId("org.apache.karaf", SOURCE_REPO_ID);
assertFalse("directory not exists", Files.exists(directory));
browseResult = browseService.browseGroupId("org.apache.karaf.features", SOURCE_REPO_ID);
assertNotNull(browseResult);
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isEmpty();
browseResult = browseService.browseGroupId("org.apache.karaf", SOURCE_REPO_ID);
assertNotNull(browseResult);
assertThat(browseResult.getBrowseResultEntries()).isNotNull().isEmpty();
log.info("browseResult empty: {}", browseResult);
} finally {
cleanRepos();
}
}
Aggregations