Skip to content

Commit 7b873f7

Browse files
authored
Get rid of unreliable TimerTest. (#408)
Replaced `TimerTest` by unit test.
1 parent 15e658d commit 7b873f7

File tree

4 files changed

+17
-362
lines changed

4 files changed

+17
-362
lines changed

quickfixj-core/src/test/java/quickfix/SessionStateTest.java

+17
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ public void testTestRequestTiming() {
7070
assertFalse("testRequest shouldn't be needed yet", state.isTestRequestNeeded());
7171
}
7272

73+
@Test
74+
public void testHeartbeatTiming() {
75+
// we set a HB interval of 2 seconds = 2000ms
76+
SessionState state = new SessionState(new Object(), null, 2 /* HB interval */, false, null,
77+
Session.DEFAULT_TEST_REQUEST_DELAY_MULTIPLIER, Session.DEFAULT_HEARTBEAT_TIMEOUT_MULTIPLIER);
78+
79+
long now = System.currentTimeMillis();
80+
timeSource.setSystemTimes(now);
81+
state.setLastSentTime(now);
82+
assertFalse("heartbeat shouldn't be needed yet", state.isHeartBeatNeeded());
83+
timeSource.increment(1000);
84+
assertFalse("heartbeat shouldn't be needed yet", state.isHeartBeatNeeded());
85+
timeSource.increment(1000);
86+
// current time is now 2000ms further since the start, i.e. the HB interval has elapsed
87+
assertTrue("heartbeat should be needed", state.isHeartBeatNeeded());
88+
}
89+
7390
@Test
7491
public void testSessionTimeout() {
7592
SessionState state = new SessionState(new Object(), null, 30, false, null,

quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTest.java

-43
This file was deleted.

quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTestClient.java

-150
This file was deleted.

quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTestServer.java

-169
This file was deleted.

0 commit comments

Comments
 (0)