use of org.apache.maven.artifact.repository.metadata.Metadata 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"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata 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"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata 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"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata 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"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata 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"));
}
Aggregations