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

Comparing jsr166/src/test/tck/AtomicReferenceArrayTest.java (file contents):
Revision 1.20 by jsr166, Fri May 27 19:39:07 2011 UTC vs.
Revision 1.21 by jsr166, Tue May 31 16:16:23 2011 UTC

# Line 7 | Line 7
7   */
8  
9   import junit.framework.*;
10 < import java.util.concurrent.atomic.*;
11 < import java.io.*;
12 < import java.util.*;
10 > import java.util.Arrays;
11 > import java.util.concurrent.atomic.AtomicReferenceArray;
12  
13   public class AtomicReferenceArrayTest extends JSR166TestCase {
14      public static void main(String[] args) {
# Line 178 | Line 177 | public class AtomicReferenceArrayTest ex
177       * a deserialized serialized array holds same values
178       */
179      public void testSerialization() throws Exception {
180 <        AtomicReferenceArray l = new AtomicReferenceArray(SIZE);
181 <        for (int i = 0; i < SIZE; ++i) {
182 <            l.set(i, new Integer(-i));
183 <        }
184 <
185 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
186 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
187 <        out.writeObject(l);
188 <        out.close();
190 <
191 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
192 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
193 <        AtomicReferenceArray r = (AtomicReferenceArray) in.readObject();
194 <        assertEquals(l.length(), r.length());
195 <        for (int i = 0; i < SIZE; ++i) {
196 <            assertEquals(r.get(i), l.get(i));
180 >        AtomicReferenceArray x = new AtomicReferenceArray(SIZE);
181 >        for (int i = 0; i < SIZE; i++) {
182 >            x.set(i, new Integer(-i));
183 >        }
184 >        AtomicReferenceArray y = serialClone(x);
185 >        assertTrue(x != y);
186 >        assertEquals(x.length(), y.length());
187 >        for (int i = 0; i < SIZE; i++) {
188 >            assertEquals(x.get(i), y.get(i));
189          }
190      }
191  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines