* cleaned-up.
*/
public void testClientCrash() throws Exception
{
ServerManagement.create(2);
Server remoteServer = ServerManagement.getServer(2);
// Make sure any previously downloadeded CF is released
WeakReference ref = new WeakReference(ic[0].lookup("/ClusteredConnectionFactory"));
int count=0;
while (ref.get() != null)
{
// put some garbage on the memory
for (int i=0; i<50000 ; i++)
{
String str = "Garbage " + i;
}
System.gc();
Thread.sleep(1000);
if ((count++>10) && ref.get() != null)
{
fail("Thre is a leak on ClusteredConnectionFactory");
}
}
ClientClusteredConnectionFactoryDelegate cfDelegate = (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();
log.info("(Before)Server0 - " + getCountOnServer(0, cfDelegate.getUniqueName()));
log.info("(Before)Server1 - " + getCountOnServer(1, cfDelegate.getUniqueName()));
assertEquals(1, getCountOnServer(0, cfDelegate.getUniqueName()));
assertEquals(1, getCountOnServer(1, cfDelegate.getUniqueName()));
cfDelegate.closeCallback();
// Validates if closeCallback is working
assertEquals(0, getCountOnServer(0, cfDelegate.getUniqueName()));
assertEquals(0, getCountOnServer(1, cfDelegate.getUniqueName()));
ClusterClientCrash command = new ClusterClientCrash(cf);
assertEquals("OK", remoteServer.executeCommand(command));
assertEquals(new Integer(1),ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));