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.19 by jsr166, Tue Mar 15 19:47:06 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 51 | Line 50 | public class AtomicReferenceArrayTest ex
50              assertEquals(a[i], ai.get(i));
51      }
52  
54
53      /**
54       * get and set for out of bound indices throw IndexOutOfBoundsException
55       */
# Line 179 | 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();
191 <
192 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
193 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
194 <        AtomicReferenceArray r = (AtomicReferenceArray) in.readObject();
195 <        assertEquals(l.length(), r.length());
196 <        for (int i = 0; i < SIZE; ++i) {
197 <            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  
201
192      /**
193       * toString returns current value.
194       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines