use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class Propagate404NotFoundTest method run.
@Test
public void run() throws Exception {
final String testRepo = "test";
final String url = server.formatUrl(testRepo, "org/test/foo/1/foo-1.pom");
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_NOT_FOUND));
} finally {
IOUtils.closeQuietly(stream);
HttpResources.cleanupResources(get, response, client);
}
final RemoteRepository remoteRepo = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.remote, "httprox_127-0-0-1_" + server.getPort()), RemoteRepository.class);
assertThat(remoteRepo, notNullValue());
assertThat(remoteRepo.getUrl(), equalTo(server.getBaseUri()));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class TrackedContentDTOTest method jsonRoundTrip_DownloadsNoUploads.
@Test
public void jsonRoundTrip_DownloadsNoUploads() throws IOException {
Set<TrackedContentEntryDTO> downloads = setOf(new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom"), new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo2"), AccessChannel.MAVEN_REPO, "/path/to/another/file.pom"));
TrackedContentDTO in = new TrackedContentDTO(new TrackingKey("key"), Collections.emptySet(), downloads);
assertRoundTrip(in, (out) -> {
assertNullOrEmpty(out.getUploads());
assertContents(out.getDownloads(), in.getDownloads());
});
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class TrackedContentEntryDTOTest method jsonRoundTrip_Urls.
@Test
public void jsonRoundTrip_Urls() throws IOException {
TrackedContentEntryDTO in = new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom");
in.setLocalUrl("http://localhost:8080/api/remote/foo/path/to/my.pom");
in.setOriginUrl("http://foo.com/repo/path/to/my.pom");
assertRoundTrip(in, (out) -> {
assertThat(out.getLocalUrl(), equalTo(out.getLocalUrl()));
assertThat(out.getOriginUrl(), equalTo(out.getOriginUrl()));
});
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class TrackedContentEntryDTOTest method jsonRoundTrip_Checksums.
@Test
public void jsonRoundTrip_Checksums() throws IOException {
TrackedContentEntryDTO in = new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom");
String content = "This is a test string";
in.setMd5(DigestUtils.md5Hex(content));
in.setSha256(DigestUtils.sha256Hex(content));
in.setSha1(DigestUtils.shaHex(content));
assertRoundTrip(in, (out) -> {
assertThat(out.getMd5(), equalTo(in.getMd5()));
assertThat(out.getSha256(), equalTo(in.getSha256()));
assertThat(out.getSha1(), equalTo(in.getSha1()));
});
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class AffectedStoreRecordTest method roundTripRecordWithTwoUploadsToJson.
@Test
public void roundTripRecordWithTwoUploadsToJson() throws Exception {
final StoreType type = StoreType.group;
final String name = "test-group";
final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
record.add("/path/one", StoreEffect.UPLOAD);
record.add("/path/two", StoreEffect.UPLOAD);
final String json = mapper.writeValueAsString(record);
System.out.println(json);
final AffectedStoreRecord result = mapper.readValue(json, AffectedStoreRecord.class);
assertThat(result, notNullValue());
assertThat(result.getKey(), equalTo(record.getKey()));
assertThat(result.getDownloadedPaths(), nullValue());
assertThat(result.getUploadedPaths(), equalTo(record.getUploadedPaths()));
}
Aggregations