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

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

# Line 7 | Line 7
7  
8   import junit.framework.*;
9   import java.util.concurrent.atomic.*;
10 + import java.io.*;
11  
12   public class AtomicLongArrayTest extends TestCase
13   {
# Line 144 | Line 145 | public class AtomicLongArrayTest extends
145          }
146      }
147  
148 +    public void testSerialization() {
149 +        AtomicLongArray l = new AtomicLongArray(N);
150 +        for (int i = 0; i < N; ++i)
151 +            l.set(i, -i);
152 +
153 +        try {
154 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
155 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
156 +            out.writeObject(l);
157 +            out.close();
158 +
159 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
160 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
161 +            AtomicLongArray r = (AtomicLongArray) in.readObject();
162 +            for (int i = 0; i < N; ++i) {
163 +                assertEquals(l.get(i), r.get(i));
164 +            }
165 +        } catch(Exception e){
166 +            e.printStackTrace();
167 +            fail("unexpected exception");
168 +        }
169 +    }
170 +
171 +
172   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines