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

Comparing jsr166/src/test/tck/SynchronousQueueTest.java (file contents):
Revision 1.18 by jsr166, Sun Nov 22 18:57:17 2009 UTC vs.
Revision 1.19 by jsr166, Tue Dec 1 06:03:49 2009 UTC

# Line 169 | Line 169 | public class SynchronousQueueTest extend
169              public void realRun() throws InterruptedException {
170                  int added = 0;
171                  try {
172 <                    q.put(new Object());
173 <                    ++added;
174 <                    q.put(new Object());
175 <                    ++added;
176 <                    q.put(new Object());
177 <                    ++added;
178 <                    q.put(new Object());
179 <                    ++added;
180 <                    threadShouldThrow();
172 >                    while (true) {
173 >                        q.put(added);
174 >                        ++added;
175 >                    }
176                  } catch (InterruptedException success) {
177 <                    assertTrue(added >= 1);
177 >                    assertTrue(added == 1);
178                  }
179              }});
180  
181          t.start();
182          Thread.sleep(SHORT_DELAY_MS);
183 <        q.take();
183 >        assertEquals(0, q.take());
184          Thread.sleep(SHORT_DELAY_MS);
185          t.interrupt();
186          t.join();
# Line 251 | Line 246 | public class SynchronousQueueTest extend
246              public void realRun() throws InterruptedException {
247                  int added = 0;
248                  try {
249 <                    q.put(new Object());
250 <                    ++added;
251 <                    q.put(new Object());
252 <                    ++added;
258 <                    q.put(new Object());
259 <                    ++added;
260 <                    q.put(new Object());
261 <                    ++added;
262 <                    threadShouldThrow();
249 >                    while (true) {
250 >                        q.put(added);
251 >                        ++added;
252 >                    }
253                  } catch (InterruptedException success) {
254 <                    assertTrue(added >= 1);
254 >                    assertTrue(added == 1);
255                  }
256              }});
257  
258          t.start();
259          Thread.sleep(SHORT_DELAY_MS);
260 <        q.take();
260 >        assertEquals(0, q.take());
261          Thread.sleep(SHORT_DELAY_MS);
262          t.interrupt();
263          t.join();
# Line 280 | Line 270 | public class SynchronousQueueTest extend
270          final SynchronousQueue q = new SynchronousQueue(true);
271          Thread t = new Thread(new CheckedInterruptedRunnable() {
272              public void realRun() throws InterruptedException {
273 <                threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS));
273 >                assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS));
274                  q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS);
275              }});
276  
# Line 573 | Line 563 | public class SynchronousQueueTest extend
563      public void testOfferInExecutor() {
564          final SynchronousQueue q = new SynchronousQueue();
565          ExecutorService executor = Executors.newFixedThreadPool(2);
576        final Integer one = new Integer(1);
566  
567          executor.execute(new CheckedRunnable() {
568              public void realRun() throws InterruptedException {
569 <                threadAssertFalse(q.offer(one));
570 <                threadAssertTrue(q.offer(one, MEDIUM_DELAY_MS, MILLISECONDS));
571 <                threadAssertEquals(0, q.remainingCapacity());
569 >                assertFalse(q.offer(one));
570 >                assertTrue(q.offer(one, MEDIUM_DELAY_MS, MILLISECONDS));
571 >                assertEquals(0, q.remainingCapacity());
572              }});
573  
574          executor.execute(new CheckedRunnable() {
575              public void realRun() throws InterruptedException {
576                  Thread.sleep(SMALL_DELAY_MS);
577 <                threadAssertEquals(one, q.take());
577 >                assertSame(one, q.take());
578              }});
579  
580          joinPool(executor);
# Line 600 | Line 589 | public class SynchronousQueueTest extend
589          ExecutorService executor = Executors.newFixedThreadPool(2);
590          executor.execute(new CheckedRunnable() {
591              public void realRun() throws InterruptedException {
592 <                threadAssertNull(q.poll());
593 <                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
594 <                threadAssertTrue(q.isEmpty());
592 >                assertNull(q.poll());
593 >                assertSame(one, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
594 >                assertTrue(q.isEmpty());
595              }});
596  
597          executor.execute(new CheckedRunnable() {
598              public void realRun() throws InterruptedException {
599 <                Thread.sleep(SMALL_DELAY_MS);
600 <                q.put(new Integer(1));
599 >                Thread.sleep(SHORT_DELAY_MS);
600 >                q.put(one);
601              }});
602  
603          joinPool(executor);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines