Search in sources :

Example 86 with HostedRepository

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

the class AutoCreateRepoWithTrackingIdTest method run.

@Test
public void run() throws Exception {
    final String testRepo = "test";
    final PomRef pom = loadPom("simple.pom", Collections.<String, String>emptyMap());
    final String url = server.formatUrl(testRepo, pom.path);
    server.expect(url, 200, pom.pom);
    final HttpGet get = new HttpGet(url);
    CloseableHttpClient client = proxiedHttp(USER, PASS);
    CloseableHttpResponse response = null;
    InputStream stream = null;
    try {
        response = client.execute(get, proxyContext(USER, PASS));
        stream = response.getEntity().getContent();
        final String resultingPom = IOUtils.toString(stream);
        assertThat(resultingPom, notNullValue());
        assertThat(resultingPom, equalTo(pom.pom));
    } finally {
        IOUtils.closeQuietly(stream);
        HttpResources.cleanupResources(get, response, client);
    }
    // Remote
    String remote = creator.formatId(HOST, 0, 0, TRACKING_ID, StoreType.remote);
    final RemoteRepository remoteRepo = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.remote, remote), RemoteRepository.class);
    assertThat(remoteRepo, notNullValue());
    assertThat(remoteRepo.getUrl(), equalTo(server.getBaseUri()));
    assertThat(remoteRepo.isPassthrough(), equalTo(false));
    String pomUrl = this.client.content().contentUrl(remoteRepo.getKey(), testRepo, pom.path) + "?cache-only=true";
    HttpHead head = new HttpHead(pomUrl);
    client = HttpClients.createDefault();
    try {
        response = client.execute(head);
        assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
    } finally {
        HttpResources.cleanupResources(head, response, client);
    }
    // Hosted
    String hosted = creator.formatId(HOST, 0, 0, TRACKING_ID, StoreType.hosted);
    final HostedRepository hostedRepo = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.hosted, hosted), HostedRepository.class);
    assertThat(hostedRepo, notNullValue());
    // Group
    final Group group = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.group, creator.formatId(HOST, 0, 0, TRACKING_ID, StoreType.group)), Group.class);
    assertThat(group, notNullValue());
    List<StoreKey> constituents = group.getConstituents();
    assertThat(constituents.contains(remoteRepo.getKey()), equalTo(true));
    assertThat(constituents.contains(hostedRepo.getKey()), equalTo(true));
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Group(org.commonjava.indy.model.core.Group) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) HttpHead(org.apache.http.client.methods.HttpHead) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 87 with HostedRepository

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

the class HostedByArcWithoutIgnoreRootUploadTest method testUploadZipAndCreate.

@Test
public void testUploadZipAndCreate() throws Exception {
    IndyHostedByArchiveClientModule module = client.module(IndyHostedByArchiveClientModule.class);
    final String hostedRepoName = "hosted-zip-no-ignore";
    HostedRepository repo = module.createRepo(getZipFile(), hostedRepoName);
    assertThat(repo, notNullValue());
    assertThat(repo.getName(), equalTo(hostedRepoName));
    boolean exists = client.content().exists(repo.getKey(), "org/foo/bar/1.0/foo-bar-1.0.pom");
    assertTrue(exists);
}
Also used : IndyHostedByArchiveClientModule(org.commonjava.indy.hostedbyarc.client.IndyHostedByArchiveClientModule) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 88 with HostedRepository

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

the class AbstractProxyRepositoryCreator method createHosted.

protected HostedRepository createHosted(String trackingID, String name, UrlInfo info, Logger logger) {
    HostedRepository hosted = new HostedRepository(GENERIC_PKG_KEY, name);
    setPropsAndMetadata(hosted, trackingID, info);
    return hosted;
}
Also used : HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 89 with HostedRepository

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

the class ListStoresByTypeTest method listByType.

@Test
public void listByType() throws Exception {
    final Set<ArtifactStore> hosteds = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        final HostedRepository repo = new HostedRepository(newName());
        assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
        hosteds.add(repo);
    }
    final Set<ArtifactStore> remotes = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        final RemoteRepository repo = new RemoteRepository(newName(), newUrl());
        assertThat(client.stores().create(repo, name.getMethodName(), RemoteRepository.class), notNullValue());
        remotes.add(repo);
    }
    final Set<ArtifactStore> groups = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        final Group repo = new Group(newName());
        assertThat(client.stores().create(repo, name.getMethodName(), Group.class), notNullValue());
        groups.add(repo);
    }
    // Now, start listing by type and verify that ONLY those of the given type are present
    checkListing(client.stores().listHostedRepositories(), hosteds, Arrays.asList(remotes, groups));
    checkListing(client.stores().listRemoteRepositories(), remotes, Arrays.asList(groups, hosteds));
    checkListing(client.stores().listGroups(), groups, Arrays.asList(hosteds, remotes));
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HashSet(java.util.HashSet) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 90 with HostedRepository

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

the class GroupAdjustmentToMemberDeletionTest method groupAdjustsToConstituentDeletion.

@Test
@Category(EventDependent.class)
public void groupAdjustsToConstituentDeletion() throws Exception {
    final HostedRepository repo = new HostedRepository(newName());
    final Group group = new Group(newName());
    group.addConstituent(repo);
    assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
    assertThat(client.stores().create(group, name.getMethodName(), Group.class), notNullValue());
    client.stores().delete(repo.getKey().getType(), repo.getName(), name.getMethodName());
    waitForEventPropagation();
    final Group result = client.stores().load(group.getKey().getType(), group.getName(), Group.class);
    assertThat(result.getConstituents() == null || result.getConstituents().isEmpty(), equalTo(true));
}
Also used : Group(org.commonjava.indy.model.core.Group) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

HostedRepository (org.commonjava.indy.model.core.HostedRepository)173 Test (org.junit.Test)91 ByteArrayInputStream (java.io.ByteArrayInputStream)84 Group (org.commonjava.indy.model.core.Group)81 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)34 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 IndyClientException (org.commonjava.indy.client.core.IndyClientException)11 VersionMetadata (org.commonjava.indy.pkg.npm.model.VersionMetadata)11 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)10 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)9