Search in sources :

Example 31 with RemoteRepository

use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.

the class SetBackSettingsManagerTest method settingsForSingleRemoteRepository_NoGroups.

@Test
public void settingsForSingleRemoteRepository_NoGroups() 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 List<String> lines = generateSettings(key);
    assertThat("No repository with id: " + remote.getName() + " found in settings.xml", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
}
Also used : RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 32 with RemoteRepository

use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.

the class SetBackSettingsManagerTest method settingsForSingleRemoteRepository_GenerateDeleteAndProveNonExistent.

@Test
public void settingsForSingleRemoteRepository_GenerateDeleteAndProveNonExistent() 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 List<String> lines = generateSettings(key);
    assertThat("No repository with id: " + remote.getName() + " found in settings.xml", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
    final ArtifactStore store = storeManager.getArtifactStore(key);
    manager.deleteStoreSettings(store);
    assertThat("Settings.xml for: " + key + " should have been deleted!", manager.getSetBackSettings(key), nullValue());
}
Also used : ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 33 with RemoteRepository

use of org.commonjava.indy.model.core.RemoteRepository 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 34 with RemoteRepository

use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.

the class PomDownloadListenerTest method run.

@Test
public void run() throws Exception {
    final String repo1 = "repo1";
    server.expect(server.formatUrl(repo1, path), 200, content);
    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    client.stores().create(remote1, "adding remote", RemoteRepository.class);
    try (InputStream is = client.content().get(remote, repo1, path)) {
        assertThat(is, notNullValue());
        String s = IOUtils.toString(is);
        assertThat(s, equalTo(content));
    }
    waitForEventPropagation();
    boolean exists = client.content().exists(remote, repo1, pathRel, true);
    assertThat(exists, equalTo(true));
    // check .rel content is not empty
    InputStream ris = client.content().get(remote, repo1, pathRel);
    String rel = IOUtils.toString(ris);
    logger.debug(">>> " + rel);
    assertThat(StringUtils.isNotEmpty(rel), equalTo(true));
}
Also used : InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Example 35 with RemoteRepository

use of org.commonjava.indy.model.core.RemoteRepository 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)

Aggregations

RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)149 Test (org.junit.Test)99 InputStream (java.io.InputStream)52 Group (org.commonjava.indy.model.core.Group)48 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)32 StoreKey (org.commonjava.indy.model.core.StoreKey)31 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)27 ByteArrayInputStream (java.io.ByteArrayInputStream)22 File (java.io.File)17 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)17 HostedRepository (org.commonjava.indy.model.core.HostedRepository)17 PathInfo (org.commonjava.indy.client.core.helper.PathInfo)16 IndyDataException (org.commonjava.indy.data.IndyDataException)14 Before (org.junit.Before)13 Category (org.junit.experimental.categories.Category)12 Date (java.util.Date)10 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)10 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)9 HttpGet (org.apache.http.client.methods.HttpGet)9