Code example for StringWriter

0
        assertEquals(expected, line);
    } 
 
    private ConsoleReader createConsole(byte[] bytes) throws Exception {
        InputStream in = new ByteArrayInputStream(bytes);
        Writer writer = new StringWriter();
        ConsoleReader reader = new ConsoleReader(in, writer);
        reader.setHistory(createSeededHistory());
        return reader;
    } 
 
    private History createSeededHistory() { 
        History history = new MemoryHistory();
        history.add("dir");
        history.add("cd c:\\");
        history.add("mkdir monkey");
        return history;
    } 
 
    @Test 
    public void testDeleteAndBackspaceKeymappings() throws Exception {