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

Comparing jsr166/src/test/tck/CyclicBarrierTest.java (file contents):
Revision 1.27 by jsr166, Sat Apr 25 04:55:30 2015 UTC vs.
Revision 1.29 by jsr166, Mon May 29 22:44:26 2017 UTC

# Line 13 | Line 13 | import java.util.concurrent.CountDownLat
13   import java.util.concurrent.CyclicBarrier;
14   import java.util.concurrent.TimeoutException;
15   import java.util.concurrent.atomic.AtomicBoolean;
16 + import java.util.concurrent.atomic.AtomicInteger;
17  
18   import junit.framework.Test;
19   import junit.framework.TestSuite;
# Line 25 | Line 26 | public class CyclicBarrierTest extends J
26          return new TestSuite(CyclicBarrierTest.class);
27      }
28  
28    private volatile int countAction;
29    private class MyAction implements Runnable {
30        public void run() { ++countAction; }
31    }
32
29      /**
30       * Spin-waits till the number of waiters == numberOfWaiters.
31       */
# Line 43 | Line 39 | public class CyclicBarrierTest extends J
39      }
40  
41      /**
42 <     * Creating with negative parties throws IAE
42 >     * Creating with negative parties throws IllegalArgumentException
43       */
44      public void testConstructor1() {
45          try {
# Line 53 | Line 49 | public class CyclicBarrierTest extends J
49      }
50  
51      /**
52 <     * Creating with negative parties and no action throws IAE
52 >     * Creating with negative parties and no action throws
53 >     * IllegalArgumentException
54       */
55      public void testConstructor2() {
56          try {
# Line 87 | Line 84 | public class CyclicBarrierTest extends J
84       * The supplied barrier action is run at barrier
85       */
86      public void testBarrierAction() throws Exception {
87 <        countAction = 0;
88 <        CyclicBarrier b = new CyclicBarrier(1, new MyAction());
87 >        final AtomicInteger count = new AtomicInteger(0);
88 >        final Runnable incCount = new Runnable() { public void run() {
89 >            count.getAndIncrement(); }};
90 >        CyclicBarrier b = new CyclicBarrier(1, incCount);
91          assertEquals(1, b.getParties());
92          assertEquals(0, b.getNumberWaiting());
93          b.await();
94          b.await();
95          assertEquals(0, b.getNumberWaiting());
96 <        assertEquals(2, countAction);
96 >        assertEquals(2, count.get());
97      }
98  
99      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines