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

Comparing jsr166/src/test/tck/AtomicIntegerArrayTest.java (file contents):
Revision 1.31 by jsr166, Sun Feb 22 04:34:44 2015 UTC vs.
Revision 1.39 by dl, Tue Jan 26 13:33:05 2021 UTC

# Line 15 | Line 15 | import junit.framework.TestSuite;
15   public class AtomicIntegerArrayTest extends JSR166TestCase {
16  
17      public static void main(String[] args) {
18 <        junit.textui.TestRunner.run(suite());
18 >        main(suite(), args);
19      }
20      public static Test suite() {
21          return new TestSuite(AtomicIntegerArrayTest.class);
# Line 55 | Line 55 | public class AtomicIntegerArrayTest exte
55      /**
56       * get and set for out of bound indices throw IndexOutOfBoundsException
57       */
58 +    @SuppressWarnings("deprecation")
59      public void testIndexing() {
60          AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
61          for (int index : new int[] { -1, SIZE }) {
# Line 160 | Line 161 | public class AtomicIntegerArrayTest exte
161       * repeated weakCompareAndSet succeeds in changing value when equal
162       * to expected
163       */
164 +    @SuppressWarnings("deprecation")
165      public void testWeakCompareAndSet() {
166          AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
167          for (int i = 0; i < SIZE; i++) {
# Line 276 | Line 278 | public class AtomicIntegerArrayTest exte
278  
279      class Counter extends CheckedRunnable {
280          final AtomicIntegerArray aa;
281 <        volatile int counts;
281 >        int decs;
282          Counter(AtomicIntegerArray a) { aa = a; }
283          public void realRun() {
284              for (;;) {
# Line 286 | Line 288 | public class AtomicIntegerArrayTest exte
288                      assertTrue(v >= 0);
289                      if (v != 0) {
290                          done = false;
291 <                        if (aa.compareAndSet(i, v, v-1))
292 <                            ++counts;
291 >                        if (aa.compareAndSet(i, v, v - 1))
292 >                            decs++;
293                      }
294                  }
295                  if (done)
# Line 307 | Line 309 | public class AtomicIntegerArrayTest exte
309              aa.set(i, countdown);
310          Counter c1 = new Counter(aa);
311          Counter c2 = new Counter(aa);
312 <        Thread t1 = new Thread(c1);
313 <        Thread t2 = new Thread(c2);
312 <        t1.start();
313 <        t2.start();
312 >        Thread t1 = newStartedThread(c1);
313 >        Thread t2 = newStartedThread(c2);
314          t1.join();
315          t2.join();
316 <        assertEquals(c1.counts+c2.counts, SIZE * countdown);
316 >        assertEquals(c1.decs + c2.decs, SIZE * countdown);
317      }
318  
319      /**
320 <     * a deserialized serialized array holds same values
320 >     * a deserialized/reserialized array holds same values in same order
321       */
322      public void testSerialization() throws Exception {
323          AtomicIntegerArray x = new AtomicIntegerArray(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines