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

Comparing jsr166/src/test/tck/ReentrantReadWriteLockTest.java (file contents):
Revision 1.2 by dl, Sun Sep 7 20:39:11 2003 UTC vs.
Revision 1.3 by dl, Sun Sep 14 20:42:40 2003 UTC

# Line 10 | Line 10 | import java.util.concurrent.locks.*;
10   import java.util.concurrent.*;
11   import java.io.*;
12  
13 < public class ReentrantReadWriteLockTest extends TestCase {
14 <    static int HOLD_COUNT_TEST_LIMIT = 20;
15 <    
13 > public class ReentrantReadWriteLockTest extends JSR166TestCase {
14      public static void main(String[] args) {
15          junit.textui.TestRunner.run (suite());  
16      }
19    
17      public static Test suite() {
18          return new TestSuite(ReentrantReadWriteLockTest.class);
19      }
20  
21 <
25 <    private static long SHORT_DELAY_MS = 100;
26 <    private static long MEDIUM_DELAY_MS = 1000;
27 <    private static long LONG_DELAY_MS = 10000;
21 >    static int HOLD_COUNT_TEST_LIMIT = 20;
22  
23      /*
24       * Unlocks an unlocked lock, throws Illegal Monitor State
25       *
26       */
33    
27      public void testIllegalMonitorStateException(){
28          ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
29          try{
# Line 49 | Line 42 | public class ReentrantReadWriteLockTest
42                  public void run(){
43                      try{
44                          lock.writeLock().lockInterruptibly();
45 <                        fail("should throw");
45 >                        threadFail("should throw");
46                      }catch(InterruptedException success){}
47                  }
48              });
# Line 70 | Line 63 | public class ReentrantReadWriteLockTest
63                  public void run(){
64                      try{
65                          lock.writeLock().tryLock(1000,TimeUnit.MILLISECONDS);
66 <                        fail("should throw");
66 >                        threadFail("should throw");
67                      }catch(InterruptedException success){}
68                  }
69              });
# Line 91 | Line 84 | public class ReentrantReadWriteLockTest
84                  public void run(){
85                      try{
86                          lock.readLock().lockInterruptibly();
87 <                        fail("should throw");
87 >                        threadFail("should throw");
88                      }catch(InterruptedException success){}
89                  }
90              });
# Line 112 | Line 105 | public class ReentrantReadWriteLockTest
105                  public void run(){
106                      try{
107                          lock.readLock().tryLock(1000,TimeUnit.MILLISECONDS);
108 <                        fail("should throw");
108 >                        threadFail("should throw");
109                      }catch(InterruptedException success){}
110                  }
111              });
# Line 131 | Line 124 | public class ReentrantReadWriteLockTest
124          lock.writeLock().lock();
125          Thread t = new Thread(new Runnable() {
126                  public void run(){
127 <                    assertFalse(lock.writeLock().tryLock());
127 >                    threadAssertFalse(lock.writeLock().tryLock());
128                  }
129              });
130          try {
# Line 148 | Line 141 | public class ReentrantReadWriteLockTest
141          lock.writeLock().lock();
142          Thread t = new Thread(new Runnable() {
143                  public void run(){
144 <                    assertFalse(lock.readLock().tryLock());
144 >                    threadAssertFalse(lock.readLock().tryLock());
145                  }
146              });
147          try {
# Line 165 | Line 158 | public class ReentrantReadWriteLockTest
158          lock.readLock().lock();
159          Thread t = new Thread(new Runnable() {
160                  public void run(){
161 <                    assertTrue(lock.readLock().tryLock());
161 >                    threadAssertTrue(lock.readLock().tryLock());
162                      lock.readLock().unlock();
163                  }
164              });
# Line 246 | Line 239 | public class ReentrantReadWriteLockTest
239          lock.readLock().lock();
240          Thread t = new Thread(new Runnable() {
241                  public void run(){
242 <                    assertTrue(lock.readLock().tryLock());
242 >                    threadAssertTrue(lock.readLock().tryLock());
243                      lock.readLock().unlock();
244                  }
245              });
# Line 266 | Line 259 | public class ReentrantReadWriteLockTest
259          lock.readLock().lock();
260          Thread t = new Thread(new Runnable() {
261                  public void run(){
262 <                    assertFalse(lock.writeLock().tryLock());
262 >                    threadAssertFalse(lock.writeLock().tryLock());
263                  }
264              });
265          try {
# Line 286 | Line 279 | public class ReentrantReadWriteLockTest
279          Thread t = new Thread(new Runnable() {
280                  public void run(){
281                      try {
282 <                        assertFalse(lock.writeLock().tryLock(1, TimeUnit.MILLISECONDS));
282 >                        threadAssertFalse(lock.writeLock().tryLock(1, TimeUnit.MILLISECONDS));
283                      } catch (Exception ex) {
284 <                        fail("unexpected exception");
284 >                        threadFail("unexpected exception");
285                      }
286                  }
287              });
# Line 307 | Line 300 | public class ReentrantReadWriteLockTest
300          Thread t = new Thread(new Runnable() {
301                  public void run(){
302                      try {
303 <                        assertFalse(lock.readLock().tryLock(1, TimeUnit.MILLISECONDS));
303 >                        threadAssertFalse(lock.readLock().tryLock(1, TimeUnit.MILLISECONDS));
304                      } catch (Exception ex) {
305 <                        fail("unexpected exception");
305 >                        threadFail("unexpected exception");
306                      }
307                  }
308              });
# Line 334 | Line 327 | public class ReentrantReadWriteLockTest
327                  public void run() {
328                      try {
329                          lock.writeLock().lockInterruptibly();
330 <                        fail("should throw");
330 >                        threadFail("should throw");
331                      }
332                      catch(InterruptedException success) {
333                      }
# Line 361 | Line 354 | public class ReentrantReadWriteLockTest
354                  public void run() {
355                      try {
356                          lock.readLock().lockInterruptibly();
357 <                        fail("should throw");
357 >                        threadFail("should throw");
358                      }
359                      catch(InterruptedException success) {
360                      }
# Line 457 | Line 450 | public class ReentrantReadWriteLockTest
450                          lock.writeLock().unlock();
451                      }
452                      catch(InterruptedException e) {
453 <                        fail("unexpected exception");
453 >                        threadFail("unexpected exception");
454                      }
455                  }
456              });
# Line 511 | Line 504 | public class ReentrantReadWriteLockTest
504                          lock.writeLock().lock();
505                          c.await();
506                          lock.writeLock().unlock();
507 <                        fail("should throw");
507 >                        threadFail("should throw");
508                      }
509                      catch(InterruptedException success) {
510                      }
# Line 539 | Line 532 | public class ReentrantReadWriteLockTest
532                          lock.writeLock().lock();
533                          c.awaitNanos(SHORT_DELAY_MS * 2 * 1000000);
534                          lock.writeLock().unlock();
535 <                        fail("should throw");
535 >                        threadFail("should throw");
536                      }
537                      catch(InterruptedException success) {
538                      }
# Line 568 | Line 561 | public class ReentrantReadWriteLockTest
561                          java.util.Date d = new java.util.Date();
562                          c.awaitUntil(new java.util.Date(d.getTime() + 10000));
563                          lock.writeLock().unlock();
564 <                        fail("should throw");
564 >                        threadFail("should throw");
565                      }
566                      catch(InterruptedException success) {
567                      }
# Line 598 | Line 591 | public class ReentrantReadWriteLockTest
591                          lock.writeLock().unlock();
592                      }
593                      catch(InterruptedException e) {
594 <                        fail("unexpected exception");
594 >                        threadFail("unexpected exception");
595                      }
596                  }
597              });
# Line 611 | Line 604 | public class ReentrantReadWriteLockTest
604                          lock.writeLock().unlock();
605                      }
606                      catch(InterruptedException e) {
607 <                        fail("unexpected exception");
607 >                        threadFail("unexpected exception");
608                      }
609                  }
610              });

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines