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.AtomicLongArray; |
12 |
|
|
13 |
|
public class AtomicLongArrayTest extends JSR166TestCase { |
14 |
|
public static void main(String[] args) { |
308 |
|
* a deserialized serialized array holds same values |
309 |
|
*/ |
310 |
|
public void testSerialization() throws Exception { |
311 |
< |
AtomicLongArray l = new AtomicLongArray(SIZE); |
311 |
> |
AtomicLongArray x = new AtomicLongArray(SIZE); |
312 |
|
for (int i = 0; i < SIZE; ++i) |
313 |
< |
l.set(i, -i); |
314 |
< |
|
315 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
316 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
318 |
< |
out.writeObject(l); |
319 |
< |
out.close(); |
320 |
< |
|
321 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
322 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
323 |
< |
AtomicLongArray r = (AtomicLongArray) in.readObject(); |
313 |
> |
x.set(i, -i); |
314 |
> |
AtomicLongArray y = serialClone(x); |
315 |
> |
assertTrue(x != y); |
316 |
> |
assertEquals(x.length(), y.length()); |
317 |
|
for (int i = 0; i < SIZE; ++i) { |
318 |
< |
assertEquals(l.get(i), r.get(i)); |
318 |
> |
assertEquals(x.get(i), y.get(i)); |
319 |
|
} |
320 |
|
} |
321 |
|
|