SessionCloseOnGCTest#testCloseOneSessionOnGC avoiding intermittent failure

This commit is contained in:
Clebert Suconic 2015-10-26 11:10:48 -04:00
parent 15b8b8138b
commit bd946d2ce8
1 changed files with 8 additions and 2 deletions

View File

@ -16,6 +16,8 @@
*/
package org.apache.activemq.artemis.tests.integration.client;
import java.lang.ref.WeakReference;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
@ -26,8 +28,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.lang.ref.WeakReference;
public class SessionCloseOnGCTest extends ActiveMQTestBase {
private ActiveMQServer server;
@ -191,6 +191,12 @@ public class SessionCloseOnGCTest extends ActiveMQTestBase {
ActiveMQTestBase.checkWeakReferences(wses);
for (int i = 0; i < 100 && sf.numSessions() != 0; i++) {
System.gc();
System.runFinalization();
Thread.sleep(100);
}
Assert.assertEquals(0, sf.numSessions());
Assert.assertEquals(1, sf.numConnections());
Assert.assertEquals(1, server.getRemotingService().getConnections().size());