33import org .apache .mina .util .AvailablePortFinder ;
44import org .junit .After ;
55import org .junit .Before ;
6+ import org .junit .Rule ;
67import org .junit .Test ;
8+ import org .junit .rules .TestName ;
9+ import org .slf4j .Logger ;
10+ import org .slf4j .LoggerFactory ;
711import quickfix .Acceptor ;
812import quickfix .ApplicationAdapter ;
913import quickfix .ConfigError ;
2832 */
2933public class SocksProxyTest {
3034
35+ private static final Logger LOGGER = LoggerFactory .getLogger (SocksProxyTest .class );
36+
3137 // maximum time to wait for session logon
3238 private static final long TIMEOUT_SECONDS = 5 ;
3339
40+ @ Rule
41+ public TestName testName = new TestName ();
42+
3443 private SocksProxyServer proxyServer ;
3544
3645 @ Before
3746 public void setUp () {
47+ LOGGER .info ("Starting test {}" , getCurrentTestName ());
3848 int proxyPort = AvailablePortFinder .getNextAvailable ();
3949
4050 proxyServer = new SocksProxyServer (proxyPort );
@@ -46,6 +56,8 @@ public void tearDown() {
4656 if (proxyServer != null ) {
4757 proxyServer .stop ();
4858 }
59+
60+ LOGGER .info ("Finished test {}" , getCurrentTestName ());
4961 }
5062
5163 @ Test
@@ -113,6 +125,16 @@ private boolean isLoggedOn(SessionConnector connector, SessionID sessionID) {
113125 return session .isLoggedOn ();
114126 }
115127
128+ private String getCurrentTestName () {
129+ String methodName = testName .getMethodName ();
130+
131+ if (methodName == null ) {
132+ return getClass ().getSimpleName ();
133+ }
134+
135+ return getClass ().getSimpleName () + "." + methodName ;
136+ }
137+
116138 private SessionConnector createAcceptor (int port ) throws ConfigError {
117139 MessageStoreFactory messageStoreFactory = new MemoryStoreFactory ();
118140 MessageFactory messageFactory = new DefaultMessageFactory ();
0 commit comments