use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForGroup_SingleMemberRemote.
@Test
public void settingsForGroup_SingleMemberRemote() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
store(remote);
final StoreKey remoteKey = remote.getKey();
final Group group = new Group(MAVEN_PKG_KEY, "test-group", remoteKey);
store(group);
assertThat(readSettings(group.getKey(), false), equalTo(null));
final List<String> lines = generateSettings(group.getKey());
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for remote!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForSingleRemoteRepository_GenerateSpawnsGroupGeneration.
@Test
public void settingsForSingleRemoteRepository_GenerateSpawnsGroupGeneration() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
store(remote);
final StoreKey key = remote.getKey();
final Group group = new Group(MAVEN_PKG_KEY, "test-group", key);
store(group);
assertThat(readSettings(group.getKey(), false), equalTo(null));
List<String> lines = generateSettings(key);
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for remote!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
lines = readSettings(group.getKey(), true);
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for group!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class PomDownloadSimpleDepTest method run.
@Test
public void run() throws Exception {
String depPom = readTestResource(repo + "/" + pathDep);
server.expect(server.formatUrl(repo1, pathDep), 200, depPom);
String consumerPom = readTestResource(repo + "/" + pathConsumer);
server.expect(server.formatUrl(repo1, pathConsumer), 200, consumerPom);
// Create remote repository
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
client.stores().create(remote1, "adding remote1", RemoteRepository.class);
// Add to a group
client.stores().create(new Group(group1, remote1.getKey()), "adding group", Group.class);
// Get consumer pom via group
InputStream is = client.content().get(group, group1, pathConsumer);
String s = IOUtils.toString(is);
logger.debug(">>> " + s);
assertThat(s, equalTo(consumerPom));
waitForEventPropagation();
boolean exists = false;
// Check consumer pom exists on group
exists = client.content().exists(group, group1, pathConsumer, true);
assertThat(exists, equalTo(true));
// Check consumer rel exists on group
exists = client.content().exists(group, group1, pathConsumerRel);
assertThat(exists, equalTo(true));
// Check consumer rel exists on remote
exists = client.content().exists(remote, repo1, pathConsumerRel, true);
assertThat(exists, equalTo(true));
// Check consumer rel content is not empty via group
InputStream ris = client.content().get(group, group1, pathConsumerRel);
String rel = IOUtils.toString(ris);
logger.debug(">>> " + rel);
assertThat(StringUtils.isNotEmpty(rel), equalTo(true));
// Check consumer rel output
String output = readTestResource(resource + "/output/rel.json");
EProjectDirectRelationships eRel = mapper.readValue(rel, EProjectDirectRelationships.class);
EProjectDirectRelationships eRelOutput = mapper.readValue(output, EProjectDirectRelationships.class);
assertThat(eRel.getDependencies(), equalTo(eRelOutput.getDependencies()));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeTwoFilesWithInterleavedVersions.
@Test
public void mergeTwoFilesWithInterleavedVersions() 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-skip.xml");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "simple-2.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(3));
assertThat(versioning.getRelease(), equalTo("1.2"));
assertThat(versioning.getLatest(), equalTo("1.2"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
idx++;
assertThat(versions.get(idx), equalTo("1.1"));
idx++;
assertThat(versions.get(idx), equalTo("1.2"));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeTwoSimpleVersionMetadataFiles.
@Test
public void mergeTwoSimpleVersionMetadataFiles() 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 + "simple-2.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(2));
assertThat(versioning.getRelease(), equalTo("1.1"));
assertThat(versioning.getLatest(), equalTo("1.1"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
idx++;
assertThat(versions.get(idx), equalTo("1.1"));
}
Aggregations