Search in sources :

Example 6 with Group

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));
}
Also used : Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 7 with Group

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));
}
Also used : Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 8 with Group

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()));
}
Also used : Group(org.commonjava.indy.model.core.Group) InputStream(java.io.InputStream) EProjectDirectRelationships(org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Example 9 with Group

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"));
}
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 10 with Group

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"));
}
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)

Aggregations

Group (org.commonjava.indy.model.core.Group)211 Test (org.junit.Test)111 HostedRepository (org.commonjava.indy.model.core.HostedRepository)89 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)82 StoreKey (org.commonjava.indy.model.core.StoreKey)76 ByteArrayInputStream (java.io.ByteArrayInputStream)67 InputStream (java.io.InputStream)62 IndyDataException (org.commonjava.indy.data.IndyDataException)44 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)42 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)42 Transfer (org.commonjava.maven.galley.model.Transfer)31 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)30 Logger (org.slf4j.Logger)30 Before (org.junit.Before)29 StoreDataManager (org.commonjava.indy.data.StoreDataManager)27 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)27 HashSet (java.util.HashSet)26 ArrayList (java.util.ArrayList)25 List (java.util.List)22 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)22