7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
< |
import java.util.concurrent.atomic.*; |
11 |
< |
import java.io.*; |
10 |
> |
import java.util.concurrent.atomic.AtomicBoolean; |
11 |
|
|
12 |
|
public class AtomicBooleanTest extends JSR166TestCase { |
13 |
|
public static void main(String[] args) { |
118 |
|
* a deserialized serialized atomic holds same value |
119 |
|
*/ |
120 |
|
public void testSerialization() throws Exception { |
121 |
< |
AtomicBoolean l = new AtomicBoolean(); |
122 |
< |
|
123 |
< |
l.set(true); |
124 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
125 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
126 |
< |
out.writeObject(l); |
127 |
< |
out.close(); |
129 |
< |
|
130 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
131 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
132 |
< |
AtomicBoolean r = (AtomicBoolean) in.readObject(); |
133 |
< |
assertEquals(l.get(), r.get()); |
121 |
> |
AtomicBoolean x = new AtomicBoolean(); |
122 |
> |
AtomicBoolean y = serialClone(x); |
123 |
> |
x.set(true); |
124 |
> |
AtomicBoolean z = serialClone(x); |
125 |
> |
assertTrue(x.get()); |
126 |
> |
assertFalse(y.get()); |
127 |
> |
assertTrue(z.get()); |
128 |
|
} |
129 |
|
|
130 |
|
/** |