KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.sapia.taskman;
2
3 import junit.framework.TestCase;
4
5 /**
6  * @author Yanick Duchesne
7  * <dl>
8  * <dt><b>Copyright: </b>
9  * <dd>Copyright &#169; 2002-2003 <a
10  * HREF="http://www.sapia-oss.org">Sapia Open Source Software </a>. All
11  * Rights Reserved.</dd>
12  * </dt>
13  * <dt><b>License: </b>
14  * <dd>Read the license.txt file of the jar or visit the <a
15  * HREF="http://www.sapia-oss.org/license.html">license page </a> at the
16  * Sapia OSS web site</dd>
17  * </dt>
18  * </dl>
19  */

20 public class RetryTaskTest extends TestCase {
21   /**
22    * @param arg0
23    */

24   public RetryTaskTest(String JavaDoc arg0) {
25     super(arg0);
26   }
27
28   public void testExec() throws Exception JavaDoc {
29     TaskManager tm = new TaskManager();
30     tm.setRunInterval(500);
31
32     TestRetryTask t = new TestRetryTask(4, 3);
33     PeriodicTaskDescriptor desc = new PeriodicTaskDescriptor("test", 100, t);
34     tm.setDaemon(true);
35     tm.start();
36     tm.execTaskFor(desc);
37     Thread.sleep(2000);
38     super.assertEquals(3, t._count);
39   }
40
41   public void testAbort() throws Exception JavaDoc {
42     TaskManager tm = new TaskManager();
43     tm.setRunInterval(500);
44
45     TestRetryTask t = new TestRetryTask(2, 3);
46     PeriodicTaskDescriptor desc = new PeriodicTaskDescriptor("test", 100, t);
47     tm.setDaemon(true);
48     tm.start();
49     tm.execTaskFor(desc);
50     Thread.sleep(2000);
51     super.assertEquals(2, t._count);
52   }
53 }
54
Popular Tags