childArray.add(1.23f);
hashMap.put("childArray", childArray);
long bitmap = 0;
byte[] bytes = objectMapper.writeValueAsBytes(hashMap);
MessageUnpacker messageUnpacker = new MessageUnpacker(new ArrayBufferInput(bytes));
assertEquals(hashMap.size(), messageUnpacker.unpackMapHeader());
for (int i = 0; i < hashMap.size(); i++) {
String key = messageUnpacker.unpackString();
if (key.equals("str")) {
// #1
assertEquals("komamitsu", messageUnpacker.unpackString());
bitmap |= 0x1 << 0;
}
else if (key.equals("boolean")) {
// #2
assertTrue(messageUnpacker.unpackBoolean());
bitmap |= 0x1 << 1;
}
else if (key.equals("int")) {
// #3
assertEquals(Integer.MAX_VALUE, messageUnpacker.unpackInt());
bitmap |= 0x1 << 2;
}
else if (key.equals("long")) {
// #4
assertEquals(Long.MIN_VALUE, messageUnpacker.unpackLong());
bitmap |= 0x1 << 3;
}
else if (key.equals("float")) {
// #5
assertEquals(3.14159f, messageUnpacker.unpackFloat(), 0.01f);
bitmap |= 0x1 << 4;
}
else if (key.equals("double")) {
// #6
assertEquals(3.14159d, messageUnpacker.unpackDouble(), 0.01f);
bitmap |= 0x1 << 5;
}
else if (key.equals("bin")) {
// #7
assertEquals(4, messageUnpacker.unpackBinaryHeader());
assertEquals((byte)0x00, messageUnpacker.unpackByte());
assertEquals((byte)0x01, messageUnpacker.unpackByte());
assertEquals((byte)0xFE, messageUnpacker.unpackByte());
assertEquals((byte)0xFF, messageUnpacker.unpackByte());
bitmap |= 0x1 << 6;
}
else if (key.equals("childObj")) {
// #8
assertEquals(2, messageUnpacker.unpackMapHeader());
for (int j = 0; j < 2; j++) {
String childKey = messageUnpacker.unpackString();
if (childKey.equals("co_str")) {
assertEquals("child#0", messageUnpacker.unpackString());
bitmap |= 0x1 << 7;
}
else if (childKey.equals("co_int")) {
assertEquals(12345, messageUnpacker.unpackInt());
bitmap |= 0x1 << 8;
}
else {
assertTrue(false);
}
}
}
else if (key.equals("childArray")) {
// #9
assertEquals(2, messageUnpacker.unpackArrayHeader());
assertEquals("child#1", messageUnpacker.unpackString());
assertEquals(1.23f, messageUnpacker.unpackFloat(), 0.01f);
bitmap |= 0x1 << 9;
}
else {
assertTrue(false);
}