use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.
the class StoreFileThenUploadThenDownloadAndVerifyInTrackingReportTest method sealAndCheck.
void sealAndCheck(String trackingId) throws IndyClientException {
// seal
IndyFoloAdminClientModule adminModule = client.module(IndyFoloAdminClientModule.class);
boolean success = adminModule.sealTrackingRecord(trackingId);
assertThat(success, equalTo(true));
// check report
final TrackedContentDTO report = adminModule.getTrackingReport(trackingId);
assertThat(report, notNullValue());
final Set<TrackedContentEntryDTO> downloads = report.getDownloads();
assertThat(downloads, notNullValue());
assertThat(downloads.size(), equalTo(1));
final Set<TrackedContentEntryDTO> uploads = report.getUploads();
assertThat(uploads, notNullValue());
assertThat(uploads.size(), equalTo(1));
}
use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.
the class StoreFileViaGroupAndVerifyInTrackingReportTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
final String path = "/path/to/foo.class";
client.module(IndyFoloContentClientModule.class).store(trackingId, group, PUBLIC, path, stream);
assertThat(client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId), equalTo(true));
final TrackedContentDTO report = client.module(IndyFoloAdminClientModule.class).getTrackingReport(trackingId);
assertThat(report, notNullValue());
final Set<TrackedContentEntryDTO> uploads = report.getUploads();
assertThat(uploads, notNullValue());
assertThat(uploads.size(), equalTo(1));
final TrackedContentEntryDTO entry = uploads.iterator().next();
System.out.println(entry);
assertThat(entry, notNullValue());
assertThat(entry.getStoreKey(), equalTo(new StoreKey(hosted, STORE)));
assertThat(entry.getPath(), equalTo(path));
assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(hosted, STORE, path)));
assertThat(entry.getOriginUrl(), nullValue());
}
use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.
the class UseChecksumFromTransferDecoratorForTrackingRecord_Sha1FileTest method run.
@BMRules(rules = { @BMRule(name = "setup_metadata_countdown", targetClass = "^org.commonjava.indy.content.ContentDigester", isInterface = true, targetMethod = "<init>", targetLocation = "ENTRY", action = "System.out.println(\"SETUP COUNTDOWN\"); createCountDown(\"COUNTDOWN\", 1);"), @BMRule(name = "prevent_successive_metadata_additions", targetClass = "^org.commonjava.indy.content.ContentDigester", isInterface = true, targetMethod = "addMetadata", targetLocation = "ENTRY", binding = "path:String = $1.getPath();", condition = "path.endsWith(\"path/to/foo.class\") && countDown(\"COUNTDOWN\")", action = "System.out.println(\"RETURN NULL\"); return null;") })
@Test
public void run() throws Exception {
final String trackingId = newName();
final String repoId = "repo";
final String path = "/org/bar/foo/1/foo-1.pom.sha1";
final InputStream stream = new ByteArrayInputStream(DigestUtils.md5("This is a test with the same content each time."));
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.folo.dto.TrackedContentDTO in project indy by Commonjava.
the class GroupMetadataExcludedFromTrackingReportTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
final String path = "org/commonjava/commonjava/maven-metadata.xml";
centralServer.expect(centralServer.formatUrl(path), 200, Thread.currentThread().getContextClassLoader().getResourceAsStream("folo-content/commonjava-version-metadata.xml"));
client.module(IndyFoloAdminClientModule.class).initReport(trackingId);
final InputStream result = client.module(IndyFoloContentClientModule.class).get(trackingId, group, PUBLIC, path);
assertThat(result, notNullValue());
final String pom = IOUtils.toString(result);
result.close();
assertThat(pom.contains("<version>2</version>"), equalTo(true));
boolean sealed = client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId);
assertThat(sealed, equalTo(true));
TrackedContentDTO trackingReport = client.module(IndyFoloAdminClientModule.class).getTrackingReport(trackingId);
Set<TrackedContentEntryDTO> downloads = trackingReport.getDownloads();
assertThat(downloads == null || downloads.isEmpty(), equalTo(true));
}
Aggregations