--- jsr166/src/test/tck/AtomicReferenceFieldUpdaterTest.java 2013/04/02 04:11:28 1.27 +++ jsr166/src/test/tck/AtomicReferenceFieldUpdaterTest.java 2014/12/31 19:05:42 1.30 @@ -6,13 +6,16 @@ * Pat Fisher, Mike Judd. */ -import junit.framework.*; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import junit.framework.Test; +import junit.framework.TestSuite; + public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { volatile Integer x = null; Object z; Integer w; + volatile int i; public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -34,18 +37,18 @@ public class AtomicReferenceFieldUpdater updaterFor("y"); shouldThrow(); } catch (RuntimeException success) { - assertTrue(success.getCause() != null); + assertNotNull(success.getCause()); } } /** - * construction with field not of given type throws RuntimeException + * construction with field not of given type throws ClassCastException */ public void testConstructor2() { try { updaterFor("z"); shouldThrow(); - } catch (RuntimeException success) {} + } catch (ClassCastException success) {} } /** @@ -59,6 +62,16 @@ public class AtomicReferenceFieldUpdater } /** + * Constructor with non-reference field throws ClassCastException + */ + public void testConstructor4() { + try { + updaterFor("i"); + shouldThrow(); + } catch (ClassCastException success) {} + } + + /** * get returns the last value set or assigned */ public void testGetSet() {