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());
}
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));
}
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));
}
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));
}
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));
}
Aggregations