Search in sources :

Example 1 with ItemSelector

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());
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector)

Example 2 with ItemSelector

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));
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 3 with ItemSelector

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);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent)

Example 4 with ItemSelector

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);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent)

Example 5 with ItemSelector

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);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Aggregations

ItemSelector (org.apache.archiva.repository.content.ItemSelector)76 ArchivaItemSelector (org.apache.archiva.repository.content.base.ArchivaItemSelector)74 Test (org.junit.Test)41 Path (java.nio.file.Path)16 Artifact (org.apache.archiva.repository.content.Artifact)16 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)13 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)12 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)12 LayoutException (org.apache.archiva.repository.content.LayoutException)12 IOException (java.io.IOException)11 ContentItem (org.apache.archiva.repository.content.ContentItem)11 Project (org.apache.archiva.repository.content.Project)11 ArchivaContentItem (org.apache.archiva.repository.content.base.ArchivaContentItem)10 Namespace (org.apache.archiva.repository.content.Namespace)9 Version (org.apache.archiva.repository.content.Version)9 VersionComparator (org.apache.archiva.common.utils.VersionComparator)8 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Stream (java.util.stream.Stream)6