litesoft
Diff Revisions
475
vs
858
for /trunk/Java/core/Server/src/org/litesoft/delayed/ThreadBasedDelayedTimedRunnableRunnerTest.java
|
@@ -1,11 +1,10 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt |
2 |
2 |
|
package org.litesoft.delayed; |
3 |
3 |
|
|
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
4 |
|
import junit.framework.*; |
7 |
5 |
|
|
8 |
6 |
|
import org.litesoft.core.delayed.*; |
|
7 |
+ |
import org.litesoft.core.simpletypes.temporal.*; |
9 |
8 |
|
import org.litesoft.core.util.*; |
10 |
9 |
|
import org.litesoft.delayed.nonpublic.*; |
11 |
10 |
|
|
|
@@ -21,6 +20,7 @@ |
21 |
20 |
|
throws Exception |
22 |
21 |
|
{ |
23 |
22 |
|
super.setUp(); |
|
23 |
+ |
mMillisecTimeSource = MillisecTimeSource.INSTANCE; |
24 |
24 |
|
mAfter = null; |
25 |
25 |
|
mRan = false; |
26 |
26 |
|
mError = null; |
|
@@ -30,7 +30,7 @@ |
30 |
30 |
|
@Override |
31 |
31 |
|
public Again runOnce() |
32 |
32 |
|
{ |
33 |
|
- |
mAfter = new Date().getTime(); |
|
33 |
+ |
mAfter = mMillisecTimeSource.now(); |
34 |
34 |
|
mRan = true; |
35 |
35 |
|
return null; |
36 |
36 |
|
} |
|
@@ -46,6 +46,7 @@ |
46 |
46 |
|
); |
47 |
47 |
|
} |
48 |
48 |
|
|
|
49 |
+ |
private MillisecTimeSource mMillisecTimeSource; |
49 |
50 |
|
private volatile Long mAfter; |
50 |
51 |
|
private volatile boolean mRan; |
51 |
52 |
|
private volatile Throwable mError; |
|
@@ -54,7 +55,7 @@ |
54 |
55 |
|
public void testTimer() |
55 |
56 |
|
throws Exception |
56 |
57 |
|
{ |
57 |
|
- |
long before = new Date().getTime(); |
|
58 |
+ |
long before = mMillisecTimeSource.now(); |
58 |
59 |
|
long targetTime = before + 100; |
59 |
60 |
|
mTimer.scheduleFor( targetTime ); |
60 |
61 |
|
// Give it upto a full second to run... |
|
@@ -74,7 +75,7 @@ |
74 |
75 |
|
public void testCancelTimer() |
75 |
76 |
|
throws Exception |
76 |
77 |
|
{ |
77 |
|
- |
long before = new Date().getTime(); |
|
78 |
+ |
long before = mMillisecTimeSource.now(); |
78 |
79 |
|
mTimer.scheduleFor( before + 1000 ); |
79 |
80 |
|
Thread.sleep( 10 ); |
80 |
81 |
|
mTimer.cancel(); |