Search in sources :

Example 36 with ArchivaRepositoryMetadata

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

the class RepositoryMetadataWriterTest method testWriteSimple.

@Test
public void testWriteSimple() throws Exception {
    Path defaultRepoDir = Paths.get("src/test/repositories/default-repository");
    Path expectedFile = defaultRepoDir.resolve("org/apache/maven/shared/maven-downloader/maven-metadata.xml");
    String expectedContent = org.apache.archiva.common.utils.FileUtils.readFileToString(expectedFile, Charset.defaultCharset());
    ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
    metadata.setGroupId("org.apache.maven.shared");
    metadata.setArtifactId("maven-downloader");
    metadata.setVersion("1.0");
    metadata.setReleasedVersion("1.1");
    metadata.getAvailableVersions().add("1.0");
    metadata.getAvailableVersions().add("1.1");
    metadata.setLastUpdated("20061212214311");
    StringWriter actual = new StringWriter();
    RepositoryMetadataWriter.write(metadata, actual);
    XMLAssert.assertXMLEqual("XML Contents", expectedContent, actual.toString());
}
Also used : Path(java.nio.file.Path) StringWriter(java.io.StringWriter) ArchivaRepositoryMetadata(org.apache.archiva.model.ArchivaRepositoryMetadata) Test(org.junit.Test)

Example 37 with ArchivaRepositoryMetadata

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

the class MavenRepositoryMetadataReaderTest method testProjectVersionMetadata.

@Test
public void testProjectVersionMetadata() throws XMLException {
    Path metadataFile = defaultRepoDir.resolve("org/apache/apache/5-SNAPSHOT/maven-metadata.xml");
    ArchivaRepositoryMetadata metadata = MavenMetadataReader.read(metadataFile);
    assertNotNull(metadata);
    assertEquals("org.apache", metadata.getGroupId());
    assertEquals("apache", metadata.getArtifactId());
    assertNull(metadata.getReleasedVersion());
    assertNull(metadata.getLatestVersion());
    assertTrue(metadata.getAvailableVersions().isEmpty());
    assertNotNull(metadata.getSnapshotVersion());
    assertEquals("20080801.151215", metadata.getSnapshotVersion().getTimestamp());
    assertEquals(1, metadata.getSnapshotVersion().getBuildNumber());
    assertEquals("20080801151215", metadata.getLastUpdated());
}
Also used : Path(java.nio.file.Path) ArchivaRepositoryMetadata(org.apache.archiva.model.ArchivaRepositoryMetadata) Test(org.junit.Test)

Aggregations

ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)37 Path (java.nio.file.Path)29 StringWriter (java.io.StringWriter)8 XMLException (org.apache.archiva.xml.XMLException)8 ArrayList (java.util.ArrayList)7 SnapshotVersion (org.apache.archiva.model.SnapshotVersion)7 Test (org.junit.Test)7 IOException (java.io.IOException)5 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)5 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)4 Plugin (org.apache.archiva.model.Plugin)4 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)4 Date (java.util.Date)3 ChecksummedFile (org.apache.archiva.checksum.ChecksummedFile)3 ArtifactReference (org.apache.archiva.model.ArtifactReference)3 RepositoryException (org.apache.archiva.repository.RepositoryException)3 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 TimeZone (java.util.TimeZone)2