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

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.78 by jsr166, Sat May 7 19:03:26 2011 UTC vs.
Revision 1.79 by jsr166, Mon May 9 20:00:19 2011 UTC

# Line 7 | Line 7
7   */
8  
9   import junit.framework.*;
10 + import java.io.ByteArrayInputStream;
11 + import java.io.ByteArrayOutputStream;
12 + import java.io.ObjectInputStream;
13 + import java.io.ObjectOutputStream;
14   import java.util.Arrays;
15   import java.util.NoSuchElementException;
16   import java.util.PropertyPermission;
# Line 844 | Line 848 | public class JSR166TestCase extends Test
848      public Runnable awaiter(final CountDownLatch latch) {
849          return new CheckedRunnable() {
850              public void realRun() throws InterruptedException {
851 <                latch.await();
851 >                await(latch);
852              }};
853      }
854  
855 +    public void await(CountDownLatch latch) {
856 +        try {
857 +            assertTrue(latch.await(LONG_DELAY_MS, MILLISECONDS));
858 +        } catch (Throwable t) {
859 +            threadUnexpectedException(t);
860 +        }
861 +    }
862 +
863      public static class NPETask implements Callable<String> {
864          public String call() { throw new NullPointerException(); }
865      }
# Line 1095 | Line 1107 | public class JSR166TestCase extends Test
1107          }
1108      }
1109  
1110 +    @SuppressWarnings("unchecked")
1111 +    public <T> T serialClone(T o) {
1112 +        try {
1113 +            ByteArrayOutputStream bos = new ByteArrayOutputStream();
1114 +            ObjectOutputStream oos = new ObjectOutputStream(bos);
1115 +            oos.writeObject(o);
1116 +            oos.flush();
1117 +            oos.close();
1118 +            ByteArrayInputStream bin =
1119 +                new ByteArrayInputStream(bos.toByteArray());
1120 +            ObjectInputStream ois = new ObjectInputStream(bin);
1121 +            return (T) ois.readObject();
1122 +        } catch (Throwable t) {
1123 +            threadUnexpectedException(t);
1124 +            return null;
1125 +        }
1126 +    }
1127   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines