Search in sources :

Example 6 with ProjectReference

use of org.apache.archiva.model.ProjectReference in project archiva by apache.

the class MetadataTransferTest method assertGroupMetadataContents.

private void assertGroupMetadataContents(String requestedResource, String[] expectedPlugins) throws Exception {
    Path actualFile = managedDefaultDir.resolve(requestedResource);
    assertTrue("Snapshot Metadata should exist: " + requestedResource, Files.exists(actualFile));
    ProjectReference actualMetadata = createGroupReference(requestedResource);
    assertGroupMetadata(actualFile, actualMetadata, expectedPlugins);
}
Also used : Path(java.nio.file.Path) ProjectReference(org.apache.archiva.model.ProjectReference)

Example 7 with ProjectReference

use of org.apache.archiva.model.ProjectReference in project archiva by apache.

the class MetadataTransferTest method assertFetchProjectOrGroupFailed.

/**
 * Transfer the metadata file, not expected to succeed.
 *
 * @param requestedResource the requested resource
 * @throws Exception
 */
private void assertFetchProjectOrGroupFailed(String requestedResource) throws Exception {
    Path expectedFile = managedDefaultDir.resolve(requestedResource);
    ProjectReference metadata = createProjectReference(requestedResource);
    Path downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository, managedDefaultRepository.toMetadataPath(metadata)).getFile();
    assertNull(downloadedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ProjectReference(org.apache.archiva.model.ProjectReference)

Example 8 with ProjectReference

use of org.apache.archiva.model.ProjectReference in project archiva by apache.

the class MetadataTransferTest method createGroupReference.

private ProjectReference createGroupReference(String requestedResource) throws RepositoryMetadataException {
    ProjectReference projectReference = createProjectReference(requestedResource);
    projectReference.setGroupId(projectReference.getGroupId() + "." + projectReference.getArtifactId());
    projectReference.setArtifactId(null);
    return projectReference;
}
Also used : ProjectReference(org.apache.archiva.model.ProjectReference)

Example 9 with ProjectReference

use of org.apache.archiva.model.ProjectReference in project archiva by apache.

the class MetadataTransferTest method assertProjectMetadataContents.

/**
 * Test for the existance of the requestedResource in the default managed repository, and if it exists,
 * does it contain the specified list of expected versions?
 *
 * @param requestedResource the requested resource
 * @throws Exception
 */
private void assertProjectMetadataContents(String requestedResource, String[] expectedVersions, String latestVersion, String releaseVersion) throws Exception {
    Path actualFile = managedDefaultDir.resolve(requestedResource);
    assertTrue(Files.exists(actualFile));
    ProjectReference metadata = createProjectReference(requestedResource);
    // Build expected metadata XML
    StringWriter expectedMetadataXml = new StringWriter();
    ArchivaRepositoryMetadata m = new ArchivaRepositoryMetadata();
    m.setGroupId(metadata.getGroupId());
    m.setArtifactId(metadata.getArtifactId());
    m.setLatestVersion(latestVersion);
    m.setReleasedVersion(releaseVersion);
    if (expectedVersions != null) {
        m.getAvailableVersions().addAll(Arrays.asList(expectedVersions));
    }
    RepositoryMetadataWriter.write(m, expectedMetadataXml);
    // Compare the file to the actual contents.
    assertMetadataEquals(expectedMetadataXml.toString(), actualFile);
}
Also used : Path(java.nio.file.Path) ProjectReference(org.apache.archiva.model.ProjectReference) StringWriter(java.io.StringWriter) ArchivaRepositoryMetadata(org.apache.archiva.model.ArchivaRepositoryMetadata)

Example 10 with ProjectReference

use of org.apache.archiva.model.ProjectReference in project archiva by apache.

the class MetadataTransferTest method assertFetchProjectOrGroup.

/**
 * Transfer the metadata file.
 *
 * @param requestedResource the requested resource
 * @throws Exception
 */
private void assertFetchProjectOrGroup(String requestedResource) throws Exception {
    Path expectedFile = managedDefaultDir.resolve(requestedResource);
    ProjectReference metadata = createProjectReference(requestedResource);
    Path downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository, managedDefaultRepository.toMetadataPath(metadata)).getFile();
    assertNotNull("Should have downloaded a file.", downloadedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ProjectReference(org.apache.archiva.model.ProjectReference)

Aggregations

ProjectReference (org.apache.archiva.model.ProjectReference)20 Path (java.nio.file.Path)11 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 VersionedReference (org.apache.archiva.model.VersionedReference)3 ContentNotFoundException (org.apache.archiva.repository.ContentNotFoundException)3 LayoutException (org.apache.archiva.repository.LayoutException)3 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)2 ArtifactReference (org.apache.archiva.model.ArtifactReference)2 RepositoryException (org.apache.archiva.repository.RepositoryException)2 RepositoryMetadataException (org.apache.archiva.repository.metadata.RepositoryMetadataException)2 URI (java.net.URI)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1