JLogList extends JPanel { public void addLine(Object line) { if (!isEnabled()) { return; } if (line instanceof LoggingEvent) { LoggingEvent ev = (LoggingEvent) line; linesToAdd.add(new LoggingEventWrapper(ev)); if (ev.getThrowableInformation() != null) { Throwable t = ev.getThrowableInformation().getThrowable(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); StringTokenizer st = new StringTokenizer(sw.toString(), "\r\n"); while (st.hasMoreElements()) { linesToAdd.add(" " + st.nextElement()); } } } else { linesToAdd.add(line); } model.ensureUpdateIsStarted(); } JLogList(String title); void clear(); JList getLogList(); long getMaxRows(); void setMaxRows(long maxRows); void addLine(Object line); void setEnabled(boolean enabled); void addLogger(String loggerName, boolean addAppender); Logger[] getLoggers(); void setLevel(Level level); Logger getLogger(String loggerName); boolean monitors(String loggerName); void removeLogger(String loggerName); void saveToFile(File file); boolean isTailing(); void setTailing(boolean tail);  }
@Test public void addsLogLinesInCorrectOrder() throws Exception { for (int i = 0; i < 20 + 1; i++) { logList.addLine("Line " + i); } waitForUpdaterThread(); for (int i = 0; i < 20 + 1; i++) { assertThat((String) model.getElementAt(i), is("Line " + i)); } }