@Test public void testDataSyncMessageEncodeDecode() throws Exception { Map<Long, Chain> chainMap = new HashMap<>(); Chain chain = getChain(true, createPayload(10L), createPayload(100L), createPayload(1000L)); chainMap.put(1L, chain); chainMap.put(2L, chain); chainMap.put(3L, chain); EhcacheDataSyncMessage message = new EhcacheDataSyncMessage(chainMap); byte[] encodedMessage = codec.encode(0, message); EhcacheDataSyncMessage decoded = (EhcacheDataSyncMessage) codec.decode(0, encodedMessage); Map<Long, Chain> decodedChainMap = decoded.getChainMap(); assertThat(decodedChainMap).hasSize(3); assertThat(chainsEqual(decodedChainMap.get(1L), chain)).isTrue(); assertThat(chainsEqual(decodedChainMap.get(2L), chain)).isTrue(); assertThat(chainsEqual(decodedChainMap.get(3L), chain)).isTrue(); }
Chain elements1 = serverStoreProxy1.get(i); Chain elements2 = serverStoreProxy2.get(i); assertThat(chainsEqual(elements1, elements2), is(true)); if (!elements1.isEmpty()) { entryCount++;
Chain elements1 = serverStoreProxy1.get(i); Chain elements2 = serverStoreProxy2.get(i); assertThat(chainsEqual(elements1, elements2), is(true)); if (!elements1.isEmpty()) { entryCount++;
@Test public void testChainReplicationMessageCodec() { Chain chain = getChain(false, createPayload(2L), createPayload(20L)); ChainReplicationMessage chainReplicationMessage = new ChainReplicationMessage(2L, chain, 200L, 100L, 1L); byte[] encoded = codec.encode(chainReplicationMessage); ChainReplicationMessage decodedMsg = (ChainReplicationMessage) codec.decode(EhcacheMessageType.CHAIN_REPLICATION_OP, wrap(encoded)); assertThat(decodedMsg.getClientId(), is(chainReplicationMessage.getClientId())); assertThat(decodedMsg.getTransactionId(), is(chainReplicationMessage.getTransactionId())); assertThat(decodedMsg.getOldestTransactionId(), is(chainReplicationMessage.getOldestTransactionId())); assertThat(decodedMsg.getKey(), is(chainReplicationMessage.getKey())); assertTrue(chainsEqual(decodedMsg.getChain(), chainReplicationMessage.getChain())); }