new PeerBuilderNAT(peer).bufferConfiguration(androidConfig).start();
}
// Test setting up relay peers
unreachablePeer1 = new PeerBuilder(Number160.createHash(rnd.nextInt())).ports(13337).start();
PeerNAT uNat1 = new PeerBuilderNAT(unreachablePeer1).relayType(relayType).gcmServerCredentials(gcmServerCredentials).start();
FutureRelayNAT fbn = uNat1.startRelay(master.peerAddress());
fbn.awaitUninterruptibly();
Assert.assertTrue(fbn.isSuccess());
mockGCM(peers, uNat1);
System.out.print("Send direct message to unreachable peer " + unreachablePeer1.peerAddress());
final String request = "Hello ";
final String response = "World!";
final AtomicBoolean test1 = new AtomicBoolean(false);
final AtomicBoolean test2 = new AtomicBoolean(false);
//final Peer unr = unreachablePeer;
unreachablePeer1.objectDataReply(new ObjectDataReply() {
public Object reply(PeerAddress sender, Object obj) throws Exception {
test1.set(obj.equals(request));
Assert.assertEquals(request.toString(), request);
test2.set(sender.inetAddress().toString().contains("0.0.0.0"));
System.err.println("Got sender:"+sender);
//this is too late here, so we cannot test this here
//Collection<PeerSocketAddress> list = new ArrayList<PeerSocketAddress>();
//list.add(new PeerSocketAddress(InetAddress.getByName("101.101.101.101"), 101, 101));
//unr.peerBean().serverPeerAddress(unr.peerBean().serverPeerAddress().changePeerSocketAddresses(list));
return response;
}
});
unreachablePeer2 = new PeerBuilder(Number160.createHash(rnd.nextInt())).ports(13338).start();
PeerNAT uNat2 = new PeerBuilderNAT(unreachablePeer2).relayType(relayType).gcmServerCredentials(gcmServerCredentials).start();
fbn = uNat2.startRelay(peers[42].peerAddress());
fbn.awaitUninterruptibly();
Assert.assertTrue(fbn.isSuccess());
mockGCM(peers, uNat2);