Skip to content

Commit bf3f34c

Browse files
author
Gary Gregory
committed
Address compiler warnings.
1 parent 4e02db1 commit bf3f34c

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
import org.apache.commons.io.FileUtils;
5454
import org.apache.commons.lang3.StringUtils;
5555
import org.h2.tools.SimpleResultSet;
56-
import org.h2.value.Value;
57-
import org.h2.value.ValueArray;
5856
import org.junit.Assert;
5957
import org.junit.Ignore;
6058
import org.junit.Test;
@@ -260,21 +258,25 @@ public void testCloseWithCsvFormatAutoFlushOn() throws IOException {
260258

261259
@Test
262260
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+
}
269269
}
270270

271271
@Test
272272
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+
}
278280
}
279281

280282
@Test

0 commit comments

Comments
 (0)