*/
@Test
public void testSendingAnAsynchronousMessageWithNoReplyMaxTimesRequestingNode()
throws ClassNotFoundException, IOException, NoPeerConnectionException, NoSessionException {
// select two random nodes
NetworkManager nodeA = network.get(random.nextInt(networkSize / 2));
NetworkManager nodeB = network.get(random.nextInt(networkSize / 2) + networkSize / 2);
// receiver nodes should already know the public key of the senders
nodeA.getSession().getKeyManager().putPublicKey(nodeB.getUserId(), getPublicKey(nodeB));
nodeB.getSession().getKeyManager().putPublicKey(nodeA.getUserId(), getPublicKey(nodeA));
// generate a random content key
String contentKey = NetworkTestUtil.randomString();
// create a message with target node B
TestMessageWithReplyMaxSending message = new TestMessageWithReplyMaxSending(nodeB.getNodeId(),
contentKey);
// create and add a callback handler
TestCallBackHandlerMaxSendig callBackHandler = message.new TestCallBackHandlerMaxSendig(nodeA);
message.setCallBackHandler(callBackHandler);
// send message
assertTrue(nodeA.getMessageManager().send(message, getPublicKey(nodeB)));
// wait till callback handler gets executed
H2HWaiter w = new H2HWaiter(10);
FutureGet futureGet = null;
do {
w.tickASecond();
futureGet = nodeB.getDataManager().getUnblocked(
new Parameters().setLocationKey(nodeA.getNodeId()).setContentKey(contentKey));
futureGet.awaitUninterruptibly();
} while (futureGet.getData() == null);
// load and verify if same secret was shared
String receivedSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
futureGet = nodeB.getDataManager().getUnblocked(
new Parameters().setLocationKey(nodeB.getNodeId()).setContentKey(contentKey));
futureGet.awaitUninterruptibly();
String originalSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
assertEquals(originalSecret, receivedSecret);
}