Ignore .writing files in Integration samples tests

Previously, a temporary .writing file could be found and an attempt made to
access its contents. If the temporary file was deleted between it being found
and its contents being read, the test would fail with a FileNotFoundException.

This commit updates the test to ignore .writing files so that it will only
examine the contents of the final file once Integration has finished
writing it an atomically moved it to its final location.
This commit is contained in:
Andy Wilkinson 2018-11-27 11:24:25 +00:00
parent f6a22a05b8
commit ac77fc9dcf

View File

@ -113,7 +113,9 @@ public class SampleIntegrationApplicationTests {
.getResourcePatternResolver(new DefaultResourceLoader())
.getResources("file:target/output/**");
for (Resource candidate : candidates) {
if (candidate.contentLength() == 0) {
if ((candidate.getFilename() != null
&& candidate.getFilename().endsWith(".writing"))
|| candidate.contentLength() == 0) {
return new Resource[0];
}
}