Search in sources :

Example 1 with ThreadIO

use of org.apache.felix.service.threadio.ThreadIO in project karaf by apache.

the class ShellTableTest method testNonUtf8.

private void testNonUtf8(String encoding) throws Exception {
    ShellTable table = new ShellTable();
    table.column("col1");
    table.column("col2").maxSize(-1).wrap();
    table.addRow().addContent("my first column value", "my second column value is quite long");
    table.size(50);
    ThreadIO tio = new ThreadIOImpl();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos, false, encoding);
    table.print(ps, true);
    tio.setStreams(new FileInputStream(FileDescriptor.in), ps, ps);
    table.print(System.out);
    assertEquals("col1                  | col2\n" + "----------------------+---------------------------\n" + "my first column value | my second column value is\n" + "                      | quite long\n" + "col1                  | col2\n" + "----------------------+---------------------------\n" + "my first column value | my second column value is\n" + "                      | quite long\n", baos.toString());
}
Also used : ThreadIO(org.apache.felix.service.threadio.ThreadIO) PrintStream(java.io.PrintStream) ThreadIOImpl(org.apache.felix.gogo.runtime.threadio.ThreadIOImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileInputStream(java.io.FileInputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 PrintStream (java.io.PrintStream)1 ThreadIOImpl (org.apache.felix.gogo.runtime.threadio.ThreadIOImpl)1 ThreadIO (org.apache.felix.service.threadio.ThreadIO)1