Search in sources :

Example 86 with RemoteRepository

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

the class AddAndRetrieveRemoteRepoTest method addMinimalRemoteRepositoryAndRetrieveIt.

@Test
public void addMinimalRemoteRepositoryAndRetrieveIt() throws Exception {
    final RemoteRepository rr = new RemoteRepository(newName(), "http://www.foo.com");
    final RemoteRepository result = client.stores().create(rr, name.getMethodName(), RemoteRepository.class);
    assertThat(result.getName(), equalTo(rr.getName()));
    assertThat(result.getUrl(), equalTo(rr.getUrl()));
    assertThat(result.equals(rr), equalTo(true));
}
Also used : RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Test(org.junit.Test)

Example 87 with RemoteRepository

use of org.commonjava.indy.model.core.RemoteRepository 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 88 with RemoteRepository

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

the class RemoteRepoValidUrlTest method run.

@Test
public void run() throws Exception {
    final String VALID_REPO = "valid";
    final String VALID_URL = "http://www.foo.com";
    client.stores().create(new RemoteRepository(VALID_REPO, VALID_URL), "adding valid test", RemoteRepository.class);
    assertTrue(client.stores().exists(remote, VALID_REPO));
}
Also used : RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Test(org.junit.Test)

Example 89 with RemoteRepository

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

the class ImpliedRepoMaintainerTest method dontRemoveImpliedRepoWhenRepoRemovedFromGroup.

@Test
public void dontRemoveImpliedRepoWhenRepoRemovedFromGroup() throws Exception {
    final Group g = new Group(MAVEN_PKG_KEY, "test");
    storeDataManager.storeArtifactStore(g, summary, false, true, new EventMetadata());
    final RemoteRepository repo1 = new RemoteRepository(MAVEN_PKG_KEY, "one", "http://www.foo.com/repo");
    storeDataManager.storeArtifactStore(repo1, summary, false, true, new EventMetadata());
    final RemoteRepository repo2 = new RemoteRepository(MAVEN_PKG_KEY, "one", "http://www.foo.com/repo");
    storeDataManager.storeArtifactStore(repo2, summary, false, true, new EventMetadata());
    metadataManager.addImpliedMetadata(repo1, Collections.singletonList(repo2));
    // Simulates removal of repo1...odd, I know, but since they post-process these updates, it's what the 
    // event observers would see.
    g.addConstituent(repo2);
    final ArtifactStorePreUpdateEvent event = new ArtifactStorePreUpdateEvent(ArtifactStoreUpdateType.UPDATE, new EventMetadata(), Collections.singletonMap(g.copyOf(), g));
    maintainer.updateImpliedStores(event);
    assertThat(g.getConstituents().contains(repo2.getKey()), equalTo(true));
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStorePreUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 90 with RemoteRepository

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

the class ImpliedRepoMaintainerTest method addImpliedRepoWhenRepoAddedToGroup.

@Test
public void addImpliedRepoWhenRepoAddedToGroup() throws Exception {
    final Group g = new Group(MAVEN_PKG_KEY, "test");
    storeDataManager.storeArtifactStore(g, summary, false, true, new EventMetadata());
    final RemoteRepository repo1 = new RemoteRepository(MAVEN_PKG_KEY, "one", "http://www.foo.com/repo");
    storeDataManager.storeArtifactStore(repo1, summary, false, true, new EventMetadata());
    final RemoteRepository repo2 = new RemoteRepository(MAVEN_PKG_KEY, "one", "http://www.foo.com/repo");
    storeDataManager.storeArtifactStore(repo2, summary, false, true, new EventMetadata());
    metadataManager.addImpliedMetadata(repo1, Collections.singletonList(repo2));
    g.addConstituent(repo1);
    final ArtifactStorePreUpdateEvent event = new ArtifactStorePreUpdateEvent(ArtifactStoreUpdateType.UPDATE, new EventMetadata(), Collections.singletonMap(g.copyOf(), g));
    maintainer.updateImpliedStores(event);
    assertThat(g.getConstituents().contains(repo2.getKey()), equalTo(true));
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStorePreUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

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