Search in sources :

Example 11 with Versioning

use of org.apache.maven.artifact.repository.metadata.Versioning in project indy by Commonjava.

the class MavenMetadataMergerTest method mergeWhenOneTransferIsMissing.

@Test
public void mergeWhenOneTransferIsMissing() throws Exception {
    String path = "org/foo/bar/maven-metadata.xml";
    HostedRepository h1 = new HostedRepository("test-hosted-1");
    HostedRepository h2 = new HostedRepository("test-hosted-2");
    Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
    initTestData(t1, VERSION_META + "simple-1.xml");
    Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
    Group g = new Group("test-group", h1.getKey(), h2.getKey());
    List<Transfer> sources = Arrays.asList(t1, t2);
    byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
    Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
    assertThat(merged.getGroupId(), equalTo("org.foo"));
    assertThat(merged.getArtifactId(), equalTo("bar"));
    Versioning versioning = merged.getVersioning();
    assertThat(versioning, notNullValue());
    List<String> versions = versioning.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.size(), equalTo(1));
    assertThat(versioning.getRelease(), equalTo("1.0"));
    assertThat(versioning.getLatest(), equalTo("1.0"));
    int idx = 0;
    assertThat(versions.get(idx), equalTo("1.0"));
}
Also used : Group(org.commonjava.indy.model.core.Group) MetadataXpp3Reader(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) Versioning(org.apache.maven.artifact.repository.metadata.Versioning) ByteArrayInputStream(java.io.ByteArrayInputStream) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 12 with Versioning

use of org.apache.maven.artifact.repository.metadata.Versioning in project indy by Commonjava.

the class MavenMetadataMergerTest method mergeWhenOneTransferIsInvalidXml.

@Test
public void mergeWhenOneTransferIsInvalidXml() throws Exception {
    String path = "org/foo/bar/maven-metadata.xml";
    HostedRepository h1 = new HostedRepository("test-hosted-1");
    HostedRepository h2 = new HostedRepository("test-hosted-2");
    Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
    initTestData(t1, VERSION_META + "simple-1.xml");
    Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
    initTestData(t2, VERSION_META + "invalid.xml");
    Group g = new Group("test-group", h1.getKey(), h2.getKey());
    List<Transfer> sources = Arrays.asList(t1, t2);
    byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
    Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
    assertThat(merged.getGroupId(), equalTo("org.foo"));
    assertThat(merged.getArtifactId(), equalTo("bar"));
    Versioning versioning = merged.getVersioning();
    assertThat(versioning, notNullValue());
    List<String> versions = versioning.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.size(), equalTo(1));
    assertThat(versioning.getRelease(), equalTo("1.0"));
    assertThat(versioning.getLatest(), equalTo("1.0"));
    int idx = 0;
    assertThat(versions.get(idx), equalTo("1.0"));
}
Also used : Group(org.commonjava.indy.model.core.Group) MetadataXpp3Reader(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) Versioning(org.apache.maven.artifact.repository.metadata.Versioning) ByteArrayInputStream(java.io.ByteArrayInputStream) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 13 with Versioning

use of org.apache.maven.artifact.repository.metadata.Versioning in project indy by Commonjava.

the class KojiMavenMetadataProviderTest method retrieveVersionMetadataWithVerification.

@Test
public void retrieveVersionMetadataWithVerification() throws Exception {
    initKojiClient("simple-metadata-verify", true);
    Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
    assertThat(metadata, notNullValue());
    StringWriter sw = new StringWriter();
    new MetadataXpp3Writer().write(sw, metadata);
    System.out.println(sw.toString());
    Versioning versioning = metadata.getVersioning();
    assertThat(versioning, notNullValue());
    assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
    assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
    List<String> versions = versioning.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.size(), equalTo(2));
    int idx = 0;
    assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
    idx++;
    assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 14 with Versioning

use of org.apache.maven.artifact.repository.metadata.Versioning in project indy by Commonjava.

the class KojiMavenMetadataProviderTest method retrieveVersionMetadataWithTagWhitelist.

@Test
public void retrieveVersionMetadataWithTagWhitelist() throws Exception {
    kojiConfig.setTagPatternsEnabled(true);
    kojiConfig.setTagPatterns(Collections.singletonList("jb-.+"));
    initKojiClient("whitelisted-tags-metadata-generate", false);
    Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
    assertThat(metadata, notNullValue());
    StringWriter sw = new StringWriter();
    new MetadataXpp3Writer().write(sw, metadata);
    System.out.println(sw.toString());
    Versioning versioning = metadata.getVersioning();
    assertThat(versioning, notNullValue());
    assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
    assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
    List<String> versions = versioning.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.size(), equalTo(2));
    int idx = 0;
    assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
    idx++;
    assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 15 with Versioning

use of org.apache.maven.artifact.repository.metadata.Versioning in project indy by Commonjava.

the class KojiMavenMetadataProviderTest method retrieveVersionMetadata.

@Test
public void retrieveVersionMetadata() throws Exception {
    initKojiClient("simple-metadata-generate", false);
    Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
    assertThat(metadata, notNullValue());
    StringWriter sw = new StringWriter();
    new MetadataXpp3Writer().write(sw, metadata);
    System.out.println(sw.toString());
    Versioning versioning = metadata.getVersioning();
    assertThat(versioning, notNullValue());
    assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
    assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
    List<String> versions = versioning.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.size(), equalTo(2));
    int idx = 0;
    assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
    idx++;
    assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Aggregations

Metadata (org.apache.maven.artifact.repository.metadata.Metadata)18 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)18 Test (org.junit.Test)11 MetadataXpp3Writer (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer)8 MetadataXpp3Reader (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader)7 StoreKey (org.commonjava.indy.model.core.StoreKey)7 Transfer (org.commonjava.maven.galley.model.Transfer)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Group (org.commonjava.indy.model.core.Group)6 HostedRepository (org.commonjava.indy.model.core.HostedRepository)6 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)6 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)6 StringWriter (java.io.StringWriter)5 TransferMetadata (org.commonjava.maven.galley.io.checksum.TransferMetadata)4 File (java.io.File)3 Date (java.util.Date)3 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)3 SnapshotVersion (org.apache.maven.artifact.repository.metadata.SnapshotVersion)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 KojiClient (com.redhat.red.build.koji.KojiClient)1