|
29 | 29 | import java.io.CharArrayWriter; |
30 | 30 | import java.io.File; |
31 | 31 | import java.io.IOException; |
| 32 | +import java.io.PrintStream; |
32 | 33 | import java.io.StringReader; |
33 | 34 | import java.io.StringWriter; |
34 | 35 | import java.io.Writer; |
|
51 | 52 | import java.util.Vector; |
52 | 53 |
|
53 | 54 | import org.apache.commons.io.FileUtils; |
| 55 | +import org.apache.commons.io.output.NullOutputStream; |
54 | 56 | import org.apache.commons.lang3.StringUtils; |
55 | 57 | import org.h2.tools.SimpleResultSet; |
56 | 58 | import org.junit.Assert; |
@@ -1243,12 +1245,18 @@ public void testPrintOnePositiveInteger() throws IOException { |
1243 | 1245 |
|
1244 | 1246 | @Test |
1245 | 1247 | public void testPrintRecordsWithEmptyVector() throws IOException { |
1246 | | - try (CSVPrinter csvPrinter = CSVFormat.POSTGRESQL_TEXT.printer()) { |
1247 | | - final Vector<CSVFormatTest.EmptyEnum> vector = new Vector<>(); |
1248 | | - final int expectedCapacity = 23; |
1249 | | - vector.setSize(expectedCapacity); |
1250 | | - csvPrinter.printRecords(vector); |
1251 | | - assertEquals(expectedCapacity, vector.capacity()); |
| 1248 | + final PrintStream out = System.out; |
| 1249 | + try { |
| 1250 | + System.setOut(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)); |
| 1251 | + try (CSVPrinter csvPrinter = CSVFormat.POSTGRESQL_TEXT.printer()) { |
| 1252 | + final Vector<CSVFormatTest.EmptyEnum> vector = new Vector<>(); |
| 1253 | + final int expectedCapacity = 23; |
| 1254 | + vector.setSize(expectedCapacity); |
| 1255 | + csvPrinter.printRecords(vector); |
| 1256 | + assertEquals(expectedCapacity, vector.capacity()); |
| 1257 | + } |
| 1258 | + } finally { |
| 1259 | + System.setOut(out); |
1252 | 1260 | } |
1253 | 1261 | } |
1254 | 1262 |
|
|
0 commit comments