Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of unreliable TimerTest #408

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions quickfixj-core/src/test/java/quickfix/SessionStateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ public void testTestRequestTiming() {
assertFalse("testRequest shouldn't be needed yet", state.isTestRequestNeeded());
}

@Test
public void testHeartbeatTiming() {
// we set a HB interval of 2 seconds = 2000ms
SessionState state = new SessionState(new Object(), null, 2 /* HB interval */, false, null,
Session.DEFAULT_TEST_REQUEST_DELAY_MULTIPLIER, Session.DEFAULT_HEARTBEAT_TIMEOUT_MULTIPLIER);

long now = System.currentTimeMillis();
timeSource.setSystemTimes(now);
state.setLastSentTime(now);
assertFalse("heartbeat shouldn't be needed yet", state.isHeartBeatNeeded());
timeSource.increment(1000);
assertFalse("heartbeat shouldn't be needed yet", state.isHeartBeatNeeded());
timeSource.increment(1000);
// current time is now 2000ms further since the start, i.e. the HB interval has elapsed
assertTrue("heartbeat should be needed", state.isHeartBeatNeeded());
}

@Test
public void testSessionTimeout() {
SessionState state = new SessionState(new Object(), null, 30, false, null,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.