### Question:
LogViewer { static String highlightLine(String data, final int lineNumber) { data = data.replaceAll("\\r", ""); String[] lines = data.split("\n"); StringBuffer sb = new StringBuffer(); int len = lines.length; StringBuffer tmpBuf = new StringBuffer(); for (int i = 0; i < len; i++) { tmpBuf.append(lines[i]); if ((i + 1) == lineNumber) { tmpBuf.insert(0, "<a name='selected'><b>").append("</b></a>"); } tmpBuf.insert(0, "</span> "); tmpBuf.insert(0, (i + 1)); tmpBuf.insert(0, "<span>"); tmpBuf.append("\n"); sb.append(tmpBuf.toString()); tmpBuf.setLength(0); } return sb.toString(); }  static String getLogsList2(final String logsRootDir); static String getLogsList(final String logsRootDir); static String highlight(final String data, final int lineNumber); static String addLineNumbers(String orig, String scriptPath);  }### Answer:
@Test public void testHighlightLine() { assertEquals("<span>1</span> <a name='selected'><b>one</b></a>\n<span>2</span> two\n<span>3</span> three\n<span>4</span> four\n", LogViewer.highlightLine("one\ntwo\nthree\r\nfour", 1)); assertEquals("<span>1</span> one\n<span>2</span> <a name='selected'><b>two</b></a>\n<span>3</span> three\n<span>4</span> four\n", LogViewer.highlightLine("one\ntwo\nthree\nfour", 2)); assertEquals("<span>1</span> one\n<span>2</span> two\n<span>3</span> three\n<span>4</span> <a name='selected'><b>four</b></a>\n", LogViewer.highlightLine("one\ntwo\nthree\nfour", 4)); assertEquals("<span>1</span> one\n<span>2</span> two\n<span>3</span> three\n<span>4</span> four\n", LogViewer.highlightLine("one\ntwo\nthree\nfour", -1)); assertEquals("<span>1</span> one\n<span>2</span> two\n<span>3</span> three\n<span>4</span> four\n", LogViewer.highlightLine("one\ntwo\nthree\nfour", 0)); }