use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class CacheFirstTimeoutWorkingTest method createRemoteRepository.
@Override
protected RemoteRepository createRemoteRepository() {
final RemoteRepository repository = new RemoteRepository(repoId, server.formatUrl(repoId));
repository.setCacheTimeoutSeconds(CACHE_TIMEOUT_SECONDS);
repository.setMetadataTimeoutSeconds(METADATA_TIMEOUT_SECONDS);
return repository;
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class ContentNotAvailableInGroupWithDisabledRemoteTest method contentAccess.
@Test
public void contentAccess() throws Exception {
final String remoteName = "r";
final String groupName = "g";
final String path = "org/foo/bar/foo-bar-1.txt";
final String content = "This is a test";
server.expect(server.formatUrl(remoteName, path), 200, content);
RemoteRepository r = new RemoteRepository(remoteName, server.formatUrl(remoteName));
r = client.stores().create(r, "adding remote", RemoteRepository.class);
Group g = new Group(groupName, r.getKey());
g = client.stores().create(g, "adding group", Group.class);
try (InputStream in = client.content().get(g.getKey(), path)) {
assertThat(IOUtils.toString(in), equalTo(content));
}
r.setDisabled(true);
client.stores().update(r, "adding remote");
assertThat(client.content().exists(g.getKey(), path), equalTo(false));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class DownloadContentHasLengthHeaderTest method proxyRemoteArtifact.
@Test
public void proxyRemoteArtifact() throws Exception {
byte[] data = ("This is a test: " + System.nanoTime()).getBytes();
final InputStream stream = new ByteArrayInputStream(data);
final String path = "org/foo/foo-project/1/foo-1.txt";
server.expect(server.formatUrl(STORE, path), 200, stream);
client.stores().create(new RemoteRepository(STORE, server.formatUrl(STORE)), "adding test proxy", RemoteRepository.class);
try (HttpResources httpResources = client.module(IndyRawHttpModule.class).getHttp().getRaw(client.content().contentPath(remote, STORE, path))) {
HttpResponse response = httpResources.getResponse();
String contentLength = response.getFirstHeader("Content-Length").getValue();
assertThat("Wrong content-length for download: " + contentLength + " (should have been: " + data.length + ")", contentLength, equalTo(Integer.toString(data.length)));
}
final PathInfo result = client.content().getInfo(remote, STORE, path);
assertThat("no result", result, notNullValue());
assertThat("doesn't exist", result.exists(), equalTo(true));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class DownloadFromSecondRemoteAfterFirstHostedRepoTest method setupTest.
@Before
public void setupTest() throws Exception {
String change = "test setup";
hosted = client.stores().create(new HostedRepository(HOSTED), change, HostedRepository.class);
remote = client.stores().create(new RemoteRepository(REMOTE, server.formatUrl(REMOTE)), change, RemoteRepository.class);
group = client.stores().create(new Group(GROUP, hosted.getKey(), remote.getKey()), change, Group.class);
client.content().store(hosted.getKey(), JAR_PATH, new ByteArrayInputStream("This is the jar".getBytes()));
server.expect(server.formatUrl(REMOTE, PATH), 200, CONTENT);
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class HttpProxyTest method proxy500As502.
@Test
@Ignore("return upstream 5xx class errors as 404 to keep Maven & co happy")
public void proxy500As502() 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.registerException(new File("/" + testRepo, pom.path).getPath(), "Expected exception", 500);
final HttpGet get = new HttpGet(url);
final CloseableHttpClient client = proxiedHttp();
CloseableHttpResponse response = null;
final InputStream stream = null;
try {
response = client.execute(get, proxyContext(USER, PASS));
assertThat(response.getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_GATEWAY));
} finally {
IOUtils.closeQuietly(stream);
HttpUtil.cleanupResources(client, get, response);
}
final RemoteRepository remoteRepo = (RemoteRepository) storeManager.getArtifactStore(new StoreKey(GENERIC_PKG_KEY, StoreType.remote, "httprox_127-0-0-1"));
assertThat(remoteRepo, notNullValue());
assertThat(remoteRepo.getUrl(), equalTo(server.getBaseUri()));
}
Aggregations