--- jsr166/src/test/tck/ThreadLocalTest.java 2009/08/04 10:13:48 1.7 +++ jsr166/src/test/tck/ThreadLocalTest.java 2011/03/15 19:47:07 1.12 @@ -1,9 +1,9 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. + * http://creativecommons.org/publicdomain/zero/1.0/ + * Other contributors include Andrew Wright, Jeffrey Hayes, + * Pat Fisher, Mike Judd. */ import junit.framework.*; @@ -11,11 +11,11 @@ import java.util.concurrent.Semaphore; public class ThreadLocalTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + junit.textui.TestRunner.run(suite()); } - + public static Test suite() { - return new TestSuite(ThreadLocalTest.class); + return new TestSuite(ThreadLocalTest.class); } static ThreadLocal tl = new ThreadLocal() { @@ -29,7 +29,7 @@ public class ThreadLocalTest extends JSR protected Integer initialValue() { return zero; } - + protected Integer childValue(Integer parentValue) { return new Integer(parentValue.intValue() + 1); } @@ -39,11 +39,11 @@ public class ThreadLocalTest extends JSR * remove causes next access to return initial value */ public void testRemove() { - assertEquals(tl.get(), one); + assertSame(tl.get(), one); tl.set(two); - assertEquals(tl.get(), two); + assertSame(tl.get(), two); tl.remove(); - assertEquals(tl.get(), one); + assertSame(tl.get(), one); } /** @@ -51,11 +51,11 @@ public class ThreadLocalTest extends JSR * initial value */ public void testRemoveITL() { - assertEquals(itl.get(), zero); + assertSame(itl.get(), zero); itl.set(two); - assertEquals(itl.get(), two); + assertSame(itl.get(), two); itl.remove(); - assertEquals(itl.get(), zero); + assertSame(itl.get(), zero); } private class ITLThread extends Thread { @@ -68,13 +68,13 @@ public class ThreadLocalTest extends JSR child.start(); } Thread.currentThread().yield(); - + int threadId = itl.get().intValue(); for (int j = 0; j < threadId; j++) { x[threadId]++; Thread.currentThread().yield(); } - + if (child != null) { // Wait for child (if any) try { child.join(); @@ -88,18 +88,14 @@ public class ThreadLocalTest extends JSR /** * InheritableThreadLocal propagates generic values. */ - public void testGenericITL() { + public void testGenericITL() throws InterruptedException { final int threadCount = 10; final int x[] = new int[threadCount]; Thread progenitor = new ITLThread(x); - try { - progenitor.start(); - progenitor.join(); - for (int i = 0; i < threadCount; i++) { - assertEquals(i, x[i]); - } - } catch (InterruptedException e) { - unexpectedException(e); + progenitor.start(); + progenitor.join(); + for (int i = 0; i < threadCount; i++) { + assertEquals(i, x[i]); } } }