package peer;
import util.Log;
import junit.framework.TestCase;
public class RobustStrategyTest extends TestCase {
PeerHash myMap = new PeerHash();
Peer peer1;
Peer peer2;
RobustStrategy robustStrategy;
protected void setUp() throws Exception {
super.setUp();
peer1 = new Peer("peer1",0,0);
peer2 = new Peer("peer2",0,0);
myMap.set(peer1);
myMap.set(peer2);
robustStrategy = new RobustStrategy();
}
public void xtestRemoveAllNodes() {
try{
Thread.sleep(11000);
} catch (InterruptedException e){
System.out.println("Thread Interrupted Exception");
e.printStackTrace();
}
robustStrategy.removeDeadNodes(myMap, new Log());
assertTrue(myMap.getHashtable().size() == 0);
}
public void testRemoveNoNodes() {
robustStrategy.removeDeadNodes(myMap, new Log());
assertTrue(myMap.getHashtable().size() == 2);
}
// public void testGetNearestPeers() {
// HashMap nearestPeers = robustStrategy.getNearestPeers(myMap);
// assertTrue(nearestPeers.size() == 3);
// assertFalse(nearestPeers.containsKey("key1"));
// assertFalse(nearestPeers.containsKey("key2"));
// assertFalse(nearestPeers.containsKey("key3"));
//
// }
}