|
20 | 20 | import com.google.gson.internal.LinkedHashTreeMap.AvlBuilder;
|
21 | 21 | import com.google.gson.internal.LinkedHashTreeMap.AvlIterator;
|
22 | 22 | import com.google.gson.internal.LinkedHashTreeMap.Node;
|
| 23 | + |
| 24 | +import java.io.ByteArrayInputStream; |
| 25 | +import java.io.ByteArrayOutputStream; |
| 26 | +import java.io.IOException; |
| 27 | +import java.io.ObjectInputStream; |
| 28 | +import java.io.ObjectOutputStream; |
23 | 29 | import java.util.ArrayList;
|
24 | 30 | import java.util.Arrays;
|
| 31 | +import java.util.Collections; |
25 | 32 | import java.util.Iterator;
|
26 | 33 | import java.util.Map;
|
27 | 34 | import java.util.Random;
|
@@ -224,6 +231,20 @@ public void testDoubleCapacityAllNodesOnLeft() {
|
224 | 231 | }
|
225 | 232 | }
|
226 | 233 |
|
| 234 | + public void testJavaSerialization() throws IOException, ClassNotFoundException { |
| 235 | + ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 236 | + ObjectOutputStream objOut = new ObjectOutputStream(out); |
| 237 | + Map<String, Integer> map = new LinkedHashTreeMap<String, Integer>(); |
| 238 | + map.put("a", 1); |
| 239 | + objOut.writeObject(map); |
| 240 | + objOut.close(); |
| 241 | + |
| 242 | + ObjectInputStream objIn = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray())); |
| 243 | + @SuppressWarnings("unchecked") |
| 244 | + Map<String, Integer> deserialized = (Map<String, Integer>) objIn.readObject(); |
| 245 | + assertEquals(Collections.singletonMap("a", 1), deserialized); |
| 246 | + } |
| 247 | + |
227 | 248 | private static final Node<String, String> head = new Node<String, String>();
|
228 | 249 |
|
229 | 250 | private Node<String, String> node(String value) {
|
|
0 commit comments