Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package quickfix.test.acceptance.resynch;

import org.apache.mina.util.AvailablePortFinder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -33,11 +34,13 @@
public class ResynchTest {

ResynchTestServer server;
int port;

@Before
public void setUp() throws Exception {
SystemTime.setTimeSource(null);
server = new ResynchTestServer();
port = AvailablePortFinder.getNextAvailable();
server = new ResynchTestServer(port);
}

@After
Expand All @@ -49,7 +52,7 @@ public void tearDown() throws Exception {
public void testAcceptorTimerSync() throws ConfigError, SessionNotFound, InterruptedException {
server.start();
server.waitForInitialization();
new ResynchTestClient().run();
new ResynchTestClient(port).run();
}

@Test(timeout=30000)
Expand All @@ -58,7 +61,7 @@ public void testAcceptorTimerUnsyncWithValidatingSequenceNumbers() throws Config
server.setValidateSequenceNumbers(true);
server.start();
server.waitForInitialization();
ResynchTestClient client = new ResynchTestClient();
ResynchTestClient client = new ResynchTestClient(port);
client.setUnsynchMode(true);
client.run();
}
Expand All @@ -69,7 +72,7 @@ public void testAcceptorTimerUnsyncWithoutValidatingSequenceNumbers() throws Con
server.setValidateSequenceNumbers(false);
server.start();
server.waitForInitialization();
ResynchTestClient client = new ResynchTestClient();
ResynchTestClient client = new ResynchTestClient(port);
client.setUnsynchMode(false);
client.setForceResynch(true);
client.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ public class ResynchTestClient extends MessageCracker implements Application {
private final SessionSettings settings = new SessionSettings();
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
private boolean failed;
private final int port;

private boolean unsynchMode = false;
private boolean forceResynch = false;

public ResynchTestClient(int port) {
this.port = port;
}



public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound,
IncorrectDataFormat, IncorrectTagValue, RejectLogon {
try {
Expand Down Expand Up @@ -102,7 +109,7 @@ public void run() throws ConfigError, SessionNotFound, InterruptedException {
defaults.put("ConnectionType", "initiator");
defaults.put("HeartBtInt", "2");
defaults.put("SocketConnectHost", "localhost");
defaults.put("SocketConnectPort", "19889");
defaults.put("SocketConnectPort", String.valueOf(port));
defaults.put("SocketTcpNoDelay", "Y");
defaults.put("ReconnectInterval", "3");
defaults.put("StartTime", "00:00:00");
Expand Down Expand Up @@ -154,12 +161,6 @@ public void toAdmin(Message message, SessionID sessionId) {
public void toApp(Message message, SessionID sessionId) throws DoNotSend {
}

public static void main(String[] args) throws ConfigError, SessionNotFound,
InterruptedException {
ResynchTestClient ttc = new ResynchTestClient();
ttc.run();
}

public void setUnsynchMode(boolean unsynchMode) {
this.unsynchMode = unsynchMode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ public class ResynchTestServer extends MessageCracker implements Application, Ru
private Thread serverThread;
private final CountDownLatch initializationLatch = new CountDownLatch(1);
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
private final int port;

private boolean unsynchMode = false;
private boolean validateSequenceNumbers = true;

public ResynchTestServer(int port) {
this.port = port;
}

@Override
public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound,
IncorrectDataFormat, IncorrectTagValue, RejectLogon {
Expand Down Expand Up @@ -107,7 +112,7 @@ public void run() {
try {
HashMap<Object, Object> defaults = new HashMap<>();
defaults.put("ConnectionType", "acceptor");
defaults.put("SocketAcceptPort", "19889");
defaults.put("SocketAcceptPort", String.valueOf(port));
defaults.put("StartTime", "00:00:00");
defaults.put("EndTime", "00:00:00");
defaults.put("SenderCompID", "ISLD");
Expand Down Expand Up @@ -161,11 +166,6 @@ public void waitForInitialization() throws InterruptedException {
initializationLatch.await();
}

public static void main(String[] args) {
ResynchTestServer server = new ResynchTestServer();
server.run();
}

public void setUnsynchMode(boolean unsynchMode) {
this.unsynchMode = unsynchMode;
}
Expand Down