Exemplo n.º 1
0
 private String runCreateFileAndGetContent(String[] args) throws Exception {
   updater.parseCommandLine(args);
   File resultFile = updater.createUpdateList();
   String content = FileUtil.getFileContent(resultFile);
   FileUtil.deleteFile(resultFile);
   return content;
 }
Exemplo n.º 2
0
 @Test
 public void testLogLineInNewFile() throws Exception {
   Calendar time = (Calendar) ld.time.clone();
   time.add(Calendar.DATE, 1);
   LogData nextDay = new LogData(ld.host, time, ld.requestLine, ld.status, ld.size, ld.username);
   l.log(ld);
   l.log(nextDay);
   l.close();
   File firstFile = getLogFileFor(ld);
   File secondFile = getLogFileFor(nextDay);
   assertTrue(firstFile.exists());
   assertTrue(secondFile.exists());
   String firstContent = FileUtil.getFileContent(firstFile);
   assertEquals(l.formatLogLine(ld) + System.getProperty("line.separator"), firstContent);
   String secondContent = FileUtil.getFileContent(secondFile);
   assertEquals(l.formatLogLine(nextDay) + System.getProperty("line.separator"), secondContent);
 }
Exemplo n.º 3
0
 private Response generateXMLResponse(File file) {
   try {
     response.setContent(FileUtil.getFileContent(file));
   } catch (IOException e) {
     response.setContent("Error: Unable to read file '" + file.getName() + "'\n");
   }
   response.setContentType(Format.XML);
   return response;
 }
Exemplo n.º 4
0
 @Test
 public void testLoggingOneLineInNewFile() throws Exception {
   l.log(ld);
   l.close();
   File dir = l.getDirectory();
   File file = new File(dir, filename);
   assertTrue(file.exists());
   String contents = FileUtil.getFileContent(file);
   assertEquals(logLine + System.getProperty("line.separator"), contents);
 }
Exemplo n.º 5
0
 @Test
 public void testLoggingIncludesUsername() throws Exception {
   ld = new LogData(ld.host, ld.time, ld.requestLine, ld.status, ld.size, "Joe");
   l.log(ld);
   l.close();
   File dir = l.getDirectory();
   File file = new File(dir, filename);
   assertTrue(file.exists());
   String contents = FileUtil.getFileContent(file);
   logLine = "myHost - Joe [06/Mar/2003:13:42:05 -0100] \"request\" 42 666";
   assertEquals(logLine + System.getProperty("line.separator"), contents);
 }
Exemplo n.º 6
0
 @Test
 public void shouldPutSpecialFilesInDifferentList() throws Exception {
   String arg1 = "-doNotReplace:MasterFolder/TestFolder/fitnesse.css";
   String arg2 = "-doNotReplace:MasterFolder/TestFolder/fitnesse_print.css";
   updater.parseCommandLine(new String[] {arg1, arg2, "MasterFolder/TestFolder"});
   File doNotUpdateFile = updater.createDoNotUpdateList();
   String doNotUpdateContent = FileUtil.getFileContent(doNotUpdateFile);
   FileUtil.deleteFile(doNotUpdateFile);
   assertSubString("TestFolder/fitnesse.css", doNotUpdateContent);
   assertSubString("TestFolder/fitnesse_print.css", doNotUpdateContent);
   assertDoesntHaveRegexp("TestFolder/TestFile", doNotUpdateContent);
 }
Exemplo n.º 7
0
  private Response makeTestExecutionReportResponse(
      Request request, Date resultDate, TestResultRecord testResultRecord) throws Exception {
    if (formatIsXML(request)) return generateXMLResponse(testResultRecord.getFile());
    ExecutionReport report;

    String content = FileUtil.getFileContent(testResultRecord.getFile());
    report = ExecutionReport.makeReport(content);
    if (report instanceof TestExecutionReport) {
      report.setDate(resultDate);
      return generateHtmlTestExecutionResponse(request, (TestExecutionReport) report);
    } else if (report instanceof SuiteExecutionReport) {
      pageTitle.setPageType("Suite History");
      return generateHtmlSuiteExecutionResponse(request, (SuiteExecutionReport) report);
    } else return makeCorruptFileResponse(request);
  }