Search in sources :

Example 31 with Group

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

the class RepoProxyCreatorWithNPMContentRewriteTest method run.

@Test
public void run() throws Exception {
    final String remoteName = String.format("%s-%s", StoreType.group, REPO_NAME);
    final StoreKey remoteKey = new StoreKey(NPMPackageTypeDescriptor.NPM_PKG_KEY, StoreType.remote, remoteName);
    RemoteRepository remote = client.stores().load(remoteKey, RemoteRepository.class);
    assertThat(remote, nullValue());
    final String REMOTE_REPO_PATH = normalize(fixture.getUrl(), "content/npm/remote", remoteName);
    final String GROUP_REPO_PATH = normalize(fixture.getUrl(), "content/npm/group", REPO_NAME);
    final Group group = new Group(PKG_TYPE_NPM, REPO_NAME);
    try (InputStream result = client.content().get(group.getKey(), PATH_ROOT)) {
        assertThat(result, notNullValue());
        final String content = IOUtils.toString(result);
        logger.debug("NPM Rewrite content: {}", content);
        assertThat(expectRepoUrlCountMatch, equalTo(StringUtils.countMatches(content, GROUP_REPO_PATH)));
        assertThat(content.contains(REMOTE_REPO_PATH), equalTo(false));
    }
    remote = client.stores().load(remoteKey, RemoteRepository.class);
    assertThat(remote, notNullValue());
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 32 with Group

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

the class GroupContentCopiedEarlierInMembershipIsReturnedTest method setupStores.

@Before
public void setupStores() throws IndyClientException, UnsupportedEncodingException {
    String changelog = "test setup";
    repoX = client.stores().create(new HostedRepository(REPO_X), changelog, HostedRepository.class);
    repoY = client.stores().create(new HostedRepository(REPO_Y), changelog, HostedRepository.class);
    groupA = client.stores().create(new Group(GROUP_A, repoX.getKey()), changelog, Group.class);
    groupB = client.stores().create(new Group(GROUP_B, repoY.getKey(), groupA.getKey()), changelog, Group.class);
    client.content().store(repoX.getKey(), PATH, new ByteArrayInputStream(CONTENT_1.getBytes("UTF-8")));
    content2 = CONTENT_2.getBytes("UTF-8");
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 33 with Group

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

the class GroupHttpHeadersFromSameRepoAsPomTest method setupStores.

@Before
public void setupStores() throws Exception {
    String changelog = "test setup";
    repoX = client.stores().create(new RemoteRepository(REPO_X, server.formatUrl(REPO_X)), changelog, RemoteRepository.class);
    repoY = client.stores().create(new RemoteRepository(REPO_Y, server.formatUrl(REPO_Y)), changelog, RemoteRepository.class);
    content2 = CONTENT_2.getBytes("UTF-8");
    server.expect(server.formatUrl(REPO_X, PATH), 200, CONTENT_1);
    server.expect(server.formatUrl(REPO_Y, PATH), 200, new ByteArrayInputStream(content2));
    groupA = client.stores().create(new Group(GROUP_A, repoX.getKey(), repoY.getKey()), changelog, Group.class);
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Before(org.junit.Before)

Example 34 with Group

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

the class GroupIgnoresDisabledRemoteRepositoryTest method run.

@Test
public void run() throws Exception {
    final String repo1 = "repo1";
    final String repo2 = "repo2";
    final String path = "path/to/test.txt";
    String disabledContent = "This is disabled.";
    String enabledContent = "This is enabled.";
    server.expect(server.formatUrl(repo1, path), 200, disabledContent);
    server.expect(server.formatUrl(repo2, path), 200, enabledContent);
    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    remote1.setDisabled(true);
    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  "));
    final InputStream stream = client.content().get(group, g.getName(), path);
    assertThat(stream, notNullValue());
    final String content = IOUtils.toString(stream);
    assertThat(content, equalTo(enabledContent));
    stream.close();
}
Also used : Group(org.commonjava.indy.model.core.Group) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 35 with Group

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

the class GroupMetadataMergeInfoGenTest method run.

@Test
public void run() throws Exception {
    final String repoA = "hostedA";
    final String repoB = "hostedB";
    final String repoC = "hostedC";
    final String path = "org/foo/bar/maven-metadata.xml";
    /* @formatter:off */
    final String repoAContent = "<?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>20150721164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    /* @formatter:off */
    final String repoBContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>2.0</latest>\n" + "    <release>2.0</release>\n" + "    <versions>\n" + "      <version>2.0</version>\n" + "    </versions>\n" + "    <lastUpdated>20160722164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    /* @formatter:off */
    final String repoCContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + "  <groupId>org.foo</groupId>\n" + "  <artifactId>bar</artifactId>\n" + "  <versioning>\n" + "    <latest>3.0</latest>\n" + "    <release>3.0</release>\n" + "    <versions>\n" + "      <version>3.0</version>\n" + "    </versions>\n" + "    <lastUpdated>20160723164334</lastUpdated>\n" + "  </versioning>\n" + "</metadata>\n";
    /* @formatter:on */
    HostedRepository hostedA = createHostedAndStorePath(repoA, path, repoAContent);
    HostedRepository hostedB = createHostedAndStorePath(repoB, path, repoBContent);
    HostedRepository hostedC = createHostedAndStorePath(repoC, path, repoCContent);
    Group g = new Group("test", hostedA.getKey());
    g = client.stores().create(g, "adding group", Group.class);
    try (final InputStream stream = client.content().get(group, g.getName(), path)) {
        System.out.println(IOUtils.toString(stream));
    }
    assertInfoContent(g, path, "maven:hosted:hostedA\n");
    g.addConstituent(hostedB.getKey());
    g = updateAndRetrieve(g, "adding group", path);
    assertInfoContent(g, path, "maven:hosted:hostedA\nmaven:hosted:hostedB\n");
    g.removeConstituent(hostedA.getKey());
    g = updateAndRetrieve(g, "removing group", path);
    assertInfoContent(g, path, "maven:hosted:hostedB\n");
    g.addConstituent(hostedC.getKey());
    g = updateAndRetrieve(g, "adding group", path);
    assertInfoContent(g, path, "maven:hosted:hostedB\nmaven:hosted:hostedC\n");
    hostedB.setDisabled(true);
    client.stores().update(hostedB, "disabled");
    try (final InputStream stream = client.content().get(group, g.getName(), path)) {
        System.out.println(IOUtils.toString(stream));
    }
    assertInfoContent(g, path, "maven:hosted:hostedC\n");
}
Also used : Group(org.commonjava.indy.model.core.Group) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

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