void work_helper(
     NonBlockingIdentityHashMap<String, String> nbhm, String thrd, int d, String[] keys) {
   final int ITERS = 20000;
   for (int j = 0; j < 10; j++) {
     long start = System.nanoTime();
     for (int i = d; i < ITERS; i += 2)
       assertThat(
           "this key not in there, so putIfAbsent must work",
           nbhm.putIfAbsent(keys[i], thrd),
           is((String) null));
     for (int i = d; i < ITERS; i += 2) assertTrue(nbhm.remove(keys[i], thrd));
     double delta_nanos = System.nanoTime() - start;
     double delta_secs = delta_nanos / 1000000000.0;
     double ops = ITERS * 2;
     // System.out.println("Thrd"+thrd+" "+(ops/delta_secs)+" ops/sec size="+nbhm.size());
   }
 }
@Category(EventDependent.class)
public class StoreFileThenUploadThenDownloadAndVerifyInTrackingReportTest
    extends AbstractTrackingReportTest {
  final byte[] bytes = ("This is a test: " + System.nanoTime()).getBytes();
  final String path = "/path/to/foo.class";

  @Before
  public void prepareStore() throws Exception {
    HostedRepository r = new HostedRepository(STORE);
    r = client.stores().create(r, "adding test hosted", HostedRepository.class);
  }

  @Test
  public void runUploadThenDownload() throws Exception {
    final String trackingId = newName();

    IndyFoloContentClientModule module = client.module(IndyFoloContentClientModule.class);

    // upload
    module.store(trackingId, hosted, STORE, path, new ByteArrayInputStream(bytes));

    // download
    module.get(trackingId, hosted, STORE, path);

    Thread.sleep(2000); // wait for event being fired

    sealAndCheck(trackingId);
  }

  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));
  }
}