01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.util.concurrent;
05:
06: import EDU.oswego.cs.dl.util.concurrent.Latch;
07: import EDU.oswego.cs.dl.util.concurrent.SynchronizedRef;
08:
09: import com.tc.util.TCTimer;
10: import com.tc.util.TCTimerImpl;
11:
12: import java.util.TimerTask;
13:
14: import junit.framework.TestCase;
15:
16: public class TCTimerTest extends TestCase {
17:
18: public void test() throws InterruptedException {
19: final String name = "testing 1 2 3";
20: TCTimer timer = new TCTimerImpl(name, true);
21:
22: final Latch proceed = new Latch();
23: final SynchronizedRef actualName = new SynchronizedRef(null);
24:
25: TimerTask task = new TimerTask() {
26: public void run() {
27: actualName.set(Thread.currentThread().getName());
28: proceed.release();
29: }
30: };
31:
32: timer.schedule(task, 0L);
33: proceed.acquire();
34:
35: assertEquals(name, actualName.get());
36:
37: timer.cancel();
38: }
39:
40: }
|