use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RemoteRepoTimeoutDisablesThenReEnabledTest method run.
@Test
@Category(TimingDependent.class)
public void run() throws Exception {
final String repo1 = "repo1";
final String path = "org/foo/bar/maven-metadata.xml";
server.expect(server.formatUrl("repo1/"), 200, "OK");
server.expect("GET", server.formatUrl(repo1, path), (req, resp) -> {
try {
Thread.sleep(5000);
} catch (final InterruptedException e) {
}
resp.setStatus(404);
});
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1.setTimeoutSeconds(1);
remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
try (InputStream is = client.content().get(remote, repo1, path)) {
} catch (final IndyClientException e) {
assertThat(e.getStatusCode(), equalTo(HttpStatus.SC_BAD_GATEWAY));
}
Thread.sleep(1000);
RemoteRepository result = client.stores().load(remote, repo1, RemoteRepository.class);
assertThat(result.isDisabled(), equalTo(true));
Thread.sleep(4000);
result = client.stores().load(remote, repo1, RemoteRepository.class);
assertThat(result.isDisabled(), equalTo(false));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RepositoryPathMaskExistsTest 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)
boolean result = client.content().exists(group, g.getName(), path_1);
assertThat(result, equalTo(true));
// get stream for path_2 via group (null)
result = client.content().exists(group, g.getName(), path_2);
assertThat(result, equalTo(false));
// get stream for path_1 via concrete store (success)
result = client.content().exists(remote, remote1.getName(), path_1);
assertThat(result, equalTo(true));
// get stream for path_2 via concrete repo (null)
result = client.content().exists(remote, remote1.getName(), path_2);
assertThat(result, equalTo(false));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AddAndDeleteRemoteRepoTest method addMinimalRemoteRepositoryAndDeleteIt.
@Test
public void addMinimalRemoteRepositoryAndDeleteIt() throws Exception {
final RemoteRepository repo = new RemoteRepository(newName(), "http://www.foo.com");
final RemoteRepository result = client.stores().create(repo, name.getMethodName(), RemoteRepository.class);
assertThat(result.getName(), equalTo(repo.getName()));
assertThat(result.getUrl(), equalTo(repo.getUrl()));
assertThat(result.equals(repo), equalTo(true));
client.stores().delete(StoreType.remote, repo.getName(), name.getMethodName());
assertThat(client.stores().exists(StoreType.remote, repo.getName()), equalTo(false));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AddRemoteRepoThenModifyAndVerifyTest method addAndModifyRemoteRepositoryThenRetrieveIt.
@Test
public void addAndModifyRemoteRepositoryThenRetrieveIt() throws Exception {
final RemoteRepository rr = new RemoteRepository(newName(), "http://www.foo.com");
client.stores().create(rr, name.getMethodName(), RemoteRepository.class);
rr.setUrl("https://www.foo.com/");
assertThat(rr.getUrl(), equalTo("https://www.foo.com/"));
final boolean updated = client.stores().update(rr, name.getMethodName());
assertThat(updated, equalTo(true));
final RemoteRepository result = client.stores().load(StoreType.remote, rr.getName(), 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 SetBackSettingsManager method updateSettingsForGroup.
private DataFile updateSettingsForGroup(final Group group) throws SetBackDataException {
if (!config.isEnabled()) {
throw new SetBackDataException("SetBack is disabled!");
}
logger.info("Updating set-back settings.xml for group: {}", group.getName());
List<ArtifactStore> concreteStores;
try {
concreteStores = storeManager.query().packageType(group.getPackageType()).getOrderedConcreteStoresInGroup(group.getName());
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve concrete membership for group: {}. Reason: {}", group.getName(), e.getMessage()), e);
return null;
}
final List<RemoteRepository> remotes = new ArrayList<RemoteRepository>();
for (final ArtifactStore cs : concreteStores) {
if (StoreType.remote == cs.getKey().getType()) {
remotes.add((RemoteRepository) cs);
}
}
return updateSettings(group, concreteStores, remotes);
}
Aggregations