LoadingRunnable implements Runnable { public synchronized void stop() { stop = true; } LoadingRunnable(Source source, LogImporter logImporter, LogDataCollector logDataCollector, long sleepTime, Optional<Long> bufferingTime, StatsService statsService);  LoadingRunnable(Source source, LogImporter logImporter, LogDataCollector logDataCollector, long sleepTime, Optional<Long> bufferingTime, Optional<AcceptCondition> withAcceptCondition, StatsService statsService); @Override void run(); synchronized LoadStatistic getLoadStatistic(); synchronized void pause(); synchronized void resume(); synchronized void stop(); synchronized void setFilter(Optional<AcceptCondition> acceptCondition);  }
@Test(invocationCount = 5) public void testLoadingStopWithLogParser() throws IOException { saveLines(Range.closed(0, julSimpleLogLines.size()), julSimpleLogLines, outputStream); underTest = createLoadingRunnable(getJulLogParser()); executorService.submit(underTest); await().until(() -> collector.getCount() == 1000); underTest.stop(); saveLines(Range.closed(0, julSimpleLogLines.size()), julSimpleLogLines, outputStream); await().atLeast(100, TimeUnit.MILLISECONDS).until(() -> collector.getCount() == 1000); }
@Test(invocationCount = 5) public void canDeleteFileWhenStopped() throws Exception { saveLines(Range.closed(0, julSimpleLogLines.size()), julSimpleLogLines, outputStream); underTest = new LoadingRunnable(vfsSource, getJulLogParser(), collector, 100, Optional.empty(), new EmptyStatsService()); executorService.submit(underTest); await().until(() -> collector.getCount() > 0); outputStream.close(); underTest.stop(); await("File " + vfsSource.stringForm() + " should be deleted").until(() -> file.delete()); }