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

Comparing jsr166/src/test/tck/SemaphoreTest.java (file contents):
Revision 1.43 by jsr166, Tue Jan 23 20:44:11 2018 UTC vs.
Revision 1.44 by jsr166, Mon Aug 12 06:21:11 2019 UTC

# Line 193 | Line 193 | public class SemaphoreTest extends JSR16
193      /**
194       * timed tryAcquire times out
195       */
196 <    public void testTryAcquire_timeout() {
197 <        final boolean fair = ThreadLocalRandom.current().nextBoolean();
196 >    public void testTryAcquire_timeout() throws InterruptedException {
197 >        final boolean fair = randomBoolean();
198          final Semaphore s = new Semaphore(0, fair);
199          final long startTime = System.nanoTime();
200 <        try { assertFalse(s.tryAcquire(timeoutMillis(), MILLISECONDS)); }
201 <        catch (InterruptedException e) { threadUnexpectedException(e); }
200 >        assertFalse(s.tryAcquire(timeoutMillis(), MILLISECONDS));
201          assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
202      }
203  
204      /**
205       * timed tryAcquire(N) times out
206       */
207 <    public void testTryAcquireN_timeout() {
208 <        final boolean fair = ThreadLocalRandom.current().nextBoolean();
207 >    public void testTryAcquireN_timeout() throws InterruptedException {
208 >        final boolean fair = randomBoolean();
209          final Semaphore s = new Semaphore(2, fair);
210          final long startTime = System.nanoTime();
211 <        try { assertFalse(s.tryAcquire(3, timeoutMillis(), MILLISECONDS)); }
213 <        catch (InterruptedException e) { threadUnexpectedException(e); }
211 >        assertFalse(s.tryAcquire(3, timeoutMillis(), MILLISECONDS));
212          assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
213      }
214  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines