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.30 by jsr166, Wed Dec 31 19:21:20 2014 UTC vs.
Revision 1.38 by jsr166, Fri Aug 4 03:30:21 2017 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 36 | Line 36 | public class AtomicIntegerArrayTest exte
36      public void testConstructor2NPE() {
37          try {
38              int[] a = null;
39 <            AtomicIntegerArray aa = new AtomicIntegerArray(a);
39 >            new AtomicIntegerArray(a);
40              shouldThrow();
41          } catch (NullPointerException success) {}
42      }
# Line 276 | Line 276 | public class AtomicIntegerArrayTest exte
276  
277      class Counter extends CheckedRunnable {
278          final AtomicIntegerArray aa;
279 <        volatile int counts;
279 >        int decs;
280          Counter(AtomicIntegerArray a) { aa = a; }
281          public void realRun() {
282              for (;;) {
# Line 286 | Line 286 | public class AtomicIntegerArrayTest exte
286                      assertTrue(v >= 0);
287                      if (v != 0) {
288                          done = false;
289 <                        if (aa.compareAndSet(i, v, v-1))
290 <                            ++counts;
289 >                        if (aa.compareAndSet(i, v, v - 1))
290 >                            decs++;
291                      }
292                  }
293                  if (done)
# Line 307 | Line 307 | public class AtomicIntegerArrayTest exte
307              aa.set(i, countdown);
308          Counter c1 = new Counter(aa);
309          Counter c2 = new Counter(aa);
310 <        Thread t1 = new Thread(c1);
311 <        Thread t2 = new Thread(c2);
312 <        t1.start();
313 <        t2.start();
310 >        Thread t1 = newStartedThread(c1);
311 >        Thread t2 = newStartedThread(c2);
312          t1.join();
313          t2.join();
314 <        assertEquals(c1.counts+c2.counts, SIZE * countdown);
314 >        assertEquals(c1.decs + c2.decs, SIZE * countdown);
315      }
316  
317      /**
318 <     * a deserialized serialized array holds same values
318 >     * a deserialized/reserialized array holds same values in same order
319       */
320      public void testSerialization() throws Exception {
321          AtomicIntegerArray x = new AtomicIntegerArray(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines