use of org.apache.archiva.repository.content.base.ArchivaItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method deleteVersionItem.
@Test
public void deleteVersionItem() throws IOException, URISyntaxException, ItemNotFoundException {
ManagedRepository repo = createManagedRepoWithContent("delete-repository");
ManagedRepositoryContent myRepoContent = repo.getContent();
Path repoRoot = repo.getRoot().getFilePath();
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A/1.0")));
ArchivaItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("A").withVersion("1.0").build();
ContentItem item = myRepoContent.getItem(selector);
assertTrue(item instanceof Version);
myRepoContent.deleteItem(item);
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/2.0")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/maven/A/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar")));
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").withVersion("2.0").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Version);
myRepoContent.deleteItem(item);
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/2.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/2.0")));
}
use of org.apache.archiva.repository.content.base.ArchivaItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method deleteArtifactItem.
@Test
public void deleteArtifactItem() throws IOException, URISyntaxException, ItemNotFoundException {
ManagedRepository repo = createManagedRepoWithContent("delete-repository");
ManagedRepositoryContent myRepoContent = repo.getContent();
Path repoRoot = repo.getRoot().getFilePath();
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A/1.0/A-1.0.pom")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A/1.0/A-1.0.war")));
ArchivaItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("A").withVersion("1.0").withArtifactId("A").withArtifactVersion("1.0").withExtension("pom").build();
ContentItem item = myRepoContent.getItem(selector);
assertTrue(item instanceof Artifact);
myRepoContent.deleteItem(item);
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/2.0")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/maven/A/1.0/A-1.0.pom")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A/1.0/A-1.0.war")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.md5")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.sha1")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.pom")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0-source.jar")));
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").withVersion("1.0").withArtifactId("samplejar").withArtifactVersion("1.0").withExtension("jar").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Artifact);
myRepoContent.deleteItem(item);
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.md5")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.sha1")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.pom")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0-source.jar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/2.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/2.0")));
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").withVersion("1.0").withArtifactId("samplejar").withArtifactVersion("1.0").withClassifier("source").withExtension("jar").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Artifact);
myRepoContent.deleteItem(item);
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.md5")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.sha1")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.pom")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0-source.jar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0-source.jar.sha1")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/2.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/2.0")));
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").withVersion("1.0").withArtifactId("samplejar").withArtifactVersion("1.0").withExtension("jar.md5").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Artifact);
myRepoContent.deleteItem(item);
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.md5")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.jar.sha1")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0.pom")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0-source.jar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/1.0/samplejar-1.0-source.jar.sha1")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar/2.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar/2.0")));
}
use of org.apache.archiva.repository.content.base.ArchivaItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method deleteProjectItem.
@Test
public void deleteProjectItem() throws IOException, URISyntaxException, ItemNotFoundException {
ManagedRepository repo = createManagedRepoWithContent("delete-repository");
ManagedRepositoryContent myRepoContent = repo.getContent();
Path repoRoot = repo.getRoot().getFilePath();
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A")));
ArchivaItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("A").build();
ContentItem item = myRepoContent.getItem(selector);
assertTrue(item instanceof Project);
myRepoContent.deleteItem(item);
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/2.0")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/maven/A")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar")));
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Project);
myRepoContent.deleteItem(item);
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar")));
}
use of org.apache.archiva.repository.content.base.ArchivaItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method getExistingMetadataItem.
@Test
public void getExistingMetadataItem() {
// org/apache/maven/some-ejb/1.0
ArchivaItemSelector versionSelector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("some-ejb").withVersion("1.0").build();
Version version = repoContent.getVersion(versionSelector);
DataItem metaData = repoContent.getMetadataItem(version);
assertTrue(metaData.exists());
assertEquals("/org/apache/maven/some-ejb/1.0/maven-metadata.xml", metaData.getAsset().getPath());
}
Aggregations