1   package com.atlassian.core.task.longrunning;
2   
3   import junit.framework.TestCase;
4   
5   import java.util.ResourceBundle;
6   
7   public class TestLongRunningTask extends TestCase
8   {
9       public void testElapsedTime() throws InterruptedException
10      {
11          AbstractLongRunningTask alrt = new AbstractLongRunningTask() {
12  
13  
14              public void run()
15              {
16                  try { super.run() ; Thread.sleep(100); stopTimer(); } catch (InterruptedException e) {}
17              }
18  
19              protected ResourceBundle getResourceBundle()
20              {
21                  return null;
22              }
23  
24              public String getName()
25              {
26                  return null;
27              }
28          };
29  
30          alrt.run();
31          
32  
33          long elapsedTime = alrt.getElapsedTime();
34          assertTrue(elapsedTime >= 100);
35  
36          // Test it's not still counting.
37          Thread.sleep(100);
38          assertEquals("counter has stopped", elapsedTime, alrt.getElapsedTime());
39      }
40  }