コード例 #1
0
  /**
   * Prints dots at a capped rate, conflating the requested type of dot to draw if this method is
   * called at a rate higher than the capped rate. The conflation works by always printing the worst
   * result that occurs within the conflation period, that is, error is worse than fail which is
   * worse than a pass.
   *
   * @param result The type of dot to draw, {@link #PASS}, {@link #FAIL} or {@link #ERROR}.
   */
  private void throttledPrint(int result) {
    conflatedResult = (result > conflatedResult) ? result : conflatedResult;

    if (throttle.checkThrottle()) {
      synchronized (printMonitor) {
        switch (conflatedResult) {
          default:
          case PASS:
            System.out.print('.');
            break;

          case FAIL:
            System.out.print('F');
            break;

          case ERROR:
            System.out.print('E');
            break;
        }

        columnCount = (columnCount >= MAX_COLUMNS) ? 0 : (columnCount + 1);

        if (columnCount == 0) {
          System.out.print('\n');
        }

        conflatedResult = 0;
      }
    }
  }
コード例 #2
0
  /** Continually updates the clock, until {@link #terminate()} is called. */
  public void run() {
    while (doSynch) {
      // Perform a clock clockSynch.
      try {
        // Wait controlled by the throttle before doing the next synch.
        throttle.throttle();

        clockSyncher.synch();
        log.debug(
            "Clock synched, delta = "
                + clockSyncher.getDelta()
                + ", epsilon = "
                + clockSyncher.getEpsilon()
                + ".");
      }
      // Terminate the synch thread if the synchronization cannot be achieved.
      catch (ClockSynchFailureException e) {
        log.debug(
            "Cannot synchronize the clock (reference service may be down). Terminating the synch thread.");
        doSynch = false;
      }
    }
  }
コード例 #3
0
 /**
  * Creates a dot drawing feedback test listener, set by default to 80 columns at 80 dots per
  * second capped rate.
  */
 public ConsoleTestListener() {
   throttle = new SleepThrottle();
   throttle.setRate(80f);
 }