Search in sources :

Example 76 with Group

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

the class RetrieveFileFromGroupAndVerifyInTrackingReportTest method run.

@Test
public void run() throws Exception {
    final String trackingId = newName();
    final String repoId = "repo";
    final String groupId = "group";
    final String path = "/path/to/foo.class";
    final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
    server.expect(server.formatUrl(repoId, path), 200, stream);
    RemoteRepository rr = new RemoteRepository(repoId, server.formatUrl(repoId));
    rr = client.stores().create(rr, "adding test remote", RemoteRepository.class);
    Group g = new Group(groupId, rr.getKey());
    g = client.stores().create(g, "Adding test group", Group.class);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final InputStream in = client.module(IndyFoloContentClientModule.class).get(trackingId, group, groupId, path);
    IOUtils.copy(in, baos);
    in.close();
    final byte[] bytes = baos.toByteArray();
    final String md5 = md5Hex(bytes);
    final String sha256 = sha256Hex(bytes);
    assertThat(md5, equalTo(DigestUtils.md5Hex(bytes)));
    assertThat(sha256, equalTo(DigestUtils.sha256Hex(bytes)));
    assertThat(client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId), equalTo(true));
    final TrackedContentDTO report = client.module(IndyFoloAdminClientModule.class).getTrackingReport(trackingId);
    assertThat(report, notNullValue());
    final Set<TrackedContentEntryDTO> downloads = report.getDownloads();
    assertThat(downloads, notNullValue());
    assertThat(downloads.size(), equalTo(1));
    final TrackedContentEntryDTO entry = downloads.iterator().next();
    System.out.println(entry);
    assertThat(entry, notNullValue());
    assertThat(entry.getStoreKey(), equalTo(new StoreKey(remote, repoId)));
    assertThat(entry.getPath(), equalTo(path));
    assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(remote, repoId, path)));
    assertThat(entry.getOriginUrl(), equalTo(server.formatUrl(repoId, path)));
    assertThat(entry.getMd5(), equalTo(md5));
    assertThat(entry.getSha256(), equalTo(sha256));
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StoreKey(org.commonjava.indy.model.core.StoreKey) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) ByteArrayInputStream(java.io.ByteArrayInputStream) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) Test(org.junit.Test)

Example 77 with Group

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

the class AbstractNPMFoloContentManagementTest method before.

@Before
public void before() throws Exception {
    final String changelog = "Setup: " + name.getMethodName();
    final HostedRepository hosted = this.client.stores().create(new HostedRepository(PKG_TYPE_NPM, STORE), changelog, HostedRepository.class);
    RemoteRepository npmjs = null;
    final StoreKey npmjsKey = new StoreKey(PKG_TYPE_NPM, remote, NPMJS);
    if (client.stores().exists(npmjsKey)) {
        client.stores().delete(npmjsKey, "removing existing remote:npmjs definition");
    }
    npmjs = client.stores().create(new RemoteRepository(PKG_TYPE_NPM, NPMJS, npmjsServer.getBaseUri()), changelog, RemoteRepository.class);
    Group g;
    final StoreKey publicGrpKey = new StoreKey(PKG_TYPE_NPM, group, PUBLIC);
    if (client.stores().exists(publicGrpKey)) {
        g = client.stores().load(publicGrpKey, Group.class);
    } else {
        g = client.stores().create(new Group(PKG_TYPE_NPM, PUBLIC), changelog, Group.class);
    }
    g.setConstituents(Arrays.asList(hosted.getKey(), npmjs.getKey()));
    client.stores().update(g, changelog);
}
Also used : Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 78 with Group

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

the class GroupMetadataForRemoteSnapshotTest method run.

/* @formatter:on */
@Test
public void run() throws Exception {
    server.expect(server.formatUrl(REMOTE, metadataPath), 200, metadataContent);
    RemoteRepository remote1 = new RemoteRepository(MAVEN_PKG_KEY, REMOTE, server.formatUrl(REMOTE));
    remote1.setAllowSnapshots(true);
    remote1 = client.stores().create(remote1, "remote A", RemoteRepository.class);
    Group g = new Group(MAVEN_PKG_KEY, GROUP, remote1.getKey());
    g = client.stores().create(g, "Create group G", Group.class);
    // Get meta from remote
    try (final InputStream stream = client.content().get(remote1.getKey(), metadataPath)) {
        assertThat(stream, notNullValue());
        String meta = IOUtils.toString(stream);
        logger.debug("Remote A meta >>>>\n" + meta);
    }
    // Get meta from group
    try (final InputStream stream = client.content().get(g.getKey(), metadataPath)) {
        assertThat(stream, notNullValue());
        String meta = IOUtils.toString(stream);
        logger.debug("Group meta >>>>\n" + meta);
        assertEquals(metadataContent, meta);
    }
}
Also used : Group(org.commonjava.indy.model.core.Group) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Example 79 with Group

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

the class RecursiveGroupMetadataClearOnUploadTest method setupRepos.

@Before
public void setupRepos() throws IndyClientException, UnsupportedEncodingException {
    String change = "Setup test";
    hostedRepo = client.stores().create(new HostedRepository(MAVEN_PKG_KEY, hostedName), change, HostedRepository.class);
    groupA = client.stores().create(new Group(MAVEN_PKG_KEY, groupAName, hostedRepo.getKey()), change, Group.class);
    groupB = client.stores().create(new Group(MAVEN_PKG_KEY, groupBName, groupA.getKey()), change, Group.class);
    client.content().store(hostedRepo.getKey(), path, new ByteArrayInputStream(firstPassContent.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 80 with Group

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

the class StoreGeneratedMetadataInRemoteTest method run.

@Test
public void run() throws Exception {
    server.expect(server.formatUrl(REMOTE, path_1), 200, pomContent_1);
    RemoteRepository remote1 = new RemoteRepository(MAVEN_PKG_KEY, REMOTE, server.formatUrl(REMOTE));
    remote1 = client.stores().create(remote1, "remote A", RemoteRepository.class);
    HostedRepository hosted1 = client.stores().create(new HostedRepository(MAVEN_PKG_KEY, HOSTED), "hosted B", HostedRepository.class);
    client.content().store(hosted1.getKey(), path_2, new ByteArrayInputStream(pomContent_2.getBytes()));
    client.content().store(hosted1.getKey(), metaPath, new ByteArrayInputStream(metaContent.getBytes()));
    Group g = new Group(MAVEN_PKG_KEY, GROUP, remote1.getKey(), hosted1.getKey());
    g = client.stores().create(g, "group G", Group.class);
    // MUST hit the .pom first. This is needed to populate org/foo/bar/1.0 folder in order to generate metadata.xml
    try (final InputStream stream = client.content().get(remote1.getKey(), path_1)) {
    }
    // Get meta from group. Contains both version 1.0 and 2.0
    try (final InputStream stream = client.content().get(g.getKey(), metaPath)) {
        String meta = IOUtils.toString(stream);
        logger.debug("Group meta >>>>\n" + meta);
        assertTrue(meta.contains("<version>1.0</version>"));
        assertTrue(meta.contains("<version>2.0</version>"));
    }
    // Get meta from remote. Contains version 1.0
    try (final InputStream stream = client.content().get(remote1.getKey(), metaPath)) {
        assertThat(stream, notNullValue());
        String meta = IOUtils.toString(stream);
        logger.debug("Remote A meta >>>>\n" + meta);
        assertTrue(meta.contains("<version>1.0</version>"));
    }
    // Delete remote A
    client.stores().delete(remote1.getKey(), "delete A");
    /*
         * Disable it has same effect

        remote1.setDisabled( true );
        client.stores().update( remote1, "disable A" );
        */
    waitForEventPropagation();
    // Get meta from group again. Contains only version 2.0, no 1.0
    try (final InputStream stream = client.content().get(g.getKey(), metaPath)) {
        assertThat(stream, notNullValue());
        String meta = IOUtils.toString(stream);
        logger.debug("Group meta after deleting A >>>>\n" + meta);
        assertFalse(meta.contains("<version>1.0</version>"));
    }
}
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) HostedRepository(org.commonjava.indy.model.core.HostedRepository) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) 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