Skip to content

Instantly share code, notes, and snippets.

@iainporter
Last active August 29, 2020 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iainporter/83066c6a8223f7b56332103bb5d48dc5 to your computer and use it in GitHub Desktop.
Save iainporter/83066c6a8223f7b56332103bb5d48dc5 to your computer and use it in GitHub Desktop.
@Test
public void pollIgnoresFileAlreadySeen() throws Exception {
final CountDownLatch stopLatch = new CountDownLatch(1);
filePollingChannel.addInterceptor(new ChannelInterceptor() {
@Override
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
stopLatch.countDown();
}
});
copy(TestUtils.locateClasspathResource(TestUtils.FILE_FIXTURE_PATH), new File(inboundReadDirectory, TestUtils.FILE_FIXTURE_NAME ));
//wait for stopLatch before asserting
assertThat(stopLatch.await(5, TimeUnit.SECONDS), is(true));
assertThatDirectoryHasFiles(inboundProcessedDirectory, 1);
assertThatDirectoryHasFiles(inboundOutDirectory, 1);
assertThatDirectoryIsEmpty(inboundReadDirectory);
assertThatDirectoryIsEmpty(inboundFailedDirectory);
copy(TestUtils.locateClasspathResource(TestUtils.FILE_FIXTURE_PATH), new File(inboundReadDirectory, TestUtils.FILE_FIXTURE_NAME ));
Thread.sleep(2000); //wait longer than the polling period
assertThatDirectoryIsEmpty(inboundFailedDirectory);
assertThatDirectoryHasFiles(inboundReadDirectory, 1);
assertThatDirectoryHasFiles(inboundProcessedDirectory, 1);
assertThatDirectoryHasFiles(inboundOutDirectory, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment