@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()."); }
@Before public void setUp() { testMain = new Workflow(); final Dataset dataset = createDataset(); testMain.dataset(dataset); testSink = new TestSink(); testMain.persister(testSink); testAssembler = new DatasetCacheLoader().cache(dataset); testMain.assembler(testAssembler); testOutputStage = new TestOutputStage(); testMain.outputStage(testOutputStage); }
@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()."); }