log.info("entering " + getName());
setupServer();
SocketClientInvoker clientInvoker = new SocketClientInvoker(serverLocator);
clientInvoker.connect();
LeasePinger leasePinger = new LeasePinger(clientInvoker, "abc", 2000);
log.info("expect WARN \"failed to ping to server\"");
Method method = LeasePinger.class.getDeclaredMethod("setLeasePingerId", new Class[]{String.class});
method.setAccessible(true);
method.invoke(leasePinger, new Object[]{"dummyID"});
leasePinger.addClient("def", null, 1000);
// Verify LeasePingerTimerTask has not been created.
Field field = LeasePinger.class.getDeclaredField("timerTask");
field.setAccessible(true);
TimerTask timerTask = (TimerTask) field.get(leasePinger);
assertNull(timerTask);
leasePinger.startPing();
timerTask = (TimerTask) field.get(leasePinger);
assertNotNull(timerTask);
// Verify new LeasePingerTimerTask gets created when adding new Client
// with shorter lease period.
leasePinger.addClient("ghi", null, 500);
TimerTask newTimerTask = (TimerTask) field.get(leasePinger);
assertNotSame(newTimerTask, timerTask);
log.info(getName() + " PASSES");
}