Search in sources :

Example 36 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class MetadataToolsTest method assertUpdatedProjectMetadata.

private void assertUpdatedProjectMetadata(String artifactId, String[] expectedVersions, String latestVersion, String releaseVersion) throws Exception {
    ManagedRepositoryContent testRepo = createTestRepoContent();
    ProjectReference reference = new ProjectReference();
    reference.setGroupId("org.apache.archiva.metadata.tests");
    reference.setArtifactId(artifactId);
    prepTestRepo(testRepo, reference);
    tools.updateMetadata(testRepo, reference);
    StringBuilder buf = new StringBuilder();
    buf.append("<metadata>\n");
    buf.append("  <groupId>").append(reference.getGroupId()).append("</groupId>\n");
    buf.append("  <artifactId>").append(reference.getArtifactId()).append("</artifactId>\n");
    if (expectedVersions != null) {
        buf.append("  <versioning>\n");
        if (latestVersion != null) {
            buf.append("    <latest>").append(latestVersion).append("</latest>\n");
        }
        if (releaseVersion != null) {
            buf.append("    <release>").append(releaseVersion).append("</release>\n");
        }
        buf.append("    <versions>\n");
        for (int i = 0; i < expectedVersions.length; i++) {
            buf.append("      <version>").append(expectedVersions[i]).append("</version>\n");
        }
        buf.append("    </versions>\n");
        buf.append("  </versioning>\n");
    }
    buf.append("</metadata>");
    assertMetadata(buf.toString(), testRepo, reference);
}
Also used : ProjectReference(org.apache.archiva.model.ProjectReference) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent)

Example 37 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent 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();
    ProjectReference reference = new ProjectReference();
    reference.setGroupId("org.apache.archiva.metadata.tests");
    reference.setArtifactId("missing_artifact");
    prepTestRepo(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.updateMetadata(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 : ProjectReference(org.apache.archiva.model.ProjectReference) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Example 38 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class MetadataToolsTest method assertUpdatedReleaseVersionMetadata.

private void assertUpdatedReleaseVersionMetadata(String artifactId, String version) throws Exception {
    ManagedRepositoryContent testRepo = createTestRepoContent();
    VersionedReference reference = new VersionedReference();
    reference.setGroupId("org.apache.archiva.metadata.tests");
    reference.setArtifactId(artifactId);
    reference.setVersion(version);
    prepTestRepo(testRepo, reference);
    tools.updateMetadata(testRepo, reference);
    StringBuilder buf = new StringBuilder();
    buf.append("<metadata>\n");
    buf.append("  <groupId>").append(reference.getGroupId()).append("</groupId>\n");
    buf.append("  <artifactId>").append(reference.getArtifactId()).append("</artifactId>\n");
    buf.append("  <version>").append(reference.getVersion()).append("</version>\n");
    buf.append("</metadata>");
    assertMetadata(buf.toString(), testRepo, reference);
}
Also used : VersionedReference(org.apache.archiva.model.VersionedReference) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent)

Example 39 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class RepositoryRequestTest method testNativePathBadRequestNull.

@Test
public void testNativePathBadRequestNull() throws Exception {
    ManagedRepositoryContent repository = createManagedRepo("default");
    // Test bad request path (too short)
    try {
        repoRequest.toNativePath(null, repository);
        fail("Should have thrown an exception about an null request.");
    } catch (LayoutException e) {
    // expected path.
    }
}
Also used : LayoutException(org.apache.archiva.repository.LayoutException) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Example 40 with ManagedRepositoryContent

use of org.apache.archiva.repository.ManagedRepositoryContent in project archiva by apache.

the class RepositoryRequestTest method testToNativePathArtifactDefaultToDefaultDualExtension.

/**
 * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
 */
@Test
public void testToNativePathArtifactDefaultToDefaultDualExtension() throws Exception {
    ManagedRepositoryContent repository = createManagedRepo("default");
    // Test (artifact) default to default - dual extension
    assertEquals("org/project/example-presentation/3.2/example-presentation-3.2.xml.zip", repoRequest.toNativePath("org/project/example-presentation/3.2/example-presentation-3.2.xml.zip", repository));
}
Also used : ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) Test(org.junit.Test)

Aggregations

ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)41 Path (java.nio.file.Path)16 Test (org.junit.Test)13 RepositoryException (org.apache.archiva.repository.RepositoryException)12 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)11 DavException (org.apache.jackrabbit.webdav.DavException)10 ArrayList (java.util.ArrayList)9 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)9 IOException (java.io.IOException)8 ArtifactReference (org.apache.archiva.model.ArtifactReference)8 VersionedReference (org.apache.archiva.model.VersionedReference)7 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)6 LayoutException (org.apache.archiva.repository.LayoutException)6 RepositoryContentProvider (org.apache.archiva.repository.RepositoryContentProvider)6 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)6 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)5 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)5 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)5 ManagedRepository (org.apache.archiva.repository.ManagedRepository)5 MavenManagedRepository (org.apache.archiva.repository.maven2.MavenManagedRepository)5