1 package org.sapia.taskman; 2 3 import junit.framework.TestCase; 4 5 8 public class TransientTaskTest extends TestCase { 9 12 public TransientTaskTest(String name) { 13 super(name); 14 } 15 16 public void testExecute() throws Exception { 17 TaskManager tm = new TaskManager("test"); 18 tm.setDaemon(true); 19 tm.start(); 20 21 TestTask t; 22 tm 23 .execTaskFor(new TransientTaskDescriptor("test", 200, 24 t = new TestTask())); 25 Thread.sleep(3000); 26 super.assertTrue("Task not executed for expected number of times", 27 t.execCount == 1); 28 } 29 30 public void testExecSync() throws Exception { 31 TaskManager tm = new TaskManager("test"); 32 TestTask t; 33 tm.start(); 34 tm.execSyncTask("test", t = new TestTask()); 35 Thread.sleep(2500); 36 super.assertTrue("Task not executed for expected number of times", 37 t.execCount == 1); 38 } 39 } 40 | Popular Tags |