MessagePack msgpack = new MessagePack();
Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
Map<K, V> ret = tmpl.read(unpacker, null);
assertEquals(v, ret);