use of org.infinispan.commons.util.FastCopyHashMap in project infinispan by infinispan.
the class VersionAwareMarshallerTest method testMapMarshalling.
public void testMapMarshalling() throws Exception {
Map<Integer, GlobalTransaction> m1 = new HashMap<>();
Map<Integer, GlobalTransaction> m2 = new TreeMap<>();
Map<Integer, GlobalTransaction> m3 = new HashMap<>();
Map<Integer, GlobalTransaction> m4 = new FastCopyHashMap<>();
for (int i = 0; i < 10; i++) {
JGroupsAddress jGroupsAddress = new JGroupsAddress(UUID.randomUUID());
GlobalTransaction gtx = gtf.newGlobalTransaction(jGroupsAddress, false);
m1.put(1000 * i, gtx);
m2.put(1000 * i, gtx);
m4.put(1000 * i, gtx);
}
Map m5 = Immutables.immutableMapWrap(m3);
marshallAndAssertEquality(m1);
marshallAndAssertEquality(m2);
byte[] bytes = marshaller.objectToByteBuffer(m4);
Map<Integer, GlobalTransaction> m4Read = (Map<Integer, GlobalTransaction>) marshaller.objectFromByteBuffer(bytes);
for (Map.Entry<Integer, GlobalTransaction> entry : m4.entrySet()) {
assert m4Read.get(entry.getKey()).equals(entry.getValue()) : "Writen[" + entry.getValue() + "] and read[" + m4Read.get(entry.getKey()) + "] objects should be the same";
}
marshallAndAssertEquality(m5);
}
Aggregations