use of org.apache.archiva.maven.metadata.MavenMetadataReader in project archiva by apache.
the class MavenRepositoryMetadataReaderTest method testProjectMetadata.
@Test
public void testProjectMetadata() throws RepositoryMetadataException {
Path metadataFile = defaultRepoDir.resolve("org/apache/maven/shared/maven-downloader/maven-metadata.xml");
MavenMetadataReader metadataReader = new MavenMetadataReader();
ArchivaRepositoryMetadata metadata = metadataReader.read(metadataFile);
assertNotNull(metadata);
assertEquals("org.apache.maven.shared", metadata.getGroupId());
assertEquals("maven-downloader", metadata.getArtifactId());
assertEquals("1.1", metadata.getReleasedVersion());
assertNull(metadata.getLatestVersion());
assertEquals(Arrays.asList("1.0", "1.1"), metadata.getAvailableVersions());
assertNull(metadata.getSnapshotVersion());
assertEquals("20061212214311", metadata.getLastUpdated());
}
use of org.apache.archiva.maven.metadata.MavenMetadataReader in project archiva by apache.
the class MavenContentHelperTest method getArtifactVersion.
@Test
void getArtifactVersion() throws IOException, URISyntaxException {
MavenContentHelper mavenContentHelper = new MavenContentHelper();
MavenMetadataReader reader = new MavenMetadataReader();
mavenContentHelper.setMetadataReader(reader);
Path testRepoPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource("repositories/metadata-repository").toURI());
FilesystemStorage storage = new FilesystemStorage(testRepoPath, new DefaultFileLockManager());
assertArtifactVersion(mavenContentHelper, "1.0-alpha-11-SNAPSHOT", storage.getAsset("org/apache/archiva/metadata/tests/snap_shots_1/1.0-alpha-11-SNAPSHOT"), "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-SNAPSHOT");
assertArtifactVersion(mavenContentHelper, "1.0-alpha-11-20070316.175232-11", storage.getAsset("org/apache/archiva/metadata/tests/snap_shots_a/1.0-alpha-11-SNAPSHOT"), "", "1.0-alpha-11-SNAPSHOT");
assertArtifactVersion(mavenContentHelper, "2.2-20070316.153953-10", storage.getAsset("org/apache/archiva/metadata/tests/snap_shots_b/2.2-SNAPSHOT"), "", "2.2-SNAPSHOT");
}
use of org.apache.archiva.maven.metadata.MavenMetadataReader in project archiva by apache.
the class RepositoryMetadataReaderTest method testLoadSimple.
@Test
public void testLoadSimple() throws RepositoryMetadataException {
Path defaultRepoDir = getRepositoryPath("default-repository");
Path metadataFile = defaultRepoDir.resolve("org/apache/maven/shared/maven-downloader/maven-metadata.xml");
MavenMetadataReader metadataReader = new MavenMetadataReader();
ArchivaRepositoryMetadata metadata = metadataReader.read(metadataFile);
assertNotNull(metadata);
assertEquals("Group Id", "org.apache.maven.shared", metadata.getGroupId());
assertEquals("Artifact Id", "maven-downloader", metadata.getArtifactId());
assertEquals("Released Version", "1.1", metadata.getReleasedVersion());
assertEquals("List of Available Versions", 2, metadata.getAvailableVersions().size());
assertTrue("Available version 1.0", metadata.getAvailableVersions().contains("1.0"));
assertTrue("Available version 1.1", metadata.getAvailableVersions().contains("1.1"));
}
use of org.apache.archiva.maven.metadata.MavenMetadataReader in project archiva by apache.
the class RepositoryMetadataReaderTest method testLoadComplex.
@Test
public void testLoadComplex() throws RepositoryMetadataException {
Path defaultRepoDir = getRepositoryPath("default-repository");
Path metadataFile = defaultRepoDir.resolve("org/apache/maven/samplejar/maven-metadata.xml");
MavenMetadataReader metadataReader = new MavenMetadataReader();
ArchivaRepositoryMetadata metadata = metadataReader.read(metadataFile);
assertNotNull(metadata);
assertEquals("Group Id", "org.apache.maven", metadata.getGroupId());
assertEquals("Artifact Id", "samplejar", metadata.getArtifactId());
assertEquals("Released Version", "2.0", metadata.getReleasedVersion());
assertEquals("Latest Version", "6.0-SNAPSHOT", metadata.getLatestVersion());
assertEquals("List of Available Versions", 18, metadata.getAvailableVersions().size());
assertTrue("Available version 6.0-20060311.183228-10", metadata.getAvailableVersions().contains("6.0-20060311.183228-10"));
assertTrue("Available version 6.0-SNAPSHOT", metadata.getAvailableVersions().contains("6.0-SNAPSHOT"));
}
use of org.apache.archiva.maven.metadata.MavenMetadataReader in project archiva by apache.
the class MavenContentHelperTest method getLatestArtifactSnapshotVersion.
@Test
void getLatestArtifactSnapshotVersion() throws URISyntaxException, IOException {
MavenContentHelper mavenContentHelper = new MavenContentHelper();
MavenMetadataReader reader = new MavenMetadataReader();
mavenContentHelper.setMetadataReader(reader);
Path testRepoPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource("repositories/default-repository").toURI());
FilesystemStorage storage = new FilesystemStorage(testRepoPath, new DefaultFileLockManager());
// Directory without metadata file
assertEquals("2.1-20090808.085535-2", mavenContentHelper.getLatestArtifactSnapshotVersion(storage.getAsset("org/apache/archiva/sample-parent/2.1-SNAPSHOT"), "2.1-SNAPSHOT"));
// Directory with metadata file
assertEquals("1.3-20070802.113139-29", mavenContentHelper.getLatestArtifactSnapshotVersion(storage.getAsset("org/apache/axis2/axis2/1.3-SNAPSHOT"), "1.3-SNAPSHOT"));
}
Aggregations