ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ThreadTest.java
Revision: 1.2
Committed: Mon Sep 1 00:17:10 2003 UTC (20 years, 8 months ago) by dl
Branch: MAIN
Changes since 1.1: +0 -7 lines
Log Message:
Remove test for defaults for UEH

File Contents

# User Rev Content
1 dl 1.1 /*
2     * Written by members of JCP JSR-166 Expert Group and released to the
3     * public domain. Use, modify, and redistribute this code in any way
4     * without acknowledgement. Other contributors include Andrew Wright,
5     * Jeffrey Hayes, Pat Fischer, Mike Judd.
6     */
7    
8     import junit.framework.*;
9     import java.util.concurrent.Semaphore;
10    
11     /**
12     * Test java.lang.Thread
13     *
14     */
15    
16     public class ThreadTest extends TestCase {
17     public static void main(String[] args) {
18     junit.textui.TestRunner.run(suite());
19     }
20    
21     public static Test suite() {
22     return new TestSuite(ThreadTest.class);
23     }
24    
25     static class MyHandler implements Thread.UncaughtExceptionHandler {
26     public void uncaughtException(Thread t, Throwable e) {
27     e.printStackTrace();
28     }
29     }
30    
31     public void testGetAndSetUncaughtExceptionHandler() {
32     // these must be done all at once to avoid state
33     // dependencies across tests
34     Thread current = Thread.currentThread();
35     ThreadGroup tg = current.getThreadGroup();
36     MyHandler eh = new MyHandler();
37     assertEquals(tg, current.getUncaughtExceptionHandler());
38     current.setUncaughtExceptionHandler(eh);
39     assertEquals(eh, current.getUncaughtExceptionHandler());
40     current.setUncaughtExceptionHandler(null);
41     assertEquals(tg, current.getUncaughtExceptionHandler());
42     }
43    
44     // How to test actually using UEH within junit?
45    
46     }
47