BATCH-1681: fix XML output on restart

This commit is contained in:
Dave Syer
2011-02-07 09:18:54 +00:00
parent ba86cbcdde
commit 8b06574c8e
2 changed files with 10 additions and 3 deletions

View File

@@ -378,9 +378,15 @@ public class StaxEventItemWriter<T> extends ExecutionContextUserSupport implemen
// Woodstox >= 3.2.9 we want to disable its
// automatic end element feature (see:
// http://jira.codehaus.org/browse/WSTX-165) per
// http://jira.springframework.org/browse/BATCH-761.
// http://jira.springframework.org/browse/BATCH-761).
outputFactory.setProperty("com.ctc.wstx.automaticEndElements", Boolean.FALSE);
}
if (outputFactory.isPropertySupported("com.ctc.wstx.outputValidateStructure")) {
// On restart we don't write the root element so we have to disable
// structural validation (see:
// http://jira.springframework.org/browse/BATCH-1681).
outputFactory.setProperty("com.ctc.wstx.outputValidateStructure", Boolean.FALSE);
}
try {
if (transactional) {

View File

@@ -106,13 +106,14 @@ public class StaxEventItemWriterTests {
writer = createItemWriter();
writer.open(executionContext);
writer.write(items);
writer.write(items);
writer.close();
// check the output is concatenation of 'before restart' and 'after
// restart' writes.
String outputFile = getOutputFileContent();
assertEquals(2, StringUtils.countOccurrencesOf(outputFile, TEST_STRING));
assertEquals("<root>" + TEST_STRING + TEST_STRING + "</root>", outputFile.replace(" ", ""));
assertEquals(3, StringUtils.countOccurrencesOf(outputFile, TEST_STRING));
assertEquals("<root>" + TEST_STRING + TEST_STRING + TEST_STRING + "</root>", outputFile.replace(" ", ""));
}
@Test