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

Comparing jsr166/src/test/tck/ReentrantLockTest.java (file contents):
Revision 1.6 by dl, Sat Sep 20 18:20:08 2003 UTC vs.
Revision 1.10 by dl, Sat Dec 27 14:16:33 2003 UTC

# Line 57 | Line 57 | public class ReentrantLockTest extends J
57              return super.getQueuedThreads();
58          }
59          public ConditionObject newCondition() {
60 <            return new PublicCondition(this);
60 >            return new PublicCondition();
61          }
62  
63 <        static class PublicCondition extends ReentrantLock.ConditionObject {
64 <            PublicCondition(PublicReentrantLock l) { super(l); }
63 >        class PublicCondition extends ReentrantLock.ConditionObject {
64 >            PublicCondition() { }
65              public Collection<Thread> getWaitingThreads() {
66                  return super.getWaitingThreads();
67              }
# Line 69 | Line 69 | public class ReentrantLockTest extends J
69  
70      }
71  
72 <    /*
72 >    /**
73 >     * Constructor sets given fairness
74 >     */
75 >    public void testConstructor() {
76 >        ReentrantLock rl = new ReentrantLock();
77 >        assertFalse(rl.isFair());
78 >        ReentrantLock r2 = new ReentrantLock(true);
79 >        assertTrue(r2.isFair());
80 >    }
81 >
82 >    /**
83       * locking an unlocked lock succeeds
84       */
85      public void testLock() {
# Line 79 | Line 89 | public class ReentrantLockTest extends J
89          rl.unlock();
90      }
91  
92 <    /*
92 >    /**
93       * locking an unlocked fair lock succeeds
94       */
95      public void testFairLock() {
# Line 89 | Line 99 | public class ReentrantLockTest extends J
99          rl.unlock();
100      }
101  
102 <    /*
102 >    /**
103       * Unlocking an unlocked lock throws IllegalMonitorStateException
104       */
105      public void testUnlock_IllegalMonitorStateException() {
# Line 101 | Line 111 | public class ReentrantLockTest extends J
111          } catch(IllegalMonitorStateException success){}
112      }
113  
114 <    /*
114 >    /**
115       * trylock on an unlocked lock succeeds
116       */
117      public void testTryLock() {
# Line 112 | Line 122 | public class ReentrantLockTest extends J
122      }
123  
124  
125 <    /*
126 <     * getLockQueueLength reports number of waiting threads
125 >    /**
126 >     * getQueueLength reports number of waiting threads
127       */
128 <    public void testGetLockQueueLength() {
128 >    public void testGetQueueLength() {
129          final ReentrantLock lock = new ReentrantLock();
130          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
131          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
132          try {
133 <            assertEquals(0, lock.getLockQueueLength());
133 >            assertEquals(0, lock.getQueueLength());
134              lock.lock();
135              t1.start();
136              Thread.sleep(SHORT_DELAY_MS);
137 <            assertEquals(1, lock.getLockQueueLength());
137 >            assertEquals(1, lock.getQueueLength());
138              t2.start();
139              Thread.sleep(SHORT_DELAY_MS);
140 <            assertEquals(2, lock.getLockQueueLength());
140 >            assertEquals(2, lock.getQueueLength());
141              t1.interrupt();
142              Thread.sleep(SHORT_DELAY_MS);
143 <            assertEquals(1, lock.getLockQueueLength());
143 >            assertEquals(1, lock.getQueueLength());
144              lock.unlock();
145              Thread.sleep(SHORT_DELAY_MS);
146 <            assertEquals(0, lock.getLockQueueLength());
146 >            assertEquals(0, lock.getQueueLength());
147              t1.join();
148              t2.join();
149          } catch(Exception e){
# Line 141 | Line 151 | public class ReentrantLockTest extends J
151          }
152      }
153  
154 <    /*
154 >    /**
155       * getQueuedThreads includes waiting threads
156       */
157      public void testGetQueuedThreads() {
# Line 174 | Line 184 | public class ReentrantLockTest extends J
184      }
185  
186  
187 <    /*
187 >    /**
188       * timed trylock is interruptible.
189       */
190      public void testInterruptedException2() {
# Line 290 | Line 300 | public class ReentrantLockTest extends J
300      }
301  
302  
303 <    /*
303 >    /**
304       * lockInterruptibly is interruptible.
305       */
306      public void testLockInterruptibly1() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines