+ @Test
+ public void test_printTable_withNulls() throws IOException, SQLException
+ {
+ DbDriverMock driver = new DbDriverMock();
+
+ TabularMock tabular = createTableWithNulls();
+ driver.set(DbDriver.SUPPRESS_NULLS, true);
+
+ try (
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8));
+ )
+ {
+ tabular.printTable(driver, pw, "No rows returned.");
+ pw.close();
+ baos.close();
+ String actual = baos.toString();
+ assertEquals( "+---------+--------+------------+\n"
+ + "| EmpId | Value1 | Value3 |\n"
+ + "+---------+--------+------------+\n"
+ + "| 12345 | Fred | Flintstone |\n"
+ + "| 7654321 | Barney | Rubble |\n"
+ + "+---------+--------+------------+\n"
+ + "2 row(s) returned.\n",
+ actual);
+ }
+
+ tabular = createTableWithNulls();
+ driver.set(DbDriver.SUPPRESS_NULLS, false);
+
+ try (
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8));
+ )
+ {
+ tabular.printTable(driver, pw, "No rows returned.");
+ pw.close();
+ baos.close();
+ String actual = baos.toString();
+ assertEquals( "+---------+--------+--------+------------+\n"
+ + "| EmpId | Value1 | Value2 | Value3 |\n"
+ + "+---------+--------+--------+------------+\n"
+ + "| 12345 | Fred | null | Flintstone |\n"
+ + "| 7654321 | Barney | null | Rubble |\n"
+ + "+---------+--------+--------+------------+\n"
+ + "2 row(s) returned.\n",
+ actual);
+ }
+
+ }
+