Skip to content

Commit 3241e0c

Browse files
author
Gary Gregory
committed
Be quiet on the console.
1 parent 8eb36bd commit 3241e0c

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.CharArrayWriter;
3030
import java.io.File;
3131
import java.io.IOException;
32+
import java.io.PrintStream;
3233
import java.io.StringReader;
3334
import java.io.StringWriter;
3435
import java.io.Writer;
@@ -51,6 +52,7 @@
5152
import java.util.Vector;
5253

5354
import org.apache.commons.io.FileUtils;
55+
import org.apache.commons.io.output.NullOutputStream;
5456
import org.apache.commons.lang3.StringUtils;
5557
import org.h2.tools.SimpleResultSet;
5658
import org.junit.Assert;
@@ -1243,12 +1245,18 @@ public void testPrintOnePositiveInteger() throws IOException {
12431245

12441246
@Test
12451247
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);
12521260
}
12531261
}
12541262

0 commit comments

Comments
 (0)