package org.threadly.test.concurrent;

/**
 * Generic tools to be used in unit testing.
 * 
 * @author jent - Mike Jensen
 */
public class TestUtils {
  private TestUtils() {
    // don't construct
  }
  
  /**
   * Since sleeps are sometimes necessary, this makes
   * an easy way to ignore InterruptedException's.
   * 
   * @param time time in milliseconds to make the thread to sleep
   */
  public static void sleep(long time) {
    try {
      Thread.sleep(time);
    } catch (InterruptedException e) {
      // ignored
    }
  }
  
  /**
   * Blocks until the System clock advances at least 1 millisecond.
   */
  public static void blockTillClockAdvances() {
    new TestCondition() {
      private static final int TIMEOUT_IN_MS = 1000;
      private static final int POLL_INTERVAL_IN_MS = 1;
      
      private final long startTime = System.currentTimeMillis();
      
      @Override
      public boolean get() {
        return System.currentTimeMillis() != startTime;
      }
      
      @Override
      public void blockTillTrue() {
        blockTillTrue(TIMEOUT_IN_MS, POLL_INTERVAL_IN_MS);
      }
    }.blockTillTrue();
  }
}

package org.threadly.test.concurrent;

import org.threadly.util.Clock;

/**
 * Generic tools to be used in unit testing.
 * 
 * @author jent - Mike Jensen
 */
public class TestUtils {
  private TestUtils() {
    // don't construct
  }
  
  /**
   * Since sleeps are sometimes necessary, this makes
   * an easy way to ignore InterruptedException's.
   * 
   * @param time time in milliseconds to make the thread to sleep
   */
  public static void sleep(long time) {
    try {
      Thread.sleep(time);
    } catch (InterruptedException e) {
      // ignored
    }
  }
  
  /**
   * Blocks until the System clock advances at least 1 millisecond.
   */
  public static void blockTillClockAdvances() {
    new TestCondition() {
      private static final int TIMEOUT_IN_MS = 1000;
      private static final int POLL_INTERVAL_IN_MS = 1;
      
      private final long startTime = Clock.accurateTime();
      
      @Override
      public boolean get() {
        return Clock.accurateTime() != startTime;
      }
      
      @Override
      public void blockTillTrue() {
        blockTillTrue(TIMEOUT_IN_MS, POLL_INTERVAL_IN_MS);
      }
    }.blockTillTrue();
  }
}

Change this to use Clock in case people are relying on this function to advance the Clock abstraction
Change this to use Clock in case people are relying on this function to advance the Clock abstraction
