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

Comparing jsr166/src/test/tck/AbstractQueuedLongSynchronizerTest.java (file contents):
Revision 1.6 by jsr166, Mon Nov 16 04:57:09 2009 UTC vs.
Revision 1.8 by jsr166, Tue Nov 17 13:40:14 2009 UTC

# Line 76 | Line 76 | public class AbstractQueuedLongSynchroni
76          public void run() {
77              try {
78                  sync.acquireInterruptibly(1);
79 <            } catch (InterruptedException success){}
79 >            } catch (InterruptedException success) {}
80          }
81      }
82  
# Line 92 | Line 92 | public class AbstractQueuedLongSynchroni
92              try {
93                  sync.acquireInterruptibly(1);
94                  threadShouldThrow();
95 <            } catch (InterruptedException success){}
95 >            } catch (InterruptedException success) {}
96          }
97      }
98  
# Line 149 | Line 149 | public class AbstractQueuedLongSynchroni
149              assertFalse(sync.hasQueuedThreads());
150              t1.join();
151              t2.join();
152 <        } catch (Exception e){
152 >        } catch (Exception e) {
153              unexpectedException();
154          }
155      }
# Line 195 | Line 195 | public class AbstractQueuedLongSynchroni
195              assertFalse(sync.isQueued(t2));
196              t1.join();
197              t2.join();
198 <        } catch (Exception e){
198 >        } catch (Exception e) {
199              unexpectedException();
200          }
201      }
# Line 225 | Line 225 | public class AbstractQueuedLongSynchroni
225              assertNull(sync.getFirstQueuedThread());
226              t1.join();
227              t2.join();
228 <        } catch (Exception e){
228 >        } catch (Exception e) {
229              unexpectedException();
230          }
231      }
# Line 255 | Line 255 | public class AbstractQueuedLongSynchroni
255              assertTrue(sync.hasContended());
256              t1.join();
257              t2.join();
258 <        } catch (Exception e){
258 >        } catch (Exception e) {
259              unexpectedException();
260          }
261      }
# Line 287 | Line 287 | public class AbstractQueuedLongSynchroni
287              assertTrue(sync.getQueuedThreads().isEmpty());
288              t1.join();
289              t2.join();
290 <        } catch (Exception e){
290 >        } catch (Exception e) {
291              unexpectedException();
292          }
293      }
# Line 319 | Line 319 | public class AbstractQueuedLongSynchroni
319              assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
320              t1.join();
321              t2.join();
322 <        } catch (Exception e){
322 >        } catch (Exception e) {
323              unexpectedException();
324          }
325      }
# Line 349 | Line 349 | public class AbstractQueuedLongSynchroni
349              assertTrue(sync.getSharedQueuedThreads().isEmpty());
350              t1.join();
351              t2.join();
352 <        } catch (Exception e){
352 >        } catch (Exception e) {
353              unexpectedException();
354          }
355      }
# Line 365 | Line 365 | public class AbstractQueuedLongSynchroni
365                      try {
366                          sync.tryAcquireNanos(1, MEDIUM_DELAY_MS * 1000 * 1000);
367                          threadShouldThrow();
368 <                    } catch (InterruptedException success){}
368 >                    } catch (InterruptedException success) {}
369                  }
370              });
371          try {
372              t.start();
373              t.interrupt();
374 <        } catch (Exception e){
374 >        } catch (Exception e) {
375              unexpectedException();
376          }
377      }
# Line 392 | Line 392 | public class AbstractQueuedLongSynchroni
392              t.start();
393              t.join();
394              sync.release(1);
395 <        } catch (Exception e){
395 >        } catch (Exception e) {
396              unexpectedException();
397          }
398      }
# Line 408 | Line 408 | public class AbstractQueuedLongSynchroni
408                      try {
409                          threadAssertFalse(sync.tryAcquireNanos(1, 1000 * 1000));
410                      } catch (Exception ex) {
411 <                        threadUnexpectedException();
411 >                        threadUnexpectedException(ex);
412                      }
413                  }
414              });
# Line 416 | Line 416 | public class AbstractQueuedLongSynchroni
416              t.start();
417              t.join();
418              sync.release(1);
419 <        } catch (Exception e){
419 >        } catch (Exception e) {
420              unexpectedException();
421          }
422      }
# Line 438 | Line 438 | public class AbstractQueuedLongSynchroni
438                          Thread.sleep(SMALL_DELAY_MS);
439                      }
440                      catch (Exception e) {
441 <                        threadUnexpectedException();
441 >                        threadUnexpectedException(e);
442                      }
443                      sync.release(1);
444                  }
# Line 449 | Line 449 | public class AbstractQueuedLongSynchroni
449              assertTrue(sync.isHeldExclusively());
450              t.join();
451              assertFalse(sync.isHeldExclusively());
452 <        } catch (Exception e){
452 >        } catch (Exception e) {
453              unexpectedException();
454          }
455      }
# Line 469 | Line 469 | public class AbstractQueuedLongSynchroni
469              Thread.sleep(SHORT_DELAY_MS);
470              sync.release(1);
471              t.join();
472 <        } catch (Exception e){
472 >        } catch (Exception e) {
473              unexpectedException();
474          }
475      }
# Line 490 | Line 490 | public class AbstractQueuedLongSynchroni
490              t.interrupt();
491              assertTrue(sync.isHeldExclusively());
492              t.join();
493 <        } catch (Exception e){
493 >        } catch (Exception e) {
494              unexpectedException();
495          }
496      }
# Line 604 | Line 604 | public class AbstractQueuedLongSynchroni
604                          sync.release(1);
605                      }
606                      catch (InterruptedException e) {
607 <                        threadUnexpectedException();
607 >                        threadUnexpectedException(e);
608                      }
609                  }
610              });
# Line 674 | Line 674 | public class AbstractQueuedLongSynchroni
674       */
675      public void testHasWaitersIAE() {
676          final Mutex sync = new Mutex();
677 <        final AbstractQueuedLongSynchronizer.ConditionObject c = (sync.newCondition());
677 >        final AbstractQueuedLongSynchronizer.ConditionObject c = sync.newCondition();
678          final Mutex sync2 = new Mutex();
679          try {
680              sync2.hasWaiters(c);
# Line 690 | Line 690 | public class AbstractQueuedLongSynchroni
690       */
691      public void testHasWaitersIMSE() {
692          final Mutex sync = new Mutex();
693 <        final AbstractQueuedLongSynchronizer.ConditionObject c = (sync.newCondition());
693 >        final AbstractQueuedLongSynchronizer.ConditionObject c = sync.newCondition();
694          try {
695              sync.hasWaiters(c);
696              shouldThrow();
# Line 706 | Line 706 | public class AbstractQueuedLongSynchroni
706       */
707      public void testGetWaitQueueLengthIAE() {
708          final Mutex sync = new Mutex();
709 <        final AbstractQueuedLongSynchronizer.ConditionObject c = (sync.newCondition());
709 >        final AbstractQueuedLongSynchronizer.ConditionObject c = sync.newCondition();
710          final Mutex sync2 = new Mutex();
711          try {
712              sync2.getWaitQueueLength(c);
# Line 722 | Line 722 | public class AbstractQueuedLongSynchroni
722       */
723      public void testGetWaitQueueLengthIMSE() {
724          final Mutex sync = new Mutex();
725 <        final AbstractQueuedLongSynchronizer.ConditionObject c = (sync.newCondition());
725 >        final AbstractQueuedLongSynchronizer.ConditionObject c = sync.newCondition();
726          try {
727              sync.getWaitQueueLength(c);
728              shouldThrow();
# Line 738 | Line 738 | public class AbstractQueuedLongSynchroni
738       */
739      public void testGetWaitingThreadsIAE() {
740          final Mutex sync = new Mutex();
741 <        final AbstractQueuedLongSynchronizer.ConditionObject c = (sync.newCondition());
741 >        final AbstractQueuedLongSynchronizer.ConditionObject c = sync.newCondition();
742          final Mutex sync2 = new Mutex();
743          try {
744              sync2.getWaitingThreads(c);
# Line 754 | Line 754 | public class AbstractQueuedLongSynchroni
754       */
755      public void testGetWaitingThreadsIMSE() {
756          final Mutex sync = new Mutex();
757 <        final AbstractQueuedLongSynchronizer.ConditionObject c = (sync.newCondition());
757 >        final AbstractQueuedLongSynchronizer.ConditionObject c = sync.newCondition();
758          try {
759              sync.getWaitingThreads(c);
760              shouldThrow();
# Line 782 | Line 782 | public class AbstractQueuedLongSynchroni
782                          sync.release(1);
783                      }
784                      catch (InterruptedException e) {
785 <                        threadUnexpectedException();
785 >                        threadUnexpectedException(e);
786                      }
787                  }
788              });
# Line 824 | Line 824 | public class AbstractQueuedLongSynchroni
824                          sync.release(1);
825                      }
826                      catch (InterruptedException e) {
827 <                        threadUnexpectedException();
827 >                        threadUnexpectedException(e);
828                      }
829                  }
830              });
# Line 839 | Line 839 | public class AbstractQueuedLongSynchroni
839                          sync.release(1);
840                      }
841                      catch (InterruptedException e) {
842 <                        threadUnexpectedException();
842 >                        threadUnexpectedException(e);
843                      }
844                  }
845              });
# Line 884 | Line 884 | public class AbstractQueuedLongSynchroni
884                          sync.release(1);
885                      }
886                      catch (InterruptedException e) {
887 <                        threadUnexpectedException();
887 >                        threadUnexpectedException(e);
888                      }
889                  }
890              });
# Line 898 | Line 898 | public class AbstractQueuedLongSynchroni
898                          sync.release(1);
899                      }
900                      catch (InterruptedException e) {
901 <                        threadUnexpectedException();
901 >                        threadUnexpectedException(e);
902                      }
903                  }
904              });
# Line 1137 | Line 1137 | public class AbstractQueuedLongSynchroni
1137              ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1138              Mutex r = (Mutex) in.readObject();
1139              assertTrue(r.isHeldExclusively());
1140 <        } catch (Exception e){
1140 >        } catch (Exception e) {
1141              e.printStackTrace();
1142              unexpectedException();
1143          }
# Line 1178 | Line 1178 | public class AbstractQueuedLongSynchroni
1178                          threadAssertFalse(l.isSignalled());
1179                          l.acquireSharedInterruptibly(0);
1180                          threadAssertTrue(l.isSignalled());
1181 <                    } catch (InterruptedException e){
1181 >                    } catch (InterruptedException e) {
1182                          threadUnexpectedException();
1183                      }
1184                  }
# Line 1190 | Line 1190 | public class AbstractQueuedLongSynchroni
1190              l.releaseShared(0);
1191              assertTrue(l.isSignalled());
1192              t.join();
1193 <        } catch (InterruptedException e){
1193 >        } catch (InterruptedException e) {
1194              unexpectedException();
1195          }
1196      }
# Line 1209 | Line 1209 | public class AbstractQueuedLongSynchroni
1209                          threadAssertTrue(l.tryAcquireSharedNanos(0, MEDIUM_DELAY_MS* 1000 * 1000));
1210                          threadAssertTrue(l.isSignalled());
1211  
1212 <                    } catch (InterruptedException e){
1212 >                    } catch (InterruptedException e) {
1213                          threadUnexpectedException();
1214                      }
1215                  }
# Line 1221 | Line 1221 | public class AbstractQueuedLongSynchroni
1221              l.releaseShared(0);
1222              assertTrue(l.isSignalled());
1223              t.join();
1224 <        } catch (InterruptedException e){
1224 >        } catch (InterruptedException e) {
1225              unexpectedException();
1226          }
1227      }
# Line 1237 | Line 1237 | public class AbstractQueuedLongSynchroni
1237                          threadAssertFalse(l.isSignalled());
1238                          l.acquireSharedInterruptibly(0);
1239                          threadShouldThrow();
1240 <                    } catch (InterruptedException success){}
1240 >                    } catch (InterruptedException success) {}
1241                  }
1242              });
1243          t.start();
# Line 1245 | Line 1245 | public class AbstractQueuedLongSynchroni
1245              assertFalse(l.isSignalled());
1246              t.interrupt();
1247              t.join();
1248 <        } catch (InterruptedException e){
1248 >        } catch (InterruptedException e) {
1249              unexpectedException();
1250          }
1251      }
# Line 1261 | Line 1261 | public class AbstractQueuedLongSynchroni
1261                          threadAssertFalse(l.isSignalled());
1262                          l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000);
1263                          threadShouldThrow();
1264 <                    } catch (InterruptedException success){}
1264 >                    } catch (InterruptedException success) {}
1265                  }
1266              });
1267          t.start();
# Line 1270 | Line 1270 | public class AbstractQueuedLongSynchroni
1270              assertFalse(l.isSignalled());
1271              t.interrupt();
1272              t.join();
1273 <        } catch (InterruptedException e){
1273 >        } catch (InterruptedException e) {
1274              unexpectedException();
1275          }
1276      }
# Line 1285 | Line 1285 | public class AbstractQueuedLongSynchroni
1285                      try {
1286                          threadAssertFalse(l.isSignalled());
1287                          threadAssertFalse(l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000));
1288 <                    } catch (InterruptedException ie){
1288 >                    } catch (InterruptedException ie) {
1289                          threadUnexpectedException();
1290                      }
1291                  }
# Line 1295 | Line 1295 | public class AbstractQueuedLongSynchroni
1295              Thread.sleep(SHORT_DELAY_MS);
1296              assertFalse(l.isSignalled());
1297              t.join();
1298 <        } catch (InterruptedException e){
1298 >        } catch (InterruptedException e) {
1299              unexpectedException();
1300          }
1301      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines