Search in sources :

Example 41 with RemoteRepository

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

the class GroupDataManagerTCK method seedRepositoriesForGroupTests.

protected void seedRepositoriesForGroupTests() throws Exception {
    manager = getFixtureProvider().getDataManager();
    manager.storeArtifactStore(new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo1.maven.apache.org/maven2/"), summary, false, false, new EventMetadata());
    manager.storeArtifactStore(new RemoteRepository(MAVEN_PKG_KEY, "repo2", "http://repo1.maven.org/maven2/"), summary, false, false, new EventMetadata());
}
Also used : RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata)

Example 42 with RemoteRepository

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

the class RepositoryDataManagerTCK method createTwoReposAndRetrieveAll.

@Test
public void createTwoReposAndRetrieveAll() throws Exception {
    final StoreDataManager manager = getFixtureProvider().getDataManager();
    final RemoteRepository repo = new RemoteRepository("central", "http://repo1.maven.apache.org/maven2/");
    storeRemoteRepository(repo);
    final RemoteRepository repo2 = new RemoteRepository("test", "http://www.google.com");
    storeRemoteRepository(repo2);
    final List<RemoteRepository> repositories = manager.query().packageType(MAVEN_PKG_KEY).storeType(RemoteRepository.class).getAll();
    assertThat(repositories, notNullValue());
    assertThat(repositories.size(), equalTo(2));
    Collections.sort(repositories, new Comparator<RemoteRepository>() {

        @Override
        public int compare(final RemoteRepository r1, final RemoteRepository r2) {
            return r1.getName().compareTo(r2.getName());
        }
    });
    ArtifactStore r = repositories.get(0);
    assertThat(r.getName(), equalTo(repo.getName()));
    r = repositories.get(1);
    assertThat(r.getName(), equalTo(repo2.getName()));
}
Also used : ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreDataManager(org.commonjava.indy.data.StoreDataManager) Test(org.junit.Test)

Example 43 with RemoteRepository

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

the class ProxyRemoteKojiContentTest method proxyBinaryRemoteKojiArtifact.

@Ignore
@Test
public void proxyBinaryRemoteKojiArtifact() throws Exception {
    final String path = "org/apache/apache/18/apache-18.pom";
    Indy client = new Indy("http://localhost:8080/api", new IndyObjectMapper(Collections.emptySet()), Collections.emptySet()).connect();
    long elapse = getContent("build-x", client, path);
    // the remote store should have been added to brew-binaries group
    StoreListingDTO<RemoteRepository> repos = client.stores().listRemoteRepositories();
    for (RemoteRepository repo : repos.getItems()) {
        logger.debug("Repo " + repo.getName());
        if (repo.getName().startsWith(KOJI_ORIGIN)) {
            logger.debug("Koji repo patterns: " + repo.getPathMaskPatterns());
        }
    }
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) Indy(org.commonjava.indy.client.core.Indy) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 44 with RemoteRepository

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

the class GroupMetaOverlapWithMetaOfHostedReposTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    final String repo1 = "repo1";
    final String repo2 = "repo2";
    final String path = "org/foo/bar/maven-metadata.xml";
    /* @formatter:off */
    final String repo1Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.0</latest>\n" + "    <release>1.0</release>\n" + "    <versions>\n" + "      <version>1.0</version>\n" + "    </versions>\n" + "    <lastUpdated>20150722164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    /* @formatter:off */
    final String repo2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.1</latest>\n" + "    <release>1.1</release>\n" + "    <versions>\n" + "      <version>1.1</version>\n" + "    </versions>\n" + "    <lastUpdated>20150822164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    server.expect(server.formatUrl(repo1, path), 200, repo1Content);
    server.expect(server.formatUrl(repo2, path), 200, repo2Content);
    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
    RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
    remote2 = client.stores().create(remote2, "adding remote", RemoteRepository.class);
    Group g = new Group("test", remote1.getKey(), remote2.getKey());
    g = client.stores().create(g, "adding group", Group.class);
    System.out.printf("\n\nGroup constituents are:\n  %s\n\n", StringUtils.join(g.getConstituents(), "\n  "));
    InputStream stream = client.content().get(group, g.getName(), path);
    assertThat(stream, notNullValue());
    String metadata = IOUtils.toString(stream);
    /* @formatter:off */
    final String groupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.1</latest>\n" + "    <release>1.1</release>\n" + "    <versions>\n" + "      <version>1.0</version>\n" + "      <version>1.1</version>\n" + "    </versions>\n" + "    <lastUpdated>20150822164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    assertThat(metadata, equalTo(groupContent));
    final String hostedRepo = "hostedRepo";
    HostedRepository hostedRepository = new HostedRepository(hostedRepo);
    hostedRepository = client.stores().create(hostedRepository, "adding hosted", HostedRepository.class);
    /* @formatter:off */
    final String hostedMetaContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.2</latest>\n" + "    <release>1.2</release>\n" + "    <versions>\n" + "      <version>1.2</version>\n" + "    </versions>\n" + "    <lastUpdated>20150922164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    client.content().store(hostedRepository.getKey(), path, new ByteArrayInputStream(hostedMetaContent.getBytes("UTF-8")));
    final PathInfo p = client.content().getInfo(hosted, hostedRepo, path);
    assertThat("hosted metadata should exist", p.exists(), equalTo(true));
    g.addConstituent(hostedRepository);
    client.stores().update(g, "add new hosted");
    System.out.printf("\n\nUpdated group constituents are:\n  %s\n\n", StringUtils.join(g.getConstituents(), "\n  "));
    waitForEventPropagation();
    final String gpLevelMetaFilePath = String.format("%s/var/lib/indy/storage/%s-%s/%s", fixture.getBootOptions().getIndyHome(), group.name(), g.getName(), path);
    assertThat("group metadata should be removed after merging", new File(gpLevelMetaFilePath).exists(), equalTo(false));
    stream = client.content().get(group, g.getName(), path);
    assertThat(stream, notNullValue());
    metadata = IOUtils.toString(stream);
    /* @formatter:off */
    final String updGroupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.2</latest>\n" + "    <release>1.2</release>\n" + "    <versions>\n" + "      <version>1.0</version>\n" + "      <version>1.1</version>\n" + "      <version>1.2</version>\n" + "    </versions>\n" + "    <lastUpdated>20150922164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    assertThat(metadata, equalTo(updGroupContent));
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) PathInfo(org.commonjava.indy.client.core.helper.PathInfo) File(java.io.File) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 45 with RemoteRepository

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

the class GroupMetaOverlapWithNestedGroupOfHostRepoMetaTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    final String repo1 = "repo1";
    final String repo2 = "repo2";
    final String path = "org/foo/bar/maven-metadata.xml";
    /* @formatter:off */
    final String repo1Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.0</latest>\n" + "    <release>1.0</release>\n" + "    <versions>\n" + "      <version>1.0</version>\n" + "    </versions>\n" + "    <lastUpdated>20150722164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    /* @formatter:off */
    final String repo2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.1</latest>\n" + "    <release>1.1</release>\n" + "    <versions>\n" + "      <version>1.1</version>\n" + "    </versions>\n" + "    <lastUpdated>20150822164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    server.expect(server.formatUrl(repo1, path), 200, repo1Content);
    server.expect(server.formatUrl(repo2, path), 200, repo2Content);
    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
    RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
    remote2 = client.stores().create(remote2, "adding remote", RemoteRepository.class);
    // constructs 3 level group structure: top -> middle -> bottom
    // and the bottom group contains repo1 and repo2
    Group bottomGroup = new Group("bottom", remote1.getKey(), remote2.getKey());
    bottomGroup = client.stores().create(bottomGroup, "adding bottom group", Group.class);
    System.out.printf("\n\nBottom group constituents are:\n  %s\n\n", StringUtils.join(bottomGroup.getConstituents(), "\n  "));
    Group middleGroup = new Group("middle", bottomGroup.getKey());
    middleGroup = client.stores().create(middleGroup, "adding middle group", Group.class);
    System.out.printf("\n\nMiddle group constituents are:\n  %s\n\n", StringUtils.join(middleGroup.getConstituents(), "\n  "));
    Group topGroup = new Group("top", middleGroup.getKey());
    topGroup = client.stores().create(topGroup, "adding top group", Group.class);
    System.out.printf("\n\nTop group constituents are:\n  %s\n\n", StringUtils.join(topGroup.getConstituents(), "\n  "));
    InputStream stream = client.content().get(group, topGroup.getName(), path);
    assertThat(stream, notNullValue());
    String metadata = IOUtils.toString(stream);
    stream.close();
    /* @formatter:off */
    final String groupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.1</latest>\n" + "    <release>1.1</release>\n" + "    <versions>\n" + "      <version>1.0</version>\n" + "      <version>1.1</version>\n" + "    </versions>\n" + "    <lastUpdated>20150822164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    assertThat(metadata, equalTo(groupContent));
    final String hostedRepo = "hostedRepo";
    HostedRepository hostedRepository = new HostedRepository(hostedRepo);
    hostedRepository = client.stores().create(hostedRepository, "adding hosted", HostedRepository.class);
    /* @formatter:off */
    final String hostedMetaContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.2</latest>\n" + "    <release>1.2</release>\n" + "    <versions>\n" + "      <version>1.2</version>\n" + "    </versions>\n" + "    <lastUpdated>20150922164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    client.content().store(hostedRepository.getKey(), path, new ByteArrayInputStream(hostedMetaContent.getBytes("UTF-8")));
    final PathInfo p = client.content().getInfo(hosted, hostedRepo, path);
    assertThat("hosted metadata should exist", p.exists(), equalTo(true));
    // added hosted repo to bottom group and update
    bottomGroup.addConstituent(hostedRepository);
    client.stores().update(bottomGroup, "add new hosted to bottom");
    System.out.printf("\n\nUpdated bottom group constituents are:\n  %s\n\n", StringUtils.join(bottomGroup.getConstituents(), "\n  "));
    waitForEventPropagation();
    // the top group should reflect the meta file deprecation and re-indexing
    final String gpLevelMetaFilePath = String.format("%s/var/lib/indy/storage/%s-%s/%s", fixture.getBootOptions().getIndyHome(), group.name(), topGroup.getName(), path);
    assertThat("group metadata should be removed after merging", new File(gpLevelMetaFilePath).exists(), equalTo(false));
    stream = client.content().get(group, topGroup.getName(), path);
    assertThat(stream, notNullValue());
    metadata = IOUtils.toString(stream);
    stream.close();
    /* @formatter:off */
    final String updGroupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>1.2</latest>\n" + "    <release>1.2</release>\n" + "    <versions>\n" + "      <version>1.0</version>\n" + "      <version>1.1</version>\n" + "      <version>1.2</version>\n" + "    </versions>\n" + "    <lastUpdated>20150922164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    assertThat(metadata, equalTo(updGroupContent));
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) PathInfo(org.commonjava.indy.client.core.helper.PathInfo) File(java.io.File) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

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