本測(cè)試方法,可以在?https://github.com/cwiki-us-demo/serialize-deserialize-demo-java/blob/master/src/test/java/com/insight/demo/serialize/MessagePackSerializer.java?中找到。
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供香坊網(wǎng)站建設(shè)、香坊做網(wǎng)站、香坊網(wǎng)站設(shè)計(jì)、香坊網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、香坊企業(yè)網(wǎng)站模板建站服務(wù),十余年香坊做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
我們需要定義測(cè)試需要的 MAP,定義 Map 的方法你可以在下面的測(cè)試程序中找到。
/** ??*?SerializationMap ??*/ ?@Test ?public?void?testMessagePackSerializationMap()?{ ?????byte[]?bytes?=?new?byte[0]; ?????String?uuid_a?=?UUID.randomUUID().toString(); ?????String?uuid_b?=?UUID.randomUUID().toString(); ?????//?Instantiate?ObjectMapper?for?MessagePack ?????ObjectMapper?objectMapper?=?new?ObjectMapper(new?MessagePackFactory()); ?????Map?map?=?new?HashMap<>(); ?????MessageData?messageData?=?new?MessageData(); ?????//?Element?A?in?MAP ?????messageData.setUuid(UUID.randomUUID().toString()); ?????messageData.setName("CWIKI.US?-?A"); ?????map.put(uuid_a,?messageData); ?????//?Element?B?in?MAP ?????messageData?=?new?MessageData(); ?????messageData.setUuid(UUID.randomUUID().toString()); ?????messageData.setName("CWIKI.US?-?B"); ?????map.put(uuid_b,?messageData); ?????try?{ ?????????//?Serialize?a?Java?object?to?byte?array ?????????bytes?=?objectMapper.writeValueAsBytes(map); ?????????logger.debug("Length?of?Bytes:?[{}]",?bytes.length); ?????????//?Deserialize?the?byte?array?to?a?MAP ?????????Map ?deserialized?=?objectMapper.readValue(bytes,?new?TypeReference
https://www.cwiki.us/display/Serialization/MessagePack+Jackson+Dataformat
?