use of water.util.IcedHashMapGeneric in project h2o-3 by h2oai.
the class IcedHasMapGenericTest method testSerialization.
@Test
public void testSerialization() {
IcedHashMapGeneric m = new IcedHashMapGeneric();
// String -> String pair
m.put("haha", "gaga");
// String -> String pair
m.put("str->freezable", new IcedDouble(3.14));
// String -> String pair
m.put("str->freezable[]", new Freezable[] { new IcedDouble(3.14) });
// String -> String pair
m.put("str->Integer", 314);
// Freezable -> String pair
m.put(new BufferedString("haha2"), "gaga");
// String -> String pair
m.put(new BufferedString("str->freezable2"), new IcedDouble(3.14));
// String -> String pair
m.put(new BufferedString("str->freezable[]2"), new Freezable[] { new IcedDouble(3.14) });
// String -> String pair
m.put(new BufferedString("str->Integer2"), 314);
// String -> String pair
m.put(new IcedLong(1234), 1234);
byte[] buf = new AutoBuffer().put(m).buf();
IcedHashMapGeneric m2 = new AutoBuffer(buf).get();
assertEquals(m.size(), m2.size());
Set<Map.Entry> entries = m.entrySet();
for (Map.Entry e : entries) {
if (e.getValue() instanceof Freezable[])
assert Arrays.deepEquals((Freezable[]) e.getValue(), (Freezable[]) m2.get(e.getKey()));
else
assertEquals(e.getValue(), m2.get(e.getKey()));
}
}
Aggregations