30
30
31
31
import junit .framework .TestCase ;
32
32
import com .tc .net .protocol .TCProtocolAdaptor ;
33
+ import com .tc .properties .TCPropertiesImpl ;
34
+ import java .util .Collections ;
33
35
34
36
/**
35
37
* TODO Jan 13, 2005: comment describing what this class is for.
@@ -43,6 +45,7 @@ public class TCConnectionManagerTest extends TestCase {
43
45
@ Override
44
46
protected void setUp () throws Exception {
45
47
super .setUp ();
48
+ TCPropertiesImpl .getProperties ().overwriteTcPropertiesFromConfig (Collections .emptyMap ());
46
49
this .clientConnMgr = new TCConnectionManagerImpl ();
47
50
this .serverConnMgr = new TCConnectionManagerImpl ();
48
51
this .lsnr = this .serverConnMgr .createListener (new TCSocketAddress (0 ), new ProtocolAdaptorFactory () {
@@ -160,14 +163,14 @@ public void testActiveClientConnections() throws Exception {
160
163
System .out .println ("Waiting for client conns" );
161
164
ThreadUtil .reallySleep (500 );
162
165
}
163
-
166
+ assertEquals (0 , serverConnMgr .getAllActiveConnections ().length );
167
+
164
168
conns = serverConnMgr .getAllConnections ();
165
169
assertTrue (2 <= conns .length );
166
170
167
171
for (TCConnection conn : conns ) {
168
172
conn .setTransportEstablished ();
169
173
}
170
- assertEquals (2 , serverConnMgr .getAllActiveConnections ().length );
171
174
172
175
conns = clientConnMgr .getAllConnections ();
173
176
assertEquals (2 , conns .length );
@@ -191,7 +194,7 @@ public void testActiveClientConnections() throws Exception {
191
194
}
192
195
193
196
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 );
195
198
this .serverConnMgr = new TCConnectionManagerImpl ("TestConnMgr" , 0 , hcConfig , new ClearTextBufferManagerFactory ());
196
199
this .lsnr = this .serverConnMgr .createListener (new TCSocketAddress (0 ), new ProtocolAdaptorFactory () {
197
200
@ Override
@@ -222,7 +225,7 @@ public TCProtocolAdaptor getInstance() {
222
225
223
226
assertEquals (2 , serverConnMgr .getAllActiveConnections ().length );
224
227
225
- long sleepTime = ConnectionHealthCheckerUtil .getMaxIdleTimeForAlive (hcConfig , false ) + 2000 /* buffer sleep time */ ;
228
+ long sleepTime = ConnectionHealthCheckerUtil .getMaxIdleTimeForAlive (hcConfig , false ) * 2 ; /* buffer sleep time */ ;
226
229
System .out .println ("making client connections inactive. sleeping for " + sleepTime + "ms." );
227
230
ThreadUtil .reallySleep (sleepTime );
228
231
0 commit comments