KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > taskman > PeriodicTaskTest


1 package org.sapia.taskman;
2
3 import junit.framework.*;
4
5 /**
6  * @author Yanick Duchesne 1-May-2003
7  */

8 public class PeriodicTaskTest extends TestCase {
9   /**
10    * Constructor for PeriodicTaskTest.
11    */

12   public PeriodicTaskTest(String JavaDoc name) {
13     super(name);
14   }
15
16   public void testExecute() throws Exception JavaDoc {
17     TaskManager tm = new TaskManager("test");
18     tm.setDaemon(true);
19     tm.start();
20
21     TestTask t;
22     tm.execTaskFor(new PeriodicTaskDescriptor("test", 200, t = new TestTask()));
23     Thread.sleep(3000);
24     super.assertTrue(
25         "Task not executed for expected number of times - at least",
26         t.execCount > 2);
27   }
28 }
29
Popular Tags