From 33f662b219b439af5134de4553a1bb9485136999 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 18 May 2018 13:47:37 -0600 Subject: [PATCH] Fix compiler warning. --- .../apache/commons/csv/CSVPrinterTest.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index 36308c53..45c84459 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -1352,33 +1352,34 @@ public class CSVPrinterTest { @Test public void testCloseBackwardCompatibility() throws IOException { - final Writer writer = mock(Writer.class); - final CSVFormat csvFormat = CSVFormat.DEFAULT; - try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { - } - verify(writer, never()).flush(); - verify(writer, times(1)).close(); - } + try (final Writer writer = mock(Writer.class)) { + final CSVFormat csvFormat = CSVFormat.DEFAULT; + try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { + } + verify(writer, never()).flush(); + verify(writer, times(1)).close(); + }} @Test public void testCloseWithCsvFormatAutoFlushOn() throws IOException { // System.out.println("start method"); - final Writer writer = mock(Writer.class); - final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(true); - try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { - } - verify(writer, times(1)).flush(); - verify(writer, times(1)).close(); - } + try (final Writer writer = mock(Writer.class)) { + final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(true); + try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { + } + verify(writer, times(1)).flush(); + verify(writer, times(1)).close(); + }} @Test public void testCloseWithCsvFormatAutoFlushOff() throws IOException { - final Writer writer = mock(Writer.class); - final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(false); - try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { + try (final Writer writer = mock(Writer.class)) { + final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(false); + try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { + } + verify(writer, never()).flush(); + verify(writer, times(1)).close(); } - verify(writer, never()).flush(); - verify(writer, times(1)).close(); } }