Skip to content
Merged
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
22 changes: 22 additions & 0 deletions quickfixj-core/src/test/java/quickfix/mina/SocksProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import org.apache.mina.util.AvailablePortFinder;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quickfix.Acceptor;
import quickfix.ApplicationAdapter;
import quickfix.ConfigError;
Expand All @@ -28,13 +32,19 @@
*/
public class SocksProxyTest {

private static final Logger LOGGER = LoggerFactory.getLogger(SocksProxyTest.class);

// maximum time to wait for session logon
private static final long TIMEOUT_SECONDS = 5;

@Rule
public TestName testName = new TestName();

private SocksProxyServer proxyServer;

@Before
public void setUp() {
LOGGER.info("Starting test {}", getCurrentTestName());
int proxyPort = AvailablePortFinder.getNextAvailable();

proxyServer = new SocksProxyServer(proxyPort);
Expand All @@ -46,6 +56,8 @@ public void tearDown() {
if (proxyServer != null) {
proxyServer.stop();
}

LOGGER.info("Finished test {}", getCurrentTestName());
}

@Test
Expand Down Expand Up @@ -113,6 +125,16 @@ private boolean isLoggedOn(SessionConnector connector, SessionID sessionID) {
return session.isLoggedOn();
}

private String getCurrentTestName() {
String methodName = testName.getMethodName();

if (methodName == null) {
return getClass().getSimpleName();
}

return getClass().getSimpleName() + "." + methodName;
}

private SessionConnector createAcceptor(int port) throws ConfigError {
MessageStoreFactory messageStoreFactory = new MemoryStoreFactory();
MessageFactory messageFactory = new DefaultMessageFactory();
Expand Down
Loading