Search in sources :

Example 16 with TrackedContentEntryDTO

use of org.commonjava.indy.folo.dto.TrackedContentEntryDTO 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));
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO)

Example 17 with TrackedContentEntryDTO

use of org.commonjava.indy.folo.dto.TrackedContentEntryDTO 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());
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) StoreKey(org.commonjava.indy.model.core.StoreKey) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Test(org.junit.Test)

Example 18 with TrackedContentEntryDTO

use of org.commonjava.indy.folo.dto.TrackedContentEntryDTO 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));
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StoreKey(org.commonjava.indy.model.core.StoreKey) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) BytemanTest(org.commonjava.indy.ftest.core.category.BytemanTest) Test(org.junit.Test) BMRules(org.jboss.byteman.contrib.bmunit.BMRules)

Example 19 with TrackedContentEntryDTO

use of org.commonjava.indy.folo.dto.TrackedContentEntryDTO 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));
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) InputStream(java.io.InputStream) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Test(org.junit.Test)

Aggregations

TrackedContentEntryDTO (org.commonjava.indy.folo.dto.TrackedContentEntryDTO)19 TrackedContentDTO (org.commonjava.indy.folo.dto.TrackedContentDTO)18 IndyFoloAdminClientModule (org.commonjava.indy.folo.client.IndyFoloAdminClientModule)16 Test (org.junit.Test)14 InputStream (java.io.InputStream)13 IndyFoloContentClientModule (org.commonjava.indy.folo.client.IndyFoloContentClientModule)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 StoreKey (org.commonjava.indy.model.core.StoreKey)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)6 BytemanTest (org.commonjava.indy.ftest.core.category.BytemanTest)3 BMRules (org.jboss.byteman.contrib.bmunit.BMRules)3 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 HttpGet (org.apache.http.client.methods.HttpGet)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 TreeSet (java.util.TreeSet)1 TrackedContentEntry (org.commonjava.indy.folo.model.TrackedContentEntry)1 Group (org.commonjava.indy.model.core.Group)1