Skip to content

Commit 01378b3

Browse files
author
Myron Scott
committed
Improve test
1 parent f0943d7 commit 01378b3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/src/test/java/com/tc/net/core/TCConnectionManagerTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
import junit.framework.TestCase;
3232
import com.tc.net.protocol.TCProtocolAdaptor;
33+
import com.tc.properties.TCPropertiesImpl;
34+
import java.util.Collections;
3335

3436
/**
3537
* TODO Jan 13, 2005: comment describing what this class is for.
@@ -43,6 +45,7 @@ public class TCConnectionManagerTest extends TestCase {
4345
@Override
4446
protected void setUp() throws Exception {
4547
super.setUp();
48+
TCPropertiesImpl.getProperties().overwriteTcPropertiesFromConfig(Collections.emptyMap());
4649
this.clientConnMgr = new TCConnectionManagerImpl();
4750
this.serverConnMgr = new TCConnectionManagerImpl();
4851
this.lsnr = this.serverConnMgr.createListener(new TCSocketAddress(0), new ProtocolAdaptorFactory() {
@@ -160,14 +163,14 @@ public void testActiveClientConnections() throws Exception {
160163
System.out.println("Waiting for client conns");
161164
ThreadUtil.reallySleep(500);
162165
}
163-
166+
assertEquals(0, serverConnMgr.getAllActiveConnections().length);
167+
164168
conns = serverConnMgr.getAllConnections();
165169
assertTrue(2 <= conns.length);
166170

167171
for (TCConnection conn : conns) {
168172
conn.setTransportEstablished();
169173
}
170-
assertEquals(2, serverConnMgr.getAllActiveConnections().length);
171174

172175
conns = clientConnMgr.getAllConnections();
173176
assertEquals(2, conns.length);
@@ -191,7 +194,7 @@ public void testActiveClientConnections() throws Exception {
191194
}
192195

193196
public void testInActiveClientConnections() throws Exception {
194-
HealthCheckerConfig hcConfig = new HealthCheckerConfigImpl(1000, 1000, 5, "testInActiveClientConnections", false);
197+
HealthCheckerConfig hcConfig = new HealthCheckerConfigImpl(250, 250, 2, "testInActiveClientConnections", false);
195198
this.serverConnMgr = new TCConnectionManagerImpl("TestConnMgr", 0, hcConfig, new ClearTextBufferManagerFactory());
196199
this.lsnr = this.serverConnMgr.createListener(new TCSocketAddress(0), new ProtocolAdaptorFactory() {
197200
@Override
@@ -222,7 +225,7 @@ public TCProtocolAdaptor getInstance() {
222225

223226
assertEquals(2, serverConnMgr.getAllActiveConnections().length);
224227

225-
long sleepTime = ConnectionHealthCheckerUtil.getMaxIdleTimeForAlive(hcConfig, false) + 2000 /* buffer sleep time */;
228+
long sleepTime = ConnectionHealthCheckerUtil.getMaxIdleTimeForAlive(hcConfig, false) * 2; /* buffer sleep time */;
226229
System.out.println("making client connections inactive. sleeping for " + sleepTime + "ms.");
227230
ThreadUtil.reallySleep(sleepTime);
228231

0 commit comments

Comments
 (0)