Skip to content

Instantly share code, notes, and snippets.

@iainporter
Last active August 29, 2020 09:57
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/99900a26e98bb889bfe0f8666b85140d to your computer and use it in GitHub Desktop.
Save iainporter/99900a26e98bb889bfe0f8666b85140d to your computer and use it in GitHub Desktop.
test for validating file was read
@Autowired
@Qualifier(ApplicationConfiguration.INBOUND_CHANNEL)
public DirectChannel filePollingChannel;
@Test
public void pollFindsValidFile() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
filePollingChannel.addInterceptor(new ChannelInterceptor() {
@Override
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
latch.countDown();
}
});
copy(TestUtils.locateClasspathResource(TestUtils.FILE_FIXTURE_PATH), new File(inboundReadDirectory, TestUtils.FILE_FIXTURE_NAME ));
assertThat(latch.await(5, TimeUnit.SECONDS), is(true));
assertThatDirectoryIsEmpty(inboundReadDirectory);
assertThatDirectoryIsEmpty(inboundFailedDirectory);
assertThatDirectoryHasFiles(inboundOutDirectory, 1);
assertThatDirectoryHasFiles(inboundProcessedDirectory, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment