Search in sources :

Example 21 with HostedRepository

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

the class AbstractContentManagementTest method before.

@Before
public void before() throws Exception {
    if (!createStandardTestStructures()) {
        return;
    }
    final String changelog = "Create test structures";
    final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
    client.stores().delete(remote, CENTRAL, "removing to setup test instance");
    final RemoteRepository central = client.stores().create(new RemoteRepository(CENTRAL, server.formatUrl("central")), changelog, RemoteRepository.class);
    Group g;
    if (client.stores().exists(group, PUBLIC)) {
        System.out.println("Loading pre-existing public group.");
        g = client.stores().load(group, PUBLIC, Group.class);
    } else {
        System.out.println("Creating new group 'public'");
        g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
    }
    g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
    client.stores().update(g, changelog);
}
Also used : Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 22 with HostedRepository

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

the class DeleteHostedRepoWithContentTest method run.

@Test
public void run() throws Exception {
    final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "build_perftest-20200229T021845");
    final StoreKey key = repo.getKey();
    final HostedRepository result = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
    assertThat(result.getName(), equalTo(repo.getName()));
    assertThat(result.equals(repo), equalTo(true));
    // Store files
    client.content().store(repo.getKey(), path_1, new ByteArrayInputStream(content.getBytes()));
    client.content().store(repo.getKey(), path_2, new ByteArrayInputStream(content.getBytes()));
    ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), path_1);
    ConcreteResource r2 = new ConcreteResource(LocationUtils.toLocation(repo), path_2);
    // Verify files exist
    assertTrue(cacheProvider.exists(r1));
    assertTrue(cacheProvider.exists(r2));
    // Delete repo with deleteContent flag
    client.stores().delete(key, "Delete", true);
    assertThat(client.stores().exists(key), equalTo(false));
    // Verify files were deleted
    assertFalse(cacheProvider.exists(r1));
    assertFalse(cacheProvider.exists(r2));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) StoreKey(org.commonjava.indy.model.core.StoreKey) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 23 with HostedRepository

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

the class DownloadFromSecondRemoteAfterFirstHostedRepoTest method setupTest.

@Before
public void setupTest() throws Exception {
    String change = "test setup";
    hosted = client.stores().create(new HostedRepository(HOSTED), change, HostedRepository.class);
    remote = client.stores().create(new RemoteRepository(REMOTE, server.formatUrl(REMOTE)), change, RemoteRepository.class);
    group = client.stores().create(new Group(GROUP, hosted.getKey(), remote.getKey()), change, Group.class);
    client.content().store(hosted.getKey(), JAR_PATH, new ByteArrayInputStream("This is the jar".getBytes()));
    server.expect(server.formatUrl(REMOTE, PATH), 200, CONTENT);
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 24 with HostedRepository

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

the class DeleteGroupWithContentTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    // Create hosted repo
    final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "test_1");
    assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
    // Store pom file in hosted repo
    client.content().store(repo.getKey(), pomPath, new ByteArrayInputStream(pomContent.getBytes()));
    // Generate metadata file in hosted repo
    try (InputStream in = client.content().get(repo.getKey(), metadataPath)) {
        IOUtils.toString(in);
    }
    // Verify the hosted meta file exists
    ConcreteResource r_meta_hosted = new ConcreteResource(LocationUtils.toLocation(repo), metadataPath);
    assertTrue(cacheProvider.exists(r_meta_hosted));
    // Create group with hosted member
    final Group group = new Group(MAVEN_PKG_KEY, "test_1", repo.getKey());
    assertThat(client.stores().create(group, name.getMethodName(), Group.class), notNullValue());
    // Generate group metadata file
    try (InputStream in = client.content().get(group.getKey(), metadataPath)) {
        IOUtils.toString(in);
    }
    // Verify the group meta file exists
    ConcreteResource r_meta = new ConcreteResource(LocationUtils.toLocation(group), metadataPath);
    assertTrue(cacheProvider.exists(r_meta));
    // Delete group
    client.stores().delete(group.getKey(), "Delete", true);
    assertThat(client.stores().exists(group.getKey()), equalTo(false));
    // Verify the group meta file gone
    assertFalse(cacheProvider.exists(r_meta));
    // Verify hosted files not change (delete group not affect the files in hosted repo)
    ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), pomPath);
    assertTrue(cacheProvider.exists(r1));
    assertTrue(cacheProvider.exists(r_meta_hosted));
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) 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 25 with HostedRepository

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

the class GroupMetadataMergeWhenSeqNewHostedAddedInMultiHostedGroupTest method createHostedAndStorePath.

private HostedRepository createHostedAndStorePath(final String repoName, final String path, final String content) throws Exception {
    HostedRepository hosted = new HostedRepository(repoName);
    hosted = client.stores().create(hosted, "adding " + repoName, HostedRepository.class);
    if (StringUtils.isNotBlank(content)) {
        client.content().store(hosted.getKey(), path, new ByteArrayInputStream(content.getBytes()));
    }
    return hosted;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Aggregations

HostedRepository (org.commonjava.indy.model.core.HostedRepository)169 Test (org.junit.Test)90 ByteArrayInputStream (java.io.ByteArrayInputStream)83 Group (org.commonjava.indy.model.core.Group)80 InputStream (java.io.InputStream)42 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)41 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)37 Before (org.junit.Before)37 StoreKey (org.commonjava.indy.model.core.StoreKey)32 Transfer (org.commonjava.maven.galley.model.Transfer)23 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)19 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)16 IndyDataException (org.commonjava.indy.data.IndyDataException)15 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)15 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)13 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)12 VersionMetadata (org.commonjava.indy.pkg.npm.model.VersionMetadata)11 IndyClientException (org.commonjava.indy.client.core.IndyClientException)10 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)10 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)9