|
53 | 53 | import org.apache.commons.io.FileUtils; |
54 | 54 | import org.apache.commons.lang3.StringUtils; |
55 | 55 | import org.h2.tools.SimpleResultSet; |
56 | | -import org.h2.value.Value; |
57 | | -import org.h2.value.ValueArray; |
58 | 56 | import org.junit.Assert; |
59 | 57 | import org.junit.Ignore; |
60 | 58 | import org.junit.Test; |
@@ -260,21 +258,25 @@ public void testCloseWithCsvFormatAutoFlushOn() throws IOException { |
260 | 258 |
|
261 | 259 | @Test |
262 | 260 | public void testCloseWithFlushOff() throws IOException { |
263 | | - final Writer writer = mock(Writer.class); |
264 | | - final CSVFormat csvFormat = CSVFormat.DEFAULT; |
265 | | - final CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat); |
266 | | - csvPrinter.close(false); |
267 | | - verify(writer, never()).flush(); |
268 | | - verify(writer, times(1)).close(); |
| 261 | + try (final Writer writer = mock(Writer.class)) { |
| 262 | + final CSVFormat csvFormat = CSVFormat.DEFAULT; |
| 263 | + @SuppressWarnings("resource") |
| 264 | + final CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat); |
| 265 | + csvPrinter.close(false); |
| 266 | + verify(writer, never()).flush(); |
| 267 | + verify(writer, times(1)).close(); |
| 268 | + } |
269 | 269 | } |
270 | 270 |
|
271 | 271 | @Test |
272 | 272 | public void testCloseWithFlushOn() throws IOException { |
273 | | - final Writer writer = mock(Writer.class); |
274 | | - final CSVFormat csvFormat = CSVFormat.DEFAULT; |
275 | | - final CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat); |
276 | | - csvPrinter.close(true); |
277 | | - verify(writer, times(1)).flush(); |
| 273 | + try (final Writer writer = mock(Writer.class)) { |
| 274 | + final CSVFormat csvFormat = CSVFormat.DEFAULT; |
| 275 | + @SuppressWarnings("resource") |
| 276 | + final CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat); |
| 277 | + csvPrinter.close(true); |
| 278 | + verify(writer, times(1)).flush(); |
| 279 | + } |
278 | 280 | } |
279 | 281 |
|
280 | 282 | @Test |
|
0 commit comments