From 47ef986be7d45fc409eb56774325bfa5262e3944 Mon Sep 17 00:00:00 2001 From: jpraet Date: Mon, 4 Mar 2013 22:01:18 +0100 Subject: [PATCH 1/4] BATCH-1959 --- .../TransactionAwareBufferedWriter.java | 10 ++- .../item/file/FlatFileItemWriterTests.java | 78 ++++++++++++++++++- .../TransactionAwareBufferedWriterTests.java | 28 ++++++- 3 files changed, 110 insertions(+), 6 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriter.java index f5562d47c..5074fd49b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriter.java @@ -16,10 +16,12 @@ package org.springframework.batch.support.transaction; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import org.springframework.batch.item.WriteFailedException; import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -137,13 +139,17 @@ public class TransactionAwareBufferedWriter extends Writer { * Convenience method for clients to determine if there is any unflushed * data. * - * @return the current size of unflushed buffered data + * @return the current size (in bytes) of unflushed buffered data */ public long getBufferSize() { if (!transactionActive()) { return 0L; } - return getCurrentBuffer().length(); + try { + return getCurrentBuffer().toString().getBytes(encoding).length; + } catch (UnsupportedEncodingException e) { + throw new WriteFailedException("Could not determine buffer size because of unsupported encoding: " + encoding, e); + } } /** diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index 22d125aba..8ec1534a6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java @@ -25,8 +25,9 @@ import static org.junit.Assert.fail; import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.io.Writer; import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; @@ -88,6 +89,7 @@ public class FlatFileItemWriterTests { writer.setLineAggregator(new PassThroughLineAggregator()); writer.afterPropertiesSet(); writer.setSaveState(true); + writer.setEncoding("UTF-8"); executionContext = new ExecutionContext(); } @@ -110,7 +112,7 @@ public class FlatFileItemWriterTests { private String readLine() throws IOException { if (reader == null) { - reader = new BufferedReader(new FileReader(outputFile)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile), "UTF-8")); } return reader.readLine(); @@ -125,7 +127,7 @@ public class FlatFileItemWriterTests { reader = null; } } - + @Test public void testWriteWithMultipleOpen() throws Exception { writer.open(executionContext); @@ -429,6 +431,76 @@ public class FlatFileItemWriterTests { assertEquals(8, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); } + + @Test + // BATCH-1959 + public void testTransactionalRestartWithMultiByteCharacter() throws Exception { + + writer.setFooterCallback(new FlatFileFooterCallback() { + + @Override + public void writeFooter(Writer writer) throws IOException { + writer.write("footer"); + } + + }); + + writer.open(executionContext); + + PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); + + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + try { + // write some lines + writer.write(Arrays.asList(new String[] { "téstLine1", "téstLine2", "téstLine3" })); + // write more lines + writer.write(Arrays.asList(new String[] { "téstLine4", "téstLine5" })); + } + catch (Exception e) { + throw new UnexpectedInputException("Could not write data", e); + } + // get restart data + writer.update(executionContext); + return null; + } + }); + // close template + writer.close(); + + // init with correct data + writer.open(executionContext); + + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + try { + // write more lines + writer.write(Arrays.asList(new String[] { "téstLine6", "téstLine7", "téstLine8" })); + } + catch (Exception e) { + throw new UnexpectedInputException("Could not write data", e); + } + // get restart data + writer.update(executionContext); + return null; + } + }); + // close template + writer.close(); + + // verify what was written to the file + for (int i = 1; i <= 8; i++) { + assertEquals("téstLine" + i, readLine()); + } + + assertEquals("footer", readLine()); + + // 3 lines were written to the file after restart + assertEquals(3, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); + + } @Test public void testOpenWithNonWritableFile() throws Exception { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java index e1e5c3a27..dcba51971 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java @@ -63,6 +63,8 @@ public class TransactionAwareBufferedWriterTests { } } }); + + writer.setEncoding("UTF-8"); } private PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); @@ -100,7 +102,7 @@ public class TransactionAwareBufferedWriterTests { assertEquals(0, writer.getBufferSize()); } - + @Ignore //TODO - need to fix capture test @Test public void testCloseOutsideTransaction() throws Exception { @@ -183,6 +185,30 @@ public class TransactionAwareBufferedWriterTests { assertEquals(0, writer.getBufferSize()); } + + @Test + @SuppressWarnings({"unchecked", "rawtypes"}) + // BATCH-1959 + public void testBufferSizeInTransactionWithMultiByteCharacter() throws Exception { + ArgumentCaptor bb = ArgumentCaptor.forClass(ByteBuffer.class); + when(fileChannel.write(bb.capture())).thenReturn(5); + + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + try { + writer.write("fóó"); + } + catch (IOException e) { + throw new IllegalStateException("Unexpected IOException", e); + } + assertEquals(5, writer.getBufferSize()); + return null; + } + }); + + assertEquals(0, writer.getBufferSize()); + } @Test @SuppressWarnings({"unchecked", "rawtypes"}) From eb163b76087c0cdf7d829de0b14d1393a5f707cb Mon Sep 17 00:00:00 2001 From: jpraet Date: Tue, 19 Mar 2013 20:34:50 +0100 Subject: [PATCH 2/4] add additional tests with UTF-8 and UTF-16BE encoding --- .../item/file/FlatFileItemWriterTests.java | 34 +++++-- .../item/xml/StaxEventItemWriterTests.java | 89 ++++++++++++++++++- .../TransactionAwareBufferedWriterTests.java | 28 +++++- 3 files changed, 140 insertions(+), 11 deletions(-) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index 8ec1534a6..7d23c926e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java @@ -110,13 +110,22 @@ public class FlatFileItemWriterTests { * because running the tests in a UNIX environment locks the file if it's open for writing. */ private String readLine() throws IOException { + return readLine("UTF-8"); + } + + /* + * Read a line from the output file, if the reader has not been created, recreate. This method is only necessary + * because running the tests in a UNIX environment locks the file if it's open for writing. + */ + private String readLine(String encoding) throws IOException { if (reader == null) { - reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile), "UTF-8")); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile), encoding)); } return reader.readLine(); - } + } + /* * Properly close the output file reader. */ @@ -434,8 +443,18 @@ public class FlatFileItemWriterTests { @Test // BATCH-1959 - public void testTransactionalRestartWithMultiByteCharacter() throws Exception { + public void testTransactionalRestartWithMultiByteCharacterUTF8() throws Exception { + testTransactionalRestartWithMultiByteCharacter("UTF-8"); + } + @Test + // BATCH-1959 + public void testTransactionalRestartWithMultiByteCharacterUTF16BE() throws Exception { + testTransactionalRestartWithMultiByteCharacter("UTF-16BE"); + } + + private void testTransactionalRestartWithMultiByteCharacter(String encoding) throws Exception { + writer.setEncoding(encoding); writer.setFooterCallback(new FlatFileFooterCallback() { @Override @@ -492,15 +511,14 @@ public class FlatFileItemWriterTests { // verify what was written to the file for (int i = 1; i <= 8; i++) { - assertEquals("téstLine" + i, readLine()); + assertEquals("téstLine" + i, readLine(encoding)); } - assertEquals("footer", readLine()); + assertEquals("footer", readLine(encoding)); // 3 lines were written to the file after restart - assertEquals(3, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); - - } + assertEquals(3, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); + } @Test public void testOpenWithNonWritableFile() throws Exception { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java index 5b10370c1..a467fdaf7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java @@ -60,13 +60,26 @@ public class StaxEventItemWriterTests { private JAXBItem jaxbItem = new JAXBItem(); + // test item for writing to output with multi byte character + private Object itemMultiByte = new Object() { + @Override + public String toString() { + return ClassUtils.getShortName(StaxEventItemWriter.class) + "-téstStrïng"; + } + }; + private List items = Collections.singletonList(item); + private List itemsMultiByte = Collections.singletonList(itemMultiByte); + private List jaxbItems = Collections.singletonList(jaxbItem); private static final String TEST_STRING = "<" + ClassUtils.getShortName(StaxEventItemWriter.class) + "-testString/>"; + private static final String TEST_STRING_MULTI_BYTE = "<" + ClassUtils.getShortName(StaxEventItemWriter.class) + + "-téstStrïng/>"; + private static final String NS_TEST_STRING = ""; @@ -185,6 +198,68 @@ public class StaxEventItemWriterTests { assertTrue(outputFile.contains("" + TEST_STRING + TEST_STRING + "")); } + @Test + // BATCH-1959 + public void testTransactionalRestartWithMultiByteCharacterUTF8() throws Exception { + testTransactionalRestartWithMultiByteCharacter("UTF-8"); + } + + @Test + // BATCH-1959 + public void testTransactionalRestartWithMultiByteCharacterUTF16BE() throws Exception { + testTransactionalRestartWithMultiByteCharacter("UTF-16BE"); + } + + private void testTransactionalRestartWithMultiByteCharacter(String encoding) throws Exception { + writer.setEncoding(encoding); + writer.open(executionContext); + + PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); + + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + try { + // write item + writer.write(itemsMultiByte); + } + catch (Exception e) { + throw new UnexpectedInputException("Could not write data", e); + } + // get restart data + writer.update(executionContext); + return null; + } + }); + writer.close(); + + // create new writer from saved restart data and continue writing + writer = createItemWriter(); + writer.setEncoding(encoding); + writer.open(executionContext); + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + try { + writer.write(itemsMultiByte); + } + catch (Exception e) { + throw new UnexpectedInputException("Could not write data", e); + } + // get restart data + writer.update(executionContext); + return null; + } + }); + writer.close(); + + // check the output is concatenation of 'before restart' and 'after + // restart' writes. + String outputFile = getOutputFileContent(encoding); + assertEquals(2, StringUtils.countOccurrencesOf(outputFile, TEST_STRING_MULTI_BYTE)); + assertTrue(outputFile.contains("" + TEST_STRING_MULTI_BYTE + TEST_STRING_MULTI_BYTE + "")); + } + @Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testTransactionalRestartFailOnFirstWrite() throws Exception { @@ -692,11 +767,21 @@ public class StaxEventItemWriterTests { * @return output file content as String */ private String getOutputFileContent() throws IOException { - String value = FileUtils.readFileToString(resource.getFile(), null); - value = value.replace("", ""); + return getOutputFileContent("UTF-8"); + } + + + /** + * @param encoding the encoding + * @return output file content as String + */ + private String getOutputFileContent(String encoding) throws IOException { + String value = FileUtils.readFileToString(resource.getFile(), encoding); + value = value.replace("", ""); return value; } + /** * @return new instance of fully configured writer */ diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java index dcba51971..d562543e3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java @@ -189,7 +189,7 @@ public class TransactionAwareBufferedWriterTests { @Test @SuppressWarnings({"unchecked", "rawtypes"}) // BATCH-1959 - public void testBufferSizeInTransactionWithMultiByteCharacter() throws Exception { + public void testBufferSizeInTransactionWithMultiByteCharacterUTF8() throws Exception { ArgumentCaptor bb = ArgumentCaptor.forClass(ByteBuffer.class); when(fileChannel.write(bb.capture())).thenReturn(5); @@ -210,6 +210,32 @@ public class TransactionAwareBufferedWriterTests { assertEquals(0, writer.getBufferSize()); } + @Test + @SuppressWarnings({"unchecked", "rawtypes"}) + // BATCH-1959 + public void testBufferSizeInTransactionWithMultiByteCharacterUTF16BE() throws Exception { + writer.setEncoding("UTF-16BE"); + + ArgumentCaptor bb = ArgumentCaptor.forClass(ByteBuffer.class); + when(fileChannel.write(bb.capture())).thenReturn(6); + + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + try { + writer.write("fóó"); + } + catch (IOException e) { + throw new IllegalStateException("Unexpected IOException", e); + } + assertEquals(6, writer.getBufferSize()); + return null; + } + }); + + assertEquals(0, writer.getBufferSize()); + } + @Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testWriteWithRollback() throws Exception { From 215d47182e66faa7675586d82acae721cb186c02 Mon Sep 17 00:00:00 2001 From: jpraet Date: Wed, 20 Mar 2013 20:34:21 +0100 Subject: [PATCH 3/4] fix assertion (see BATCH-1957: WRITTEN_STATISTICS_NAME in execution context now contains TOTAL number of records written) --- .../batch/item/file/FlatFileItemWriterTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index 7d23c926e..20451b479 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java @@ -516,8 +516,8 @@ public class FlatFileItemWriterTests { assertEquals("footer", readLine(encoding)); - // 3 lines were written to the file after restart - assertEquals(3, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); + // 8 lines were written to the file in total + assertEquals(8, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); } @Test From f01ef38e987be1786ae3d55ffe27f1581080928e Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Thu, 21 Mar 2013 10:08:12 -0500 Subject: [PATCH 4/4] BATCH-1959: Fixed whitespace issues --- .../item/file/FlatFileItemWriterTests.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index 20451b479..4e9c0a764 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java @@ -112,7 +112,7 @@ public class FlatFileItemWriterTests { private String readLine() throws IOException { return readLine("UTF-8"); } - + /* * Read a line from the output file, if the reader has not been created, recreate. This method is only necessary * because running the tests in a UNIX environment locks the file if it's open for writing. @@ -124,8 +124,8 @@ public class FlatFileItemWriterTests { } return reader.readLine(); - } - + } + /* * Properly close the output file reader. */ @@ -136,7 +136,7 @@ public class FlatFileItemWriterTests { reader = null; } } - + @Test public void testWriteWithMultipleOpen() throws Exception { writer.open(executionContext); @@ -242,7 +242,7 @@ public class FlatFileItemWriterTests { @Test public void testWriteWithConverter() throws Exception { writer.setLineAggregator(new LineAggregator() { - @Override + @Override public String aggregate(String item) { return "FOO:" + item; } @@ -263,7 +263,7 @@ public class FlatFileItemWriterTests { @Test public void testWriteWithConverterAndString() throws Exception { writer.setLineAggregator(new LineAggregator() { - @Override + @Override public String aggregate(String item) { return "FOO:" + item; } @@ -301,7 +301,7 @@ public class FlatFileItemWriterTests { writer.setFooterCallback(new FlatFileFooterCallback() { - @Override + @Override public void writeFooter(Writer writer) throws IOException { writer.write("footer"); } @@ -356,7 +356,7 @@ public class FlatFileItemWriterTests { writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { - @Override + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(Collections.singletonList(TEST_STRING)); @@ -377,7 +377,7 @@ public class FlatFileItemWriterTests { writer.setFooterCallback(new FlatFileFooterCallback() { - @Override + @Override public void writeFooter(Writer writer) throws IOException { writer.write("footer"); } @@ -389,7 +389,7 @@ public class FlatFileItemWriterTests { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { - @Override + @Override public Object doInTransaction(TransactionStatus status) { try { // write some lines @@ -412,7 +412,7 @@ public class FlatFileItemWriterTests { writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { - @Override + @Override public Object doInTransaction(TransactionStatus status) { try { // write more lines @@ -440,7 +440,7 @@ public class FlatFileItemWriterTests { assertEquals(8, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); } - + @Test // BATCH-1959 public void testTransactionalRestartWithMultiByteCharacterUTF8() throws Exception { @@ -457,7 +457,7 @@ public class FlatFileItemWriterTests { writer.setEncoding(encoding); writer.setFooterCallback(new FlatFileFooterCallback() { - @Override + @Override public void writeFooter(Writer writer) throws IOException { writer.write("footer"); } @@ -469,7 +469,7 @@ public class FlatFileItemWriterTests { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { - @Override + @Override public Object doInTransaction(TransactionStatus status) { try { // write some lines @@ -492,7 +492,7 @@ public class FlatFileItemWriterTests { writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { - @Override + @Override public Object doInTransaction(TransactionStatus status) { try { // write more lines @@ -517,7 +517,7 @@ public class FlatFileItemWriterTests { assertEquals("footer", readLine(encoding)); // 8 lines were written to the file in total - assertEquals(8, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); + assertEquals(8, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".written")); } @Test @@ -604,7 +604,7 @@ public class FlatFileItemWriterTests { public void testWriteFooter() throws Exception { writer.setFooterCallback(new FlatFileFooterCallback() { - @Override + @Override public void writeFooter(Writer writer) throws IOException { writer.write("a\nb"); } @@ -622,7 +622,7 @@ public class FlatFileItemWriterTests { public void testWriteHeader() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { - @Override + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -642,7 +642,7 @@ public class FlatFileItemWriterTests { @Test public void testWriteWithAppendAfterHeaders() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { - @Override + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -668,7 +668,7 @@ public class FlatFileItemWriterTests { public void testWriteHeaderAndDeleteOnExit() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { - @Override + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -693,12 +693,12 @@ public class FlatFileItemWriterTests { writer.write(Collections.singletonList("test2")); assertEquals("test2", readLine()); } - + @Test public void testWriteHeaderAndDeleteOnExitReopen() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { - @Override + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -716,8 +716,8 @@ public class FlatFileItemWriterTests { assertEquals("a", readLine()); assertEquals("b", readLine()); assertEquals("test2", readLine()); - } - + } + @Test public void testDeleteOnExitNoRecordsWrittenAfterRestart() throws Exception { writer.setShouldDeleteIfEmpty(true); @@ -735,7 +735,7 @@ public class FlatFileItemWriterTests { public void testWriteHeaderAfterRestartOnFirstChunk() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { - @Override + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -761,7 +761,7 @@ public class FlatFileItemWriterTests { public void testWriteHeaderAfterRestartOnSecondChunk() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { - @Override + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -800,7 +800,7 @@ public class FlatFileItemWriterTests { writer.setLineAggregator(new LineAggregator() { - @Override + @Override public String aggregate(String item) { if (item.equals("2")) { throw new RuntimeException("aggregation failed on " + item);