@@ -75,8 +75,8 @@ public void cleanup() {
7575
7676 @ Test
7777 public void testRestartOfAcceptor () throws Exception {
78- TestAcceptorApplication testAcceptorApplication = new TestAcceptorApplication ();
79- TestInitiatorApplication testInitiatorApplication = new TestInitiatorApplication ();
78+ TestConnectorApplication testAcceptorApplication = new TestConnectorApplication ();
79+ TestConnectorApplication testInitiatorApplication = new TestConnectorApplication ();
8080 ThreadMXBean bean = ManagementFactory .getThreadMXBean ();
8181 Acceptor acceptor = null ;
8282 Initiator initiator = null ;
@@ -109,14 +109,14 @@ public void testRestartOfAcceptor() throws Exception {
109109 log .error (e .getMessage (), e );
110110 }
111111 }
112+ testAcceptorApplication .waitForLogout ();
112113 if (acceptor != null ) {
113114 try {
114115 acceptor .stop ();
115116 } catch (RuntimeException e ) {
116117 log .error (e .getMessage (), e );
117118 }
118119 }
119- testAcceptorApplication .waitForLogout ();
120120 testInitiatorApplication .waitForLogout ();
121121 }
122122 }
@@ -127,7 +127,7 @@ public void testQuickRestartOfAcceptor() throws Exception {
127127 Acceptor acceptor = null ;
128128 try {
129129 ThreadMXBean bean = ManagementFactory .getThreadMXBean ();
130- TestAcceptorApplication testAcceptorApplication = new TestAcceptorApplication ();
130+ TestConnectorApplication testAcceptorApplication = new TestConnectorApplication ();
131131 acceptor = createAcceptor (testAcceptorApplication );
132132 acceptor .start ();
133133 Thread .sleep (2500L );
@@ -148,7 +148,7 @@ public void testDoubleStartOfAcceptor() throws Exception {
148148 Acceptor acceptor = null ;
149149 try {
150150 ThreadMXBean bean = ManagementFactory .getThreadMXBean ();
151- TestAcceptorApplication testAcceptorApplication = new TestAcceptorApplication ();
151+ TestConnectorApplication testAcceptorApplication = new TestConnectorApplication ();
152152 acceptor = createAcceptor (testAcceptorApplication );
153153 acceptor .start ();
154154 // second start should be ignored
@@ -166,7 +166,7 @@ public void testDoubleStartOfAcceptor() throws Exception {
166166 public void testSessionsAreCleanedUp () throws Exception {
167167 Acceptor acceptor = null ;
168168 try {
169- TestAcceptorApplication testAcceptorApplication = new TestAcceptorApplication ();
169+ TestConnectorApplication testAcceptorApplication = new TestConnectorApplication ();
170170 acceptor = createAcceptor (testAcceptorApplication );
171171 acceptor .start ();
172172 assertEquals (1 , acceptor .getSessions ().size () );
@@ -185,7 +185,7 @@ public void testSessionsAreCleanedUp() throws Exception {
185185 public void testSessionsAreCleanedUpOnThreadedSocketAcceptor () throws Exception {
186186 Acceptor acceptor = null ;
187187 try {
188- TestAcceptorApplication testAcceptorApplication = new TestAcceptorApplication ();
188+ TestConnectorApplication testAcceptorApplication = new TestConnectorApplication ();
189189 acceptor = createAcceptorThreaded (testAcceptorApplication );
190190 acceptor .start ();
191191 assertEquals (1 , acceptor .getSessions ().size () );
@@ -292,12 +292,12 @@ private Session lookupSession(SessionID sessionID) {
292292 return Session .lookupSession (sessionID );
293293 }
294294
295- private static class TestAcceptorApplication extends ApplicationAdapter {
295+ private class TestConnectorApplication extends ApplicationAdapter {
296296
297297 private final CountDownLatch logonLatch ;
298298 private final CountDownLatch logoutLatch ;
299299
300- public TestAcceptorApplication () {
300+ public TestConnectorApplication () {
301301 logonLatch = new CountDownLatch (1 );
302302 logoutLatch = new CountDownLatch (1 );
303303 }
@@ -334,53 +334,15 @@ public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound
334334 // ignore
335335 }
336336 }
337- }
338-
339- private static class TestInitiatorApplication extends ApplicationAdapter {
340-
341- private final CountDownLatch logonLatch ;
342- private final CountDownLatch logoutLatch ;
343-
344- public TestInitiatorApplication () {
345- logonLatch = new CountDownLatch (1 );
346- logoutLatch = new CountDownLatch (1 );
347- }
348-
349- @ Override
350- public void onLogon (SessionID sessionId ) {
351- super .onLogon (sessionId );
352- logonLatch .countDown ();
353- }
354-
355- public void waitForLogon () {
356- try {
357- assertTrue ("Logon timed out" , logonLatch .await (10 , TimeUnit .SECONDS ));
358- } catch (InterruptedException e ) {
359- fail (e .getMessage ());
360- }
361- }
362-
363- public void waitForLogout () {
364- try {
365- assertTrue ("Logout timed out" , logoutLatch .await (10 , TimeUnit .SECONDS ));
366- } catch (InterruptedException e ) {
367- fail (e .getMessage ());
368- }
369- }
370337
371338 @ Override
372- public void fromAdmin (Message message , SessionID sessionId ) throws FieldNotFound , IncorrectDataFormat , IncorrectTagValue , RejectLogon {
373- try {
374- if (MsgType .LOGOUT .equals (MessageUtils .getMessageType (message .toString ()))) {
375- logoutLatch .countDown ();
376- }
377- } catch (InvalidMessage ex ) {
378- // ignore
379- }
339+ public void toAdmin (Message message , SessionID sessionId ) {
340+ log .info ("toAdmin: [{}] {}" , sessionId , message );
380341 }
381342 }
382343
383- private Acceptor createAcceptor (TestAcceptorApplication testAcceptorApplication )
344+
345+ private Acceptor createAcceptor (TestConnectorApplication testAcceptorApplication )
384346 throws ConfigError {
385347
386348 SessionSettings settings = createAcceptorSettings ();
@@ -391,7 +353,7 @@ private Acceptor createAcceptor(TestAcceptorApplication testAcceptorApplication)
391353 new DefaultMessageFactory ());
392354 }
393355
394- private Acceptor createAcceptorThreaded (TestAcceptorApplication testAcceptorApplication )
356+ private Acceptor createAcceptorThreaded (TestConnectorApplication testAcceptorApplication )
395357 throws ConfigError {
396358
397359 SessionSettings settings = createAcceptorSettings ();
@@ -409,13 +371,14 @@ private SessionSettings createAcceptorSettings() {
409371 defaults .put ("StartTime" , "00:00:00" );
410372 defaults .put ("EndTime" , "00:00:00" );
411373 defaults .put ("BeginString" , "FIX.4.2" );
374+ defaults .put ("NonStopSession" , "Y" );
412375 settings .setString (acceptorSessionID , "SocketAcceptProtocol" , ProtocolFactory .getTypeString (ProtocolFactory .VM_PIPE ));
413376 settings .setString (acceptorSessionID , "SocketAcceptPort" , "10000" );
414377 settings .set (defaults );
415378 return settings ;
416379 }
417380
418- private Initiator createInitiator (TestInitiatorApplication testInitiatorApplication ) throws ConfigError {
381+ private Initiator createInitiator (TestConnectorApplication testInitiatorApplication ) throws ConfigError {
419382 SessionSettings settings = new SessionSettings ();
420383 HashMap <Object , Object > defaults = new HashMap <>();
421384 defaults .put ("ConnectionType" , "initiator" );
@@ -425,6 +388,7 @@ private Initiator createInitiator(TestInitiatorApplication testInitiatorApplicat
425388 defaults .put ("ReconnectInterval" , "2" );
426389 defaults .put ("FileStorePath" , "target/data/client" );
427390 defaults .put ("ValidateUserDefinedFields" , "Y" );
391+ defaults .put ("NonStopSession" , "Y" );
428392 settings .setString ("BeginString" , FixVersions .BEGINSTRING_FIX42 );
429393 settings .setString (initiatorSessionID , "SocketConnectProtocol" , ProtocolFactory .getTypeString (ProtocolFactory .VM_PIPE ));
430394 settings .setString (initiatorSessionID , "SocketConnectHost" , "127.0.0.1" );
0 commit comments