File-split-ftp: fix read files race condition

https://build.spring.io/browse/INTSAMPLES-NIGHTLY-1898/

There is no guarantee that if `File.exists()`, the real write to file has occurred

 * Add `while()` to check not only `File.exists()` but also its `length()` only after that proceed to assert logic
This commit is contained in:
Artem Bilan
2016-10-25 10:34:54 -04:00
parent 171dd51024
commit e35d441691

View File

@@ -118,12 +118,20 @@ public class ApplicationTests {
br.close();
out.delete();
out = new File("/tmp/out/006.txt");
n = 0;
while(n++ < 100 && (!out.exists() || out.length() < 12)) {
Thread.sleep(100);
}
assertThat(out.exists()).isTrue();
br = new BufferedReader(new FileReader(out));
assertThat(br.readLine()).isEqualTo("*006,baz,qux");
br.close();
out.delete();
out = new File("/tmp/out/009.txt");
n = 0;
while(n++ < 100 && (!out.exists() || out.length() < 12)) {
Thread.sleep(100);
}
assertThat(out.exists()).isTrue();
br = new BufferedReader(new FileReader(out));
assertThat(br.readLine()).isEqualTo("*009,fiz,buz");