@Timeout
  public void handletimeout(Timer timer) {
    // delete temp files

    for (File f : deleteTempFileList) {
      dbgLog.fine("file to be deleted: path=" + f.getAbsolutePath() + "\tname=" + f.getName());
      if (f.exists()) {
        boolean sc = f.delete();
        if (!sc) {
          dbgLog.fine(
              "failed to delete file: path=" + f.getAbsolutePath() + "\tname=" + f.getName());
        } else {
          dbgLog.fine("successfully deleted? let's check its existence");
          if (f.exists()) {
            dbgLog.fine("surprise: actually the File still exists");
          } else {
            dbgLog.fine("The file no longer exists");
          }
        }
      }
    }
  }
Пример #2
0
  /**
   * Log all test case results to file. Depend on 'log' configuration details will be log or not.
   *
   * @throws IOException
   */
  public void logToFile() throws IOException {
    /*
    // Generate file name
    String DATE_FORMAT_NOW = "yyyyMMddHHmmssmm";
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);

    //String fileName = "report-" + sdf.format(cal.getTime())+ "-" + ran.nextInt(100);
    //System.out.println("File Name is : " + oi.reportFilePath + fileName);
     *
     */

    String fileName = init.defaultReportFileName;

    // Create new file
    File reportFile = new File("C:\\" + fileName + ".csv");
    if (reportFile.exists() == false) {
      reportFile.createNewFile();
    }

    // Write log to reportFile
    FileWriter outFile = new FileWriter(reportFile, true);
    PrintWriter out = new PrintWriter(outFile, true);

    Iterator<?> stepper = oi.logList.iterator();

    while (stepper.hasNext()) {
      out.println(stepper.next());
    }

    out.close();

    System.out.println("File Name is : " + reportFile);

    // Clear logList
    oi.logList = new ArrayList<String>();
  }