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

Comparing jsr166/src/test/tck/FairSemaphoreTest.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.*;
10   import java.util.concurrent.*;
11   import java.io.*;
12  
13 < public class FairSemaphoreTest extends TestCase{
13 > public class FairSemaphoreTest extends JSR166TestCase{
14  
15      public static void main(String[] args) {
16          junit.textui.TestRunner.run (suite());  
# Line 20 | Line 20 | public class FairSemaphoreTest extends T
20          return new TestSuite(FairSemaphoreTest.class);
21      }
22  
23    private static long SHORT_DELAY_MS = 100;
24    private static long MEDIUM_DELAY_MS = 1000;
25    private static long LONG_DELAY_MS = 10000;
26
27
23      public void testConstructor1() {
24          FairSemaphore s = new FairSemaphore(0);
25          assertEquals(0, s.availablePermits());
# Line 119 | Line 114 | public class FairSemaphoreTest extends T
114                          s.acquire();
115                          s.acquire();
116                      }catch(InterruptedException ie){
117 <                        fail("unexpected exception");
117 >                        threadFail("unexpected exception");
118                      }
119                  }
120              });
# Line 147 | Line 142 | public class FairSemaphoreTest extends T
142                          s.acquire(2);
143                          s.acquire(2);
144                      }catch(InterruptedException ie){
145 <                        fail("unexpected exception");
145 >                        threadFail("unexpected exception");
146                      }
147                  }
148              });
# Line 206 | Line 201 | public class FairSemaphoreTest extends T
201          Thread t = new Thread(new Runnable(){
202                  public void run(){
203                      try{
204 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
205 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
206 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
207 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
208 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
204 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
205 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
206 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
207 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
208 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
209  
210                      }catch(InterruptedException ie){
211 <                        fail("unexpected exception");
211 >                        threadFail("unexpected exception");
212                      }
213                  }
214              });
# Line 235 | Line 230 | public class FairSemaphoreTest extends T
230          Thread t = new Thread(new Runnable(){
231                  public void run(){
232                      try{
233 <                        assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
233 >                        threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
234                          s.release(2);
235 <                        assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
235 >                        threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
236                          s.release(2);
237                      }catch(InterruptedException ie){
238 <                        fail("unexpected exception");
238 >                        threadFail("unexpected exception");
239                      }
240                  }
241              });
# Line 262 | Line 257 | public class FairSemaphoreTest extends T
257                  public void run(){
258                      try{
259                          s.acquire();
260 <                        fail("should throw");
260 >                        threadFail("should throw");
261                      }catch(InterruptedException success){}
262                  }
263              });
# Line 282 | Line 277 | public class FairSemaphoreTest extends T
277                  public void run(){
278                      try{
279                          s.acquire(3);
280 <                        fail("should throw");
280 >                        threadFail("should throw");
281                      }catch(InterruptedException success){}
282                  }
283              });
# Line 302 | Line 297 | public class FairSemaphoreTest extends T
297                  public void run(){
298                      try{
299                          s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
300 <                        fail("should throw");
300 >                        threadFail("should throw");
301                      }catch(InterruptedException success){
302                      }
303                  }
# Line 323 | Line 318 | public class FairSemaphoreTest extends T
318                  public void run(){
319                      try{
320                          s.tryAcquire(4, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
321 <                        fail("should throw");
321 >                        threadFail("should throw");
322                      }catch(InterruptedException success){
323                      }
324                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines