Ejemplo n.º 1
0
  @Test
  public void testFullRun() throws InterruptedException {
    log.trace("Entering testFullRun()...");
    final Set<Resource> successfulUris = testMain.cache(uris);
    testMain.index(transformation, successfulUris);
    final long startTime = currentTimeMillis();
    synchronized (testSink) {
      while (testSink.accepted().size() < successfulUris.size()
          && currentTimeMillis() < (startTime + TIMEOUT)) {
        testSink.wait(TIMESTEP);
      }
    }
    for (final Resource uri : uris) {
      assertTrue(
          "Failed to find a record for " + uri + " in output records: " + testSink.accepted() + "!",
          Iterables.any(
              testSink.accepted(),
              new Predicate<OutputRecord>() {

                @Override
                public boolean apply(final OutputRecord record) {

                  return record.id().equals(uri.toString());
                }
              }));
    }
    log.trace("Leaving testFullRun().");
  }
Ejemplo n.º 2
0
 @Test
 public void testRunWithUnloadableResources() throws InterruptedException {
   log.trace("Entering testRunWithUnloadableResources()...");
   final Set<Resource> urisWithExtra = new HashSet<>(uris);
   final Set<Resource> badUris = singleton(createResource());
   urisWithExtra.addAll(badUris);
   final Set<Resource> successfulUris = testMain.cache(urisWithExtra);
   testMain.index(transformation, successfulUris);
   final long startTime = currentTimeMillis();
   synchronized (testSink) {
     while ((testSink.accepted().size() < successfulUris.size())
         && currentTimeMillis() < (startTime + TIMEOUT)) {
       testSink.wait(TIMESTEP);
     }
   }
   assertEquals(
       "Didn't find the appropriate resource failing to be retrieved!",
       badUris,
       difference(urisWithExtra, successfulUris));
   log.trace("Leaving testRunWithUnloadableResources().");
 }