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.13 by dl, Fri Jan 9 15:39:10 2004 UTC vs.
Revision 1.14 by dl, Sat Jan 10 01:41:59 2004 UTC

# 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 676 | Line 712 | public class AbstractQueuedSynchronizerT
712              unexpectedException();
713          }
714      }
715 +
716      
717   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines