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

Comparing jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java (file contents):
Revision 1.12 by dl, Fri Jan 9 14:45:58 2004 UTC vs.
Revision 1.14 by dl, Sat Jan 10 01:41:59 2004 UTC

# Line 254 | Line 254 | public class AbstractQueuedSynchronizerT
254      }
255  
256      /**
257 <     * timed tryAcquireExclusive is interruptible.
257 >     * acquireExclusiveNanos is interruptible.
258       */
259      public void testInterruptedException2() {
260          final Mutex lock = new Mutex();
# Line 297 | Line 297 | public class AbstractQueuedSynchronizerT
297      }
298  
299      /**
300 <     * acquireExclusiveTimed on a locked lock times out
300 >     * acquireExclusiveNanos on a locked lock times out
301       */
302 <    public void testacquireExclusiveTimed_Timeout() {
302 >    public void testAcquireExclusiveNanos_Timeout() {
303          final Mutex lock = new Mutex();
304          lock.acquireExclusiveUninterruptibly(1);
305          Thread t = new Thread(new Runnable() {
# Line 322 | Line 322 | public class AbstractQueuedSynchronizerT
322      
323    
324      /**
325 <     * isLocked is true when locked and false when not
325 >     * getState is true when acquired and false when not
326       */
327 <    public void testIsLocked() {
327 >    public void testGetState() {
328          final Mutex lock = new Mutex();
329          lock.acquireExclusiveUninterruptibly(1);
330          assertTrue(lock.isLocked());
# Line 520 | Line 520 | public class AbstractQueuedSynchronizerT
520          }
521      }
522  
523 +    /**
524 +     * toString indicates current state
525 +     */
526 +    public void testToString() {
527 +        Mutex lock = new Mutex();
528 +        String us = lock.toString();
529 +        assertTrue(us.indexOf("State = 0") >= 0);
530 +        lock.acquireExclusiveUninterruptibly(1);
531 +        String ls = lock.toString();
532 +        assertTrue(ls.indexOf("State = 1") >= 0);
533 +    }
534 +
535 +    /**
536 +     * A serialized AQS deserializes with current state
537 +     */
538 +    public void testSerialization() {
539 +        Mutex l = new Mutex();
540 +        l.acquireExclusiveUninterruptibly(1);
541 +        assertTrue(l.isLocked());
542 +
543 +        try {
544 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
545 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
546 +            out.writeObject(l);
547 +            out.close();
548 +
549 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
550 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
551 +            Mutex r = (Mutex) in.readObject();
552 +            assertTrue(r.isLocked());
553 +        } catch(Exception e){
554 +            e.printStackTrace();
555 +            unexpectedException();
556 +        }
557 +    }
558 +
559  
560      /**
561       * Latch isSignalled initially returns false, then true after release
# Line 534 | Line 570 | public class AbstractQueuedSynchronizerT
570      /**
571       * release and has no effect when already signalled
572       */
573 <    public void testLatchBoolean() {
573 >    public void testReleaseShared() {
574          final BooleanLatch l = new BooleanLatch();
575          assertFalse(l.isSignalled());
576          l.releaseShared(0);
# Line 546 | Line 582 | public class AbstractQueuedSynchronizerT
582      /**
583       * acquireSharedInterruptibly returns after release, but not before
584       */
585 <    public void testLatchAcquireSharedInterruptibly() {
585 >    public void testAcquireSharedInterruptibly() {
586          final BooleanLatch l = new BooleanLatch();
587  
588          Thread t = new Thread(new Runnable() {
# Line 576 | Line 612 | public class AbstractQueuedSynchronizerT
612      /**
613       * acquireSharedTimed returns after release
614       */
615 <    public void testLatchTimedacquireSharedInterruptibly() {
615 >    public void testAsquireSharedTimed() {
616          final BooleanLatch l = new BooleanLatch();
617  
618          Thread t = new Thread(new Runnable() {
# Line 606 | Line 642 | public class AbstractQueuedSynchronizerT
642      /**
643       * acquireSharedInterruptibly throws IE if interrupted before released
644       */
645 <    public void testLatchAcquireSharedInterruptibly_InterruptedException() {
645 >    public void testAcquireSharedInterruptibly_InterruptedException() {
646          final BooleanLatch l = new BooleanLatch();
647          Thread t = new Thread(new Runnable() {
648                  public void run() {
# Line 630 | Line 666 | public class AbstractQueuedSynchronizerT
666      /**
667       * acquireSharedTimed throws IE if interrupted before released
668       */
669 <    public void testLatchTimedAwait_InterruptedException() {
669 >    public void testAcquireSharedNanos_InterruptedException() {
670          final BooleanLatch l = new BooleanLatch();
671          Thread t = new Thread(new Runnable() {
672                  public void run() {
# Line 655 | Line 691 | public class AbstractQueuedSynchronizerT
691      /**
692       * acquireSharedTimed times out if not released before timeout
693       */
694 <    public void testLatchAwaitTimeout() {
694 >    public void testAcquireSharedNanos_Timeout() {
695          final BooleanLatch l = new BooleanLatch();
696          Thread t = new Thread(new Runnable() {
697                  public void run() {
# Line 676 | Line 712 | public class AbstractQueuedSynchronizerT
712              unexpectedException();
713          }
714      }
715 +
716      
717   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines