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

Comparing jsr166/src/test/tck/DelayQueueTest.java (file contents):
Revision 1.15 by jsr166, Mon Nov 2 20:28:31 2009 UTC vs.
Revision 1.17 by jsr166, Mon Nov 16 05:30:07 2009 UTC

# Line 119 | Line 119 | public class DelayQueueTest extends JSR1
119      private DelayQueue populatedQueue(int n) {
120          DelayQueue q = new DelayQueue();
121          assertTrue(q.isEmpty());
122 <        for(int i = n-1; i >= 0; i-=2)
122 >        for (int i = n-1; i >= 0; i-=2)
123              assertTrue(q.offer(new PDelay(i)));
124 <        for(int i = (n & 1); i < n; i+=2)
124 >        for (int i = (n & 1); i < n; i+=2)
125              assertTrue(q.offer(new PDelay(i)));
126          assertFalse(q.isEmpty());
127          assertEquals(NOCAP, q.remainingCapacity());
# Line 343 | Line 343 | public class DelayQueueTest extends JSR1
343              q.put(null);
344              shouldThrow();
345          }
346 <        catch (NullPointerException success){
346 >        catch (NullPointerException success) {
347          }
348       }
349  
# Line 392 | Line 392 | public class DelayQueueTest extends JSR1
392              q.take();
393              t.interrupt();
394              t.join();
395 <        } catch (Exception e){
395 >        } catch (Exception e) {
396              unexpectedException();
397          }
398      }
# Line 418 | Line 418 | public class DelayQueueTest extends JSR1
418              Thread.sleep(SMALL_DELAY_MS);
419              t.interrupt();
420              t.join();
421 <        } catch (Exception e){
421 >        } catch (Exception e) {
422              unexpectedException();
423          }
424      }
# Line 432 | Line 432 | public class DelayQueueTest extends JSR1
432              for (int i = 0; i < SIZE; ++i) {
433                  assertEquals(new PDelay(i), ((PDelay)q.take()));
434              }
435 <        } catch (InterruptedException e){
435 >        } catch (InterruptedException e) {
436              unexpectedException();
437          }
438      }
# Line 447 | Line 447 | public class DelayQueueTest extends JSR1
447                      try {
448                          q.take();
449                          threadShouldThrow();
450 <                    } catch (InterruptedException success){ }
450 >                    } catch (InterruptedException success) { }
451                  }
452              });
453          try {
# Line 455 | Line 455 | public class DelayQueueTest extends JSR1
455              Thread.sleep(SHORT_DELAY_MS);
456              t.interrupt();
457              t.join();
458 <        } catch (Exception e){
458 >        } catch (Exception e) {
459              unexpectedException();
460          }
461      }
# Line 473 | Line 473 | public class DelayQueueTest extends JSR1
473                          }
474                          q.take();
475                          threadShouldThrow();
476 <                    } catch (InterruptedException success){
476 >                    } catch (InterruptedException success) {
477                      }
478                  }});
479          t.start();
# Line 509 | Line 509 | public class DelayQueueTest extends JSR1
509                  assertEquals(new PDelay(i), ((PDelay)q.poll(0, TimeUnit.MILLISECONDS)));
510              }
511              assertNull(q.poll(0, TimeUnit.MILLISECONDS));
512 <        } catch (InterruptedException e){
512 >        } catch (InterruptedException e) {
513              unexpectedException();
514          }
515      }
# Line 524 | Line 524 | public class DelayQueueTest extends JSR1
524                  assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)));
525              }
526              assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
527 <        } catch (InterruptedException e){
527 >        } catch (InterruptedException e) {
528              unexpectedException();
529          }
530      }
# Line 542 | Line 542 | public class DelayQueueTest extends JSR1
542                              threadAssertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)));
543                          }
544                          threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
545 <                    } catch (InterruptedException success){
545 >                    } catch (InterruptedException success) {
546                      }
547                  }});
548          t.start();
# Line 578 | Line 578 | public class DelayQueueTest extends JSR1
578              assertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
579              t.interrupt();
580              t.join();
581 <        } catch (Exception e){
581 >        } catch (Exception e) {
582              unexpectedException();
583          }
584      }
# Line 627 | Line 627 | public class DelayQueueTest extends JSR1
627          try {
628              q.remove();
629              shouldThrow();
630 <        } catch (NoSuchElementException success){
630 >        } catch (NoSuchElementException success) {
631          }
632      }
633  
# Line 732 | Line 732 | public class DelayQueueTest extends JSR1
732          Object[] o = q.toArray();
733          Arrays.sort(o);
734          try {
735 <        for(int i = 0; i < o.length; i++)
735 >        for (int i = 0; i < o.length; i++)
736              assertEquals(o[i], q.take());
737 <        } catch (InterruptedException e){
737 >        } catch (InterruptedException e) {
738              unexpectedException();
739          }
740      }
# Line 748 | Line 748 | public class DelayQueueTest extends JSR1
748          ints = (PDelay[])q.toArray(ints);
749          Arrays.sort(ints);
750          try {
751 <            for(int i = 0; i < ints.length; i++)
751 >            for (int i = 0; i < ints.length; i++)
752                  assertEquals(ints[i], q.take());
753 <        } catch (InterruptedException e){
753 >        } catch (InterruptedException e) {
754              unexpectedException();
755          }
756      }
# Line 764 | Line 764 | public class DelayQueueTest extends JSR1
764              DelayQueue q = populatedQueue(SIZE);
765              Object o[] = q.toArray(null);
766              shouldThrow();
767 <        } catch(NullPointerException success){}
767 >        } catch (NullPointerException success) {}
768      }
769  
770      /**
# Line 775 | Line 775 | public class DelayQueueTest extends JSR1
775              DelayQueue q = populatedQueue(SIZE);
776              Object o[] = q.toArray(new String[10] );
777              shouldThrow();
778 <        } catch(ArrayStoreException  success){}
778 >        } catch (ArrayStoreException  success) {}
779      }
780  
781      /**
# Line 785 | Line 785 | public class DelayQueueTest extends JSR1
785          DelayQueue q = populatedQueue(SIZE);
786          int i = 0;
787          Iterator it = q.iterator();
788 <        while(it.hasNext()) {
788 >        while (it.hasNext()) {
789              assertTrue(q.contains(it.next()));
790              ++i;
791          }
# Line 880 | Line 880 | public class DelayQueueTest extends JSR1
880                  last = tt;
881              }
882          }
883 <        catch(InterruptedException ie) {
883 >        catch (InterruptedException ie) {
884              unexpectedException();
885          }
886      }
# Line 925 | Line 925 | public class DelayQueueTest extends JSR1
925          try {
926              q.drainTo(null);
927              shouldThrow();
928 <        } catch(NullPointerException success) {
928 >        } catch (NullPointerException success) {
929          }
930      }
931  
# Line 937 | Line 937 | public class DelayQueueTest extends JSR1
937          try {
938              q.drainTo(q);
939              shouldThrow();
940 <        } catch(IllegalArgumentException success) {
940 >        } catch (IllegalArgumentException success) {
941          }
942      }
943  
# Line 986 | Line 986 | public class DelayQueueTest extends JSR1
986              assertTrue(l.size() >= SIZE);
987              t.join();
988              assertTrue(q.size() + l.size() >= SIZE);
989 <        } catch(Exception e){
989 >        } catch (Exception e) {
990              unexpectedException();
991          }
992      }
# Line 999 | Line 999 | public class DelayQueueTest extends JSR1
999          try {
1000              q.drainTo(null, 0);
1001              shouldThrow();
1002 <        } catch(NullPointerException success) {
1002 >        } catch (NullPointerException success) {
1003          }
1004      }
1005  
# Line 1011 | Line 1011 | public class DelayQueueTest extends JSR1
1011          try {
1012              q.drainTo(q, 0);
1013              shouldThrow();
1014 <        } catch(IllegalArgumentException success) {
1014 >        } catch (IllegalArgumentException success) {
1015          }
1016      }
1017  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines