Package test.utils.time

Source Code of test.utils.time.TestTimerWheel

package test.utils.time;

import org.junit.Assert;
import org.junit.Test;
import com.firefly.utils.time.wheel.TimeWheel;
import static org.hamcrest.Matchers.*;

public class TestTimerWheel {
  @Test
  public void test() {
//    log.debug("test timer wheel");
    TimeWheel t = new TimeWheel();
    t.start();
    final long start = System.currentTimeMillis();
    t.add(1500, new Runnable() {

      @Override
      public void run() {
        long end = System.currentTimeMillis();
//        log.info("ttt1: " + (end - start));
        Assert.assertThat((end - start), greaterThanOrEqualTo(1500L));
      }
    });

    t.add(2500, new Runnable() {

      @Override
      public void run() {
        long end = System.currentTimeMillis();
//        log.info("ttt2: " + (end - start));
        Assert.assertThat((end - start), greaterThanOrEqualTo(2500L));
      }
    });
  }

  public static void main(String[] args) {
    new TestTimerWheel().test();
  }
}
TOP

Related Classes of test.utils.time.TestTimerWheel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.