KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > connextra > util > ClockTest


1 package test.connextra.util;
2
3 import junit.framework.*;
4
5 import com.connextra.util.*;
6
7
8 public class ClockTest extends TestCase {
9     private static final Class JavaDoc THIS = ClockTest.class;
10
11     public ClockTest(String JavaDoc name) {
12         super(name);
13     }
14
15     public static Test suite() {
16         return new TestSuite(THIS);
17     }
18
19     public void testRunning() throws InterruptedException JavaDoc {
20         Clock aClock = new RealClock();
21         long start = aClock.getTime();
22         Thread.currentThread().sleep(10);
23
24         long stop = aClock.getTime();
25
26         assertTrue("Should keep running", stop > start);
27     }
28
29     public void testStop() throws InterruptedException JavaDoc {
30         Clock aClock = new RealClock();
31         aClock.stop();
32
33         long start = aClock.getTime();
34         Thread.currentThread().sleep(10);
35
36         long stop = aClock.getTime();
37
38         assertEquals("Should not advance time", start, stop);
39     }
40 }
Popular Tags