// enable leasing on client
Map conf = new HashMap();
conf.put(Client.ENABLE_LEASE, Boolean.TRUE);
conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, "999");
Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL, conf);
client.connect();
long leasePeriod = client.getLeasePeriod();
assertEquals(999, leasePeriod);
ServerManagement.kill(0);
// wait long enough so we get into lease pinging trouble, send around 5 pings; the lease
// pinger will still be pinging, thinking that the server is up. In my opinion, this is a
// Remoting design flaw, but we can work around from Messaging, so it's ok. I am using this
// test to detect a change in behavior of future remoting releases.
int i = 0;
long upperLimit = System.currentTimeMillis() + 5 * leasePeriod;
while(System.currentTimeMillis() < upperLimit)
{
i++;
assertEquals("attempt " + i, 999, client.getLeasePeriod());
Thread.sleep(1000);
}
}