ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/TimerExecutorTest.java
Revision: 1.3
Committed: Wed May 28 15:03:14 2003 UTC (21 years ago) by tim
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
Moved tests to corresponding packages.

File Contents

# User Rev Content
1 tim 1.1
2     import java.util.Date;
3     import java.util.TimerTask;
4     import java.util.concurrent.*;
5     import junit.framework.TestCase;
6    
7     /**
8     * Tests the TimerExecutor method
9     */
10     public class TimerExecutorTest extends TestCase {
11    
12     public void testTimedExecute () {
13     TimerExecutor te = TimerExecutors.newTimerExecutor(new DirectExecutor());
14     Date inASecond= new Date(System.currentTimeMillis() + 1000);
15     flag = false;
16     TimerTask timerTask = te.schedule(new Runnable() {
17     public void run () {
18     flag = true;
19     }
20     }, inASecond);
21     try {
22     Thread.sleep(3000);
23     }
24     catch (InterruptedException e) {
25     fail("task interrupted");
26     }
27     assertTrue("flag should have been set", flag);
28     }
29    
30     private static class DirectExecutor implements Executor {
31     public void execute (Runnable r) {
32     r.run();
33     }
34     }
35    
36     private boolean flag = false;
37     }