use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method testGetArtifactsTimestampedSnapshots.
@Test
public void testGetArtifactsTimestampedSnapshots() throws Exception {
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(storage.readArtifactsMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT", ALL)));
assertEquals(1, artifacts.size());
ArtifactMetadata artifact = artifacts.get(0);
assertEquals("missing-metadata-1.0-20091101.112233-1.pom", artifact.getId());
assertEquals("com.example.test", artifact.getNamespace());
assertEquals("missing-metadata", artifact.getProject());
assertEquals("1.0-20091101.112233-1", artifact.getVersion());
assertEquals(TEST_REPO_ID, artifact.getRepositoryId());
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method testModelWithJdkProfileActivation.
@Test
public void testModelWithJdkProfileActivation() throws Exception {
ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest().repositoryId(TEST_REPO_ID).namespace("org.apache.maven").projectId("maven-archiver").projectVersion("2.4.1");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(readMetadataRequest);
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method testGetArtifactMetadata.
@Test
public void testGetArtifactMetadata() throws Exception {
Collection<ArtifactMetadata> springArtifacts = storage.readArtifactsMetadata(new ReadMetadataRequest(TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL));
List<ArtifactMetadata> artifacts = new ArrayList<>(springArtifacts);
Collections.sort(artifacts, new Comparator<ArtifactMetadata>() {
@Override
public int compare(ArtifactMetadata o1, ArtifactMetadata o2) {
return o1.getId().compareTo(o2.getId());
}
});
assertEquals(3, artifacts.size());
ArtifactMetadata artifactMetadata = artifacts.get(0);
assertEquals("plexus-spring-1.2-sources.jar", artifactMetadata.getId());
MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(0, facet.getBuildNumber());
assertNull(facet.getTimestamp());
assertEquals("sources", facet.getClassifier());
assertEquals("java-source", facet.getType());
artifactMetadata = artifacts.get(1);
assertEquals("plexus-spring-1.2.jar", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(0, facet.getBuildNumber());
assertNull(facet.getTimestamp());
assertNull(facet.getClassifier());
assertEquals("jar", facet.getType());
artifactMetadata = artifacts.get(2);
assertEquals("plexus-spring-1.2.pom", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(0, facet.getBuildNumber());
assertNull(facet.getTimestamp());
assertNull(facet.getClassifier());
assertEquals("pom", facet.getType());
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata.
@Test
public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata() throws Exception {
try {
storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT"));
fail("Should not be found");
} catch (RepositoryStorageMetadataNotFoundException e) {
assertEquals("missing-pom", e.getId());
}
}
use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method testGetArtifactMetadataSnapshotsMRM1859.
@Test
public void testGetArtifactMetadataSnapshotsMRM1859() throws Exception {
Path repoDir = Paths.get("target/test-repository/com/example/test/test-artifact/1.0-SNAPSHOT");
URL url = Thread.currentThread().getContextClassLoader().getResource("resolver-status.properties");
Path resFile = Paths.get(url.toURI());
Path destFile = repoDir.resolve(resFile.getFileName());
Files.copy(resFile, destFile, StandardCopyOption.REPLACE_EXISTING);
URL url2 = Thread.currentThread().getContextClassLoader().getResource("test01.properties");
Path resFile2 = Paths.get(url2.toURI());
Path destFile2 = repoDir.resolve(resFile2.getFileName());
Files.copy(resFile2, destFile2, StandardCopyOption.REPLACE_EXISTING);
try {
Collection<ArtifactMetadata> testArtifacts = storage.readArtifactsMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact", "1.0-SNAPSHOT", ALL));
List<ArtifactMetadata> artifacts = new ArrayList<>(testArtifacts);
Collections.sort(artifacts, new Comparator<ArtifactMetadata>() {
@Override
public int compare(ArtifactMetadata o1, ArtifactMetadata o2) {
return o1.getId().compareTo(o2.getId());
}
});
assertEquals(6, artifacts.size());
ArtifactMetadata artifactMetadata = artifacts.get(0);
assertEquals("test-artifact-1.0-20100308.230825-1.jar", artifactMetadata.getId());
MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(1, facet.getBuildNumber());
assertEquals("20100308.230825", facet.getTimestamp());
assertNull(facet.getClassifier());
assertEquals("jar", facet.getType());
artifactMetadata = artifacts.get(1);
assertEquals("test-artifact-1.0-20100308.230825-1.pom", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(1, facet.getBuildNumber());
assertEquals("20100308.230825", facet.getTimestamp());
assertNull(facet.getClassifier());
assertEquals("pom", facet.getType());
artifactMetadata = artifacts.get(2);
assertEquals("test-artifact-1.0-20100310.014828-2-javadoc.jar", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(2, facet.getBuildNumber());
assertEquals("20100310.014828", facet.getTimestamp());
assertEquals("javadoc", facet.getClassifier());
assertEquals("javadoc", facet.getType());
artifactMetadata = artifacts.get(3);
assertEquals("test-artifact-1.0-20100310.014828-2-sources.jar", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(2, facet.getBuildNumber());
assertEquals("20100310.014828", facet.getTimestamp());
assertEquals("sources", facet.getClassifier());
assertEquals("java-source", facet.getType());
artifactMetadata = artifacts.get(4);
assertEquals("test-artifact-1.0-20100310.014828-2.jar", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(2, facet.getBuildNumber());
assertEquals("20100310.014828", facet.getTimestamp());
assertNull(facet.getClassifier());
assertEquals("jar", facet.getType());
artifactMetadata = artifacts.get(5);
assertEquals("test-artifact-1.0-20100310.014828-2.pom", artifactMetadata.getId());
facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
assertEquals(2, facet.getBuildNumber());
assertEquals("20100310.014828", facet.getTimestamp());
assertNull(facet.getClassifier());
assertEquals("pom", facet.getType());
} finally {
Files.delete(destFile);
Files.delete(destFile2);
}
}
Aggregations