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.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 SemaphoreTest extends TestCase{
13 > public class SemaphoreTest extends JSR166TestCase {
14  
15      public static void main(String[] args) {
16          junit.textui.TestRunner.run (suite());  
# Line 20 | Line 20 | public class SemaphoreTest extends TestC
20          return new TestSuite(SemaphoreTest.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          Semaphore s = new Semaphore(0);
25          assertEquals(0, s.availablePermits());
# Line 92 | Line 87 | public class SemaphoreTest extends TestC
87                          s.release();
88                          s.acquire();
89                      }catch(InterruptedException ie){
90 <                        fail("unexpected exception");
90 >                        threadFail("unexpected exception");
91                      }
92                  }
93              });
# Line 133 | Line 128 | public class SemaphoreTest extends TestC
128                  public void run(){
129                      try{
130                          s.release();
131 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
131 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
132                          s.release();
133 <                        assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
133 >                        threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
134  
135                      }catch(InterruptedException ie){
136 <                        fail("unexpected exception");
136 >                        threadFail("unexpected exception");
137                      }
138                  }
139              });
# Line 160 | Line 155 | public class SemaphoreTest extends TestC
155                  public void run(){
156                      try{
157                          s.acquire();
158 <                        fail("should throw");
158 >                        threadFail("should throw");
159                      }catch(InterruptedException success){}
160                  }
161              });
# Line 180 | Line 175 | public class SemaphoreTest extends TestC
175                  public void run(){
176                      try{
177                          s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
178 <                        fail("should throw");
178 >                        threadFail("should throw");
179                      }catch(InterruptedException success){
180                      }
181                  }
# Line 197 | Line 192 | public class SemaphoreTest extends TestC
192  
193      public void testSerialization() {
194          Semaphore l = new Semaphore(3);
200
195          try {
196              l.acquire();
197              l.release();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines