use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RelDownloadPomNotFound404Test method run.
@Test
public void run() throws Exception {
final String repo1 = "repo1";
server.expect(server.formatUrl(repo1, path), 404, "not found");
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
client.stores().create(remote1, "adding remote", RemoteRepository.class);
// Download .rel before even touching POM
InputStream rel = client.content().get(remote, repo1, pathRel);
assertThat(rel, nullValue());
logger.debug(">>> register again ...");
// upstream restored
server.expect(server.formatUrl(repo1, path), 200, content);
remote1.setDisabled(false);
// disabled due to previous error, need to enable it again
client.stores().update(remote1, "enable it");
// Retrieve it again
rel = client.content().get(remote, repo1, pathRel);
assertThat(rel, notNullValue());
String s = IOUtils.toString(rel);
logger.debug(">>> " + s);
assertThat(StringUtils.isNotEmpty(s), equalTo(true));
// check POM is downloaded
boolean exists = client.content().exists(remote, repo1, path, true);
assertThat(exists, equalTo(true));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class PomDownloadDepFromParentTest method run.
@Test
public void run() throws Exception {
String depPom = readTestResource(repo + "/" + pathDep);
server.expect(server.formatUrl(repo1, pathDep), 200, depPom);
String consumerPom = readTestResource(repo + "/" + pathConsumer);
server.expect(server.formatUrl(repo1, pathConsumer), 200, consumerPom);
String consumerParentPom = readTestResource(repo + "/" + pathConsumerParent);
server.expect(server.formatUrl(repo1, pathConsumerParent), 200, consumerParentPom);
// Create remote repositories
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
client.stores().create(remote1, "adding remote1", RemoteRepository.class);
// Get consumer pom
InputStream is = client.content().get(remote, repo1, pathConsumer);
assertThat(is, notNullValue());
String s = IOUtils.toString(is);
logger.debug(">>> " + s);
assertThat(s, equalTo(consumerPom));
waitForEventPropagation();
boolean exists = false;
// Check consumer rel exists
exists = client.content().exists(remote, repo1, pathConsumerRel, true);
assertThat(exists, equalTo(true));
// Check consumer's parent pom exists
exists = client.content().exists(remote, repo1, pathConsumerParent, true);
assertThat(exists, equalTo(true));
// Check consumer's parent rel exists
exists = client.content().exists(remote, repo1, pathConsumerParentRel, true);
assertThat(exists, equalTo(true));
// Check consumer rel content
InputStream ris = client.content().get(remote, repo1, pathConsumerRel);
assertThat(ris, notNullValue());
String rel = IOUtils.toString(ris);
logger.debug(">>> " + rel);
String output = readTestResource(resource + "/output/rel.json");
EProjectDirectRelationships eRel = mapper.readValue(rel, EProjectDirectRelationships.class);
EProjectDirectRelationships eRelOutput = mapper.readValue(output, EProjectDirectRelationships.class);
assertThat(eRel.getParent(), equalTo(eRelOutput.getParent()));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RetrieveFileAndVerifyInTrackingReportTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
final String repoId = "repo";
final String path = "/path/to/foo.class";
final InputStream stream = new ByteArrayInputStream("This is a test with the same content each time.".getBytes());
server.expect(server.formatUrl(repoId, path), 200, stream);
RemoteRepository rr = new RemoteRepository(repoId, server.formatUrl(repoId));
rr = client.stores().create(rr, "adding test remote", RemoteRepository.class);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final InputStream in = client.module(IndyFoloContentClientModule.class).get(trackingId, remote, repoId, path);
IOUtils.copy(in, baos);
in.close();
final byte[] bytes = baos.toByteArray();
final String md5 = md5Hex(bytes);
final String sha256 = sha256Hex(bytes);
assertThat(md5, equalTo(DigestUtils.md5Hex(bytes)));
assertThat(sha256, equalTo(DigestUtils.sha256Hex(bytes)));
waitForEventPropagation();
assertThat(client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId), equalTo(true));
final TrackedContentDTO report = client.module(IndyFoloAdminClientModule.class).getTrackingReport(trackingId);
assertThat(report, notNullValue());
final Set<TrackedContentEntryDTO> downloads = report.getDownloads();
assertThat(downloads, notNullValue());
assertThat(downloads.size(), equalTo(1));
final TrackedContentEntryDTO entry = downloads.iterator().next();
System.out.println(entry);
assertThat(entry, notNullValue());
assertThat(entry.getStoreKey(), equalTo(new StoreKey(remote, repoId)));
assertThat(entry.getPath(), equalTo(path));
assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(remote, repoId, path)));
assertThat(entry.getOriginUrl(), equalTo(server.formatUrl(repoId, path)));
assertThat(entry.getMd5(), equalTo(md5));
assertThat(entry.getSha256(), equalTo(sha256));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RetrieveFileFromGroupAndVerifyInTrackingReportTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
final String repoId = "repo";
final String groupId = "group";
final String path = "/path/to/foo.class";
final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
server.expect(server.formatUrl(repoId, path), 200, stream);
RemoteRepository rr = new RemoteRepository(repoId, server.formatUrl(repoId));
rr = client.stores().create(rr, "adding test remote", RemoteRepository.class);
Group g = new Group(groupId, rr.getKey());
g = client.stores().create(g, "Adding test group", Group.class);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final InputStream in = client.module(IndyFoloContentClientModule.class).get(trackingId, group, groupId, path);
IOUtils.copy(in, baos);
in.close();
final byte[] bytes = baos.toByteArray();
final String md5 = md5Hex(bytes);
final String sha256 = sha256Hex(bytes);
assertThat(md5, equalTo(DigestUtils.md5Hex(bytes)));
assertThat(sha256, equalTo(DigestUtils.sha256Hex(bytes)));
assertThat(client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId), equalTo(true));
final TrackedContentDTO report = client.module(IndyFoloAdminClientModule.class).getTrackingReport(trackingId);
assertThat(report, notNullValue());
final Set<TrackedContentEntryDTO> downloads = report.getDownloads();
assertThat(downloads, notNullValue());
assertThat(downloads.size(), equalTo(1));
final TrackedContentEntryDTO entry = downloads.iterator().next();
System.out.println(entry);
assertThat(entry, notNullValue());
assertThat(entry.getStoreKey(), equalTo(new StoreKey(remote, repoId)));
assertThat(entry.getPath(), equalTo(path));
assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(remote, repoId, path)));
assertThat(entry.getOriginUrl(), equalTo(server.formatUrl(repoId, path)));
assertThat(entry.getMd5(), equalTo(md5));
assertThat(entry.getSha256(), equalTo(sha256));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class AutoProxCalculationTest method jsonRoundTrip_RemoteRepoCreation.
@Test
public void jsonRoundTrip_RemoteRepoCreation() throws IOException {
RemoteRepository repo = new RemoteRepository("test", "http://foo.com/test");
AutoProxCalculation in = new AutoProxCalculation(repo, "test-rule.groovy");
IndyObjectMapper mapper = new IndyObjectMapper(true);
String json = mapper.writeValueAsString(in);
AutoProxCalculation out = mapper.readValue(json, AutoProxCalculation.class);
assertThat(out, notNullValue());
assertThat(out.getRuleName(), equalTo(in.getRuleName()));
assertThat(out.getStore(), equalTo(in.getStore()));
assertThat(out, equalTo(in));
}
Aggregations