ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AtomicIntegerFieldUpdaterTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AtomicIntegerFieldUpdaterTest.java (file contents):
Revision 1.24 by jsr166, Mon Apr 1 20:58:58 2013 UTC vs.
Revision 1.28 by jsr166, Wed Dec 31 19:21:20 2014 UTC

# Line 6 | Line 6
6   * Pat Fisher, Mike Judd.
7   */
8  
9 import junit.framework.*;
9   import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
10  
11 + import junit.framework.Test;
12 + import junit.framework.TestSuite;
13 +
14   public class AtomicIntegerFieldUpdaterTest extends JSR166TestCase {
15      volatile int x = 0;
16      int w;
# Line 32 | Line 34 | public class AtomicIntegerFieldUpdaterTe
34          try {
35              updaterFor("y");
36              shouldThrow();
37 <        } catch (RuntimeException success) {}
37 >        } catch (RuntimeException success) {
38 >            assertNotNull(success.getCause());
39 >        }
40      }
41  
42      /**
43 <     * construction with field not of given type throws RuntimeException
43 >     * construction with field not of given type throws IllegalArgumentException
44       */
45      public void testConstructor2() {
46          try {
47              updaterFor("z");
48              shouldThrow();
49 <        } catch (RuntimeException success) {}
49 >        } catch (IllegalArgumentException success) {}
50      }
51  
52      /**
53 <     * construction with non-volatile field throws RuntimeException
53 >     * construction with non-volatile field throws IllegalArgumentException
54       */
55      public void testConstructor3() {
56          try {
57              updaterFor("w");
58              shouldThrow();
59 <        } catch (RuntimeException success) {}
59 >        } catch (IllegalArgumentException success) {}
60      }
61  
62      /**
# Line 129 | Line 133 | public class AtomicIntegerFieldUpdaterTe
133          AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
134          a = updaterFor("x");
135          x = 1;
136 <        while (!a.weakCompareAndSet(this, 1, 2));
137 <        while (!a.weakCompareAndSet(this, 2, -4));
136 >        do {} while (!a.weakCompareAndSet(this, 1, 2));
137 >        do {} while (!a.weakCompareAndSet(this, 2, -4));
138          assertEquals(-4, a.get(this));
139 <        while (!a.weakCompareAndSet(this, -4, 7));
139 >        do {} while (!a.weakCompareAndSet(this, -4, 7));
140          assertEquals(7, a.get(this));
141      }
142  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines