Fix compiler warning.

This commit is contained in:
Gary Gregory 2018-05-18 13:47:37 -06:00
parent 5c0d27c0e2
commit 33f662b219
1 changed files with 20 additions and 19 deletions

View File

@ -1352,33 +1352,34 @@ public class CSVPrinterTest {
@Test @Test
public void testCloseBackwardCompatibility() throws IOException { public void testCloseBackwardCompatibility() throws IOException {
final Writer writer = mock(Writer.class); try (final Writer writer = mock(Writer.class)) {
final CSVFormat csvFormat = CSVFormat.DEFAULT; final CSVFormat csvFormat = CSVFormat.DEFAULT;
try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) {
} }
verify(writer, never()).flush(); verify(writer, never()).flush();
verify(writer, times(1)).close(); verify(writer, times(1)).close();
} }}
@Test @Test
public void testCloseWithCsvFormatAutoFlushOn() throws IOException { public void testCloseWithCsvFormatAutoFlushOn() throws IOException {
// System.out.println("start method"); // System.out.println("start method");
final Writer writer = mock(Writer.class); try (final Writer writer = mock(Writer.class)) {
final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(true); final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(true);
try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) {
} }
verify(writer, times(1)).flush(); verify(writer, times(1)).flush();
verify(writer, times(1)).close(); verify(writer, times(1)).close();
} }}
@Test @Test
public void testCloseWithCsvFormatAutoFlushOff() throws IOException { public void testCloseWithCsvFormatAutoFlushOff() throws IOException {
final Writer writer = mock(Writer.class); try (final Writer writer = mock(Writer.class)) {
final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(false); final CSVFormat csvFormat = CSVFormat.DEFAULT.withAutoFlush(false);
try (CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) { 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();
} }
} }