use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MetadataToolsTest method assertProjectReference.
private void assertProjectReference(String groupId, String artifactId, String path) throws RepositoryMetadataException {
ItemSelector reference = tools.toProjectSelector(path);
assertNotNull("Reference should not be null.", reference);
assertEquals("ProjectReference.groupId", groupId, reference.getNamespace());
assertEquals("ProjectReference.artifactId", artifactId, reference.getArtifactId());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MetadataToolsTest method testToPathFromProjectReference.
@Test
public void testToPathFromProjectReference() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("com.foo").withProjectId("foo-tool").withArtifactId("foo-tool").build();
assertEquals("com/foo/foo-tool/maven-metadata.xml", tools.toPath(selector));
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MetadataToolsTest method assertUpdatedSnapshotVersionMetadata.
private void assertUpdatedSnapshotVersionMetadata(String artifactId, String version, String expectedDate, String expectedTime, String expectedBuildNumber) throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ItemSelector reference = ArchivaItemSelector.builder().withNamespace("org.apache.archiva.metadata.tests").withArtifactId(artifactId).withProjectId(artifactId).withVersion(version).build();
prepTestRepo(testRepo, reference);
tools.updateVersionMetadata(testRepo, reference);
StringBuilder buf = new StringBuilder();
buf.append("<metadata>\n");
buf.append(" <groupId>").append(reference.getNamespace()).append("</groupId>\n");
buf.append(" <artifactId>").append(reference.getArtifactId()).append("</artifactId>\n");
buf.append(" <version>").append(reference.getVersion()).append("</version>\n");
buf.append(" <versioning>\n");
buf.append(" <snapshot>\n");
buf.append(" <buildNumber>").append(expectedBuildNumber).append("</buildNumber>\n");
buf.append(" <timestamp>");
buf.append(expectedDate).append(".").append(expectedTime);
buf.append("</timestamp>\n");
buf.append(" </snapshot>\n");
buf.append(" <lastUpdated>").append(expectedDate).append(expectedTime).append("</lastUpdated>\n");
buf.append(" </versioning>\n");
buf.append("</metadata>");
assertMetadata(buf.toString(), testRepo, reference);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MetadataToolsTest method assertUpdatedReleaseVersionMetadata.
private void assertUpdatedReleaseVersionMetadata(String artifactId, String version) throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.archiva.metadata.tests").withProjectId(artifactId).withArtifactId(artifactId).withVersion(version).build();
prepTestRepo(testRepo, selector);
tools.updateVersionMetadata(testRepo, selector);
StringBuilder buf = new StringBuilder();
buf.append("<metadata>\n");
buf.append(" <groupId>").append(selector.getNamespace()).append("</groupId>\n");
buf.append(" <artifactId>").append(selector.getArtifactId()).append("</artifactId>\n");
buf.append(" <version>").append(selector.getVersion()).append("</version>\n");
buf.append("</metadata>");
assertMetadata(buf.toString(), testRepo, selector);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MetadataToolsTest method testUpdateProjectNonExistingVersion.
// TODO: replace with group tests
// public void testUpdateProjectBadArtifact()
// throws Exception
// {
// try
// {
// assertUpdatedProjectMetadata( "bad_artifact", null );
// fail( "Should have thrown an IOException on a bad artifact." );
// }
// catch ( IOException e )
// {
// // Expected path
// }
// }
@Test
public void testUpdateProjectNonExistingVersion() throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ItemSelector reference = ArchivaItemSelector.builder().withNamespace("org.apache.archiva.metadata.tests").withProjectId("missing_artifact").build();
prepProjectTestRepo(testRepo, reference);
// check metadata prior to update -- should contain the non-existing artifact version
assertProjectMetadata(testRepo, reference, "missing_artifact", new String[] { "1.0-SNAPSHOT", "1.1-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null);
tools.updateProjectMetadata(testRepo, reference);
// metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT
assertProjectMetadata(testRepo, reference, "missing_artifact", new String[] { "1.0-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null);
}
Aggregations