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

Comparing jsr166/src/test/tck/TimeUnitTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:56 2003 UTC vs.
Revision 1.2 by dl, Sun Sep 7 20:39:11 2003 UTC

# Line 8 | Line 8
8  
9   import junit.framework.*;
10   import java.util.concurrent.*;
11 + import java.io.*;
12  
13   public class TimeUnitTest extends TestCase {
14        static public boolean DEBUG = false;
# Line 241 | Line 242 | public class TimeUnitTest extends TestCa
242              fail("Unexpected exception");
243          }
244      }
245 +
246 +    public void testSerialization() {
247 +        TimeUnit q = TimeUnit.MILLISECONDS;
248 +
249 +        try {
250 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
251 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
252 +            out.writeObject(q);
253 +            out.close();
254 +
255 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
256 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
257 +            TimeUnit r = (TimeUnit)in.readObject();
258 +            
259 +            assertEquals(q.toString(), r.toString());
260 +        } catch(Exception e){
261 +            e.printStackTrace();
262 +            fail("unexpected exception");
263 +        }
264 +    }
265 +
266   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines