Search in sources :

Example 81 with RemoteRepository

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

the class RepositoryPathMaskTest method run.

@Test
public void run() throws Exception {
    final String content = "{\"content\": \"This is a test: " + System.nanoTime() + "\"}";
    final String path_1 = "org/foo/foo-project/1/a.out.txt";
    // not in masks
    final String path_2 = "org/bar/bar-project/1/a.out.txt";
    final String repo1 = "repo1";
    server.expect(server.formatUrl(repo1, path_1), 200, new ByteArrayInputStream(content.getBytes()));
    server.expect(server.formatUrl(repo1, path_2), 200, new ByteArrayInputStream(content.getBytes()));
    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    Set<String> pathMaskPatterns = new HashSet<>();
    pathMaskPatterns.add("org/foo");
    remote1.setPathMaskPatterns(pathMaskPatterns);
    remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
    Group g = new Group("test", remote1.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  "));
    // get stream for path-1 via group (success)
    InputStream stream = client.content().get(group, g.getName(), path_1);
    assertThat(stream, notNullValue());
    final String str = IOUtils.toString(stream);
    assertThat(str, equalTo(content));
    stream.close();
    // get stream for path_2 via group (null)
    stream = client.content().get(group, g.getName(), path_2);
    assertThat(stream, nullValue());
    // get stream for path_1 via concrete store (success)
    stream = client.content().get(remote, remote1.getName(), path_1);
    assertThat(stream, notNullValue());
    stream.close();
    // get stream for path_2 via concrete repo (null)
    stream = client.content().get(remote, remote1.getName(), path_2);
    assertThat(stream, nullValue());
}
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) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 82 with RemoteRepository

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

the class RoutedCacheProviderForRemoteWithNoNFSTest method proxyRemoteWithNoNFS.

@Test
public void proxyRemoteWithNoNFS() throws Exception {
    final String repo1 = "repo1";
    final String pomPath = "org/foo/bar/1.0/bar-1.0.pom";
    final String pomUrl = server.formatUrl(repo1, pomPath);
    final String datetime = (new Date()).toString();
    server.expect(pomUrl, 200, String.format("pom %s", datetime));
    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    client.stores().create(remote1, "adding remote", RemoteRepository.class);
    final PathInfo result = client.content().getInfo(remote, repo1, pomPath);
    assertThat("no result", result, notNullValue());
    assertThat("doesn't exist", result.exists(), equalTo(true));
    final File nfsStorage = Paths.get(fixture.getBootOptions().getIndyHome(), NFS_BASE).toFile();
    assertThat(nfsStorage.exists(), equalTo(false));
}
Also used : RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) PathInfo(org.commonjava.indy.client.core.helper.PathInfo) File(java.io.File) Date(java.util.Date) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 83 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 84 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 85 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)

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