### Question:
LogViewer { public static String getLogsList(final String logsRootDir) { File[] fileList = new File(logsRootDir).listFiles(); Comparator<File> comparator = new LastModifiedComparator(); Arrays.sort(fileList, comparator); StringBuffer sb = new StringBuffer(); for (int i = 0; i < fileList.length; i++) { String fileName = fileList[i].getName(); if (fileName.endsWith(".htm") || fileList[i].isDirectory()) { sb.append("<a href='/_s_/dyn/Log_viewLogs/"); sb.append(getSummaryFile(fileList[i])); sb.append("'>"); sb.append(fileName); sb.append("</a><br>"); } } 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 testGetLogsList() throws IOException, InterruptedException { new File(dir, "log3.htm").createNewFile(); new File(dir, "log2.htm").createNewFile(); new File(dir, "dummy.txt").createNewFile(); Thread.sleep(100); File subDir = new File(dir, "subDir"); subDir.mkdirs(); new File(subDir, "blah.htm").createNewFile(); String expected1 = "<a href='/_s_/dyn/Log_viewLogs/subDir/index.htm'>subDir</a><br>"; String expected2 = "<a href='/_s_/dyn/Log_viewLogs/log2.htm'>log2.htm</a><br>"; String expected3 = "<a href='/_s_/dyn/Log_viewLogs/log3.htm'>log3.htm</a><br>"; String actual = LogViewer.getLogsList(dir.getAbsolutePath()); assertTrue(actual.indexOf(expected1) != 1); assertTrue(actual.indexOf(expected2) != 1); assertTrue(actual.indexOf(expected3) != 1); }