use of org.apache.archiva.maven.model.Artifact in project archiva by apache.
the class BrowseServiceTest method searchArtifacts.
@Test
public void searchArtifacts() throws Exception {
// START SNIPPET: search-artifacts
BrowseService browseService = getBrowseService(authorizationHeader, true);
tryAssert(() -> {
List<Artifact> artifactDownloadInfos = browseService.searchArtifacts("The Apache Software Foundation", TEST_REPO_ID, true);
assertThat(artifactDownloadInfos).isNotNull().isNotEmpty().hasSize(7);
});
// END SNIPPET: search-artifacts
}
use of org.apache.archiva.maven.model.Artifact in project archiva by apache.
the class RepositoriesServiceTest method deleteArtifactVersion.
/**
* delete a version of an artifact without packaging
*
* @throws Exception
*/
@Test
public void deleteArtifactVersion() throws Exception {
initSourceTargetRepo();
BrowseService browseService = getBrowseService(authorizationHeader, false);
List<Artifact> artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
log.info("artifacts: {}", artifacts);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
VersionsList versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(2);
log.info("artifacts.size: {}", artifacts.size());
try {
Path artifactFile = getAppserverBase().resolve("data/repositories/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar");
assertTrue("artifact not exists:" + artifactFile, Files.exists(artifactFile));
Artifact artifact = new Artifact();
artifact.setGroupId("org.apache.karaf.features");
artifact.setArtifactId("org.apache.karaf.features.core");
artifact.setVersion("2.2.2");
artifact.setContext(SOURCE_REPO_ID);
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
repositoriesService.deleteArtifact(artifact);
assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
assertThat(artifacts).isNotNull().isEmpty();
versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(1);
} finally {
cleanRepos();
}
}
use of org.apache.archiva.maven.model.Artifact in project archiva by apache.
the class RepositoriesServiceTest method deleteArtifact.
@Test
public void deleteArtifact() throws Exception {
initSourceTargetRepo();
BrowseService browseService = getBrowseService(authorizationHeader, false);
List<Artifact> artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
log.info("artifacts: {}", artifacts);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
VersionsList versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(2);
log.info("artifacts.size: {}", artifacts.size());
try {
Path artifactFile = getAppserverBase().resolve("data/repositories/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar");
assertTrue("artifact not exists:" + artifactFile.toString(), Files.exists(artifactFile));
Artifact artifact = new Artifact();
artifact.setGroupId("org.apache.karaf.features");
artifact.setArtifactId("org.apache.karaf.features.core");
artifact.setVersion("2.2.2");
artifact.setPackaging("jar");
artifact.setContext(SOURCE_REPO_ID);
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
repositoriesService.deleteArtifact(artifact);
assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
assertThat(artifacts).isNotNull().isEmpty();
versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(1);
} finally {
cleanRepos();
}
}
use of org.apache.archiva.maven.model.Artifact in project archiva by apache.
the class RepositoriesServiceTest method deleteSnapshot.
@Test
public void deleteSnapshot() throws Exception {
Path targetRepo = initSnapshotRepo();
try {
RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
// repositoriesService.scanRepositoryDirectoriesNow( SNAPSHOT_REPO_ID );
BrowseService browseService = getBrowseService(authorizationHeader, false);
List<Artifact> artifacts = browseService.getArtifactDownloadInfos("org.apache.archiva.redback.components", "spring-quartz", "2.0-SNAPSHOT", SNAPSHOT_REPO_ID);
log.info("artifacts: {}", artifacts);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(10);
Path artifactFile = targetRepo.resolve("org/apache/archiva/redback/components/spring-quartz/2.0-SNAPSHOT/spring-quartz-2.0-20120618.214127-1.jar");
Path artifactFilemd5 = targetRepo.resolve("org/apache/archiva/redback/components/spring-quartz/2.0-SNAPSHOT/spring-quartz-2.0-20120618.214127-1.jar.md5");
Path artifactFilepom = targetRepo.resolve("org/apache/archiva/redback/components/spring-quartz/2.0-SNAPSHOT/spring-quartz-2.0-20120618.214127-1.pom");
assertTrue(Files.exists(artifactFile));
assertTrue(Files.exists(artifactFilemd5));
assertTrue(Files.exists(artifactFilepom));
// we delete only one snapshot
Artifact artifact = new Artifact("org.apache.archiva.redback.components", "spring-quartz", "2.0-20120618.214127-1");
artifact.setPackaging("jar");
artifact.setRepositoryId(SNAPSHOT_REPO_ID);
artifact.setContext(SNAPSHOT_REPO_ID);
repositoriesService.deleteArtifact(artifact);
artifacts = browseService.getArtifactDownloadInfos("org.apache.archiva.redback.components", "spring-quartz", "2.0-SNAPSHOT", SNAPSHOT_REPO_ID);
log.info("artifacts: {}", artifacts);
assertThat(artifacts).isNotNull().isNotEmpty().hasSize(8);
assertFalse(Files.exists(artifactFile));
assertFalse(Files.exists(artifactFilemd5));
assertFalse(Files.exists(artifactFilepom));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
cleanSnapshotRepo();
}
}
use of org.apache.archiva.maven.model.Artifact in project archiva by apache.
the class SearchServiceTest method search_with_sha1.
/**
* sha1 commons-logging 1.1 ba24d5de831911b684c92cd289ed5ff826271824
*/
@Test
public void search_with_sha1() throws Exception {
SearchService searchService = getSearchService(authorizationHeader);
List<Artifact> artifacts = searchService.getArtifactByChecksum(new ChecksumSearch(null, "ba24d5de831911b684c92cd289ed5ff826271824"));
Assertions.assertThat(artifacts).isNotNull().isNotEmpty().hasSize(1);
}
Aggregations