diff --git a/quickfixj-core/src/test/java/quickfix/SessionStateTest.java b/quickfixj-core/src/test/java/quickfix/SessionStateTest.java
index dc0a5e8440..a19e48f949 100644
--- a/quickfixj-core/src/test/java/quickfix/SessionStateTest.java
+++ b/quickfixj-core/src/test/java/quickfix/SessionStateTest.java
@@ -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,
diff --git a/quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTest.java b/quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTest.java
deleted file mode 100644
index 5d6600d192..0000000000
--- a/quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) quickfixengine.org All rights reserved.
- *
- * This file is part of the QuickFIX FIX Engine
- *
- * This file may be distributed under the terms of the quickfixengine.org
- * license as defined by quickfixengine.org and appearing in the file
- * LICENSE included in the packaging of this file.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
- * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * See http://www.quickfixengine.org/LICENSE for licensing information.
- *
- * Contact ask@quickfixengine.org if any conditions of this licensing
- * are not clear to you.
- ******************************************************************************/
-
-package quickfix.test.acceptance.timer;
-
-import junit.framework.TestCase;
-import quickfix.ConfigError;
-import quickfix.SessionNotFound;
-
-public class TimerTest extends TestCase {
-
- TimerTestServer server;
-
- public void testAcceptorTimer() throws ConfigError, SessionNotFound, InterruptedException {
- new TimerTestClient().run();
- }
-
- protected void setUp() throws Exception {
- server = new TimerTestServer();
- server.start();
- server.waitForInitialization();
- }
-
- protected void tearDown() throws Exception {
- server.stop();
- }
-}
diff --git a/quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTestClient.java b/quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTestClient.java
deleted file mode 100644
index 55765bcd83..0000000000
--- a/quickfixj-core/src/test/java/quickfix/test/acceptance/timer/TimerTestClient.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) quickfixengine.org All rights reserved.
- *
- * This file is part of the QuickFIX FIX Engine
- *
- * This file may be distributed under the terms of the quickfixengine.org
- * license as defined by quickfixengine.org and appearing in the file
- * LICENSE included in the packaging of this file.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
- * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * See http://www.quickfixengine.org/LICENSE for licensing information.
- *
- * Contact ask@quickfixengine.org if any conditions of this licensing
- * are not clear to you.
- ******************************************************************************/
-
-package quickfix.test.acceptance.timer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import quickfix.Application;
-import quickfix.ConfigError;
-import quickfix.DefaultMessageFactory;
-import quickfix.DoNotSend;
-import quickfix.FieldNotFound;
-import quickfix.FixVersions;
-import quickfix.IncorrectDataFormat;
-import quickfix.IncorrectTagValue;
-import quickfix.Initiator;
-import quickfix.MemoryStoreFactory;
-import quickfix.Message;
-import quickfix.MessageCracker;
-import quickfix.MessageStoreFactory;
-import quickfix.RejectLogon;
-import quickfix.RuntimeError;
-import quickfix.SLF4JLogFactory;
-import quickfix.SessionID;
-import quickfix.SessionNotFound;
-import quickfix.SessionSettings;
-import quickfix.SocketInitiator;
-import quickfix.UnsupportedMessageType;
-import quickfix.fix44.ListStatusRequest;
-import quickfix.fix44.TestRequest;
-
-import java.util.HashMap;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * @author John Hensley
- */
-public class TimerTestClient extends MessageCracker implements Application {
- private final Logger log = LoggerFactory.getLogger(TimerTestServer.class);
- private final SessionSettings settings = new SessionSettings();
- private final CountDownLatch shutdownLatch = new CountDownLatch(1);
- private boolean failed;
-
- public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound,
- IncorrectDataFormat, IncorrectTagValue, RejectLogon {
- }
-
- public void fromApp(Message message, SessionID sessionID) throws FieldNotFound,
- IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
- crack(message, sessionID);
- }
-
- public void onCreate(SessionID sessionId) {
- }
-
- public void onLogon(SessionID sessionId) {
- }
-
- public void onLogout(SessionID sessionId) {
- }
-
- public void onMessage(ListStatusRequest message, SessionID sessionID) {
- log.info("got ListStatusRequest");
- }
-
- private void stop(boolean failed) {
- this.failed = failed;
- shutdownLatch.countDown();
- }
-
- public void run() throws ConfigError, SessionNotFound, InterruptedException {
- HashMap