BATCH-1881: added forceSync flag to file writers

This commit is contained in:
Dave Syer
2012-07-27 13:54:52 +01:00
parent 1449eb3dc3
commit be7754bed4
4 changed files with 88 additions and 18 deletions

View File

@@ -202,6 +202,17 @@ public class FlatFileItemWriterTests {
assertEquals(TEST_STRING, lineFromFile);
}
@Test
public void testForcedWriteString() throws Exception {
writer.setForceSync(true);
writer.open(executionContext);
writer.write(Collections.singletonList(TEST_STRING));
writer.close();
String lineFromFile = readLine();
assertEquals(TEST_STRING, lineFromFile);
}
/**
* Regular usage of <code>write(String)</code> method
*

View File

@@ -90,6 +90,16 @@ public class StaxEventItemWriterTests {
assertTrue("Wrong content: " + content, content.contains(TEST_STRING));
}
@Test
public void testWriteAndForceFlush() throws Exception {
writer.setForceSync(true);
writer.open(executionContext);
writer.write(items);
writer.close();
String content = getOutputFileContent();
assertTrue("Wrong content: " + content, content.contains(TEST_STRING));
}
/**
* Restart scenario - content is appended to the output file after restart.
*/