01: package org.uispec4j.utils;
02:
03: import junit.framework.Assert;
04:
05: import java.util.Date;
06:
07: public class Chrono {
08: private Date startDate;
09:
10: public static Chrono start() {
11: return new Chrono();
12: }
13:
14: private Chrono() {
15: startDate = new Date();
16: }
17:
18: public void assertElapsedTimeLessThan(long max) {
19: long elapsed = getElapsedTime();
20: Assert.assertTrue("Maximum elapsed time reached: " + elapsed
21: + " >= " + max, elapsed < max);
22: }
23:
24: public long getElapsedTime() {
25: Date currentDate = new Date();
26: return currentDate.getTime() - startDate.getTime();
27: }
28: }
|