1919
2020package quickfix .mina .ssl ;
2121
22- import junit .framework .TestCase ;
2322import org .apache .mina .core .filterchain .IoFilterAdapter ;
2423import org .apache .mina .core .session .IoSession ;
24+ import org .junit .Before ;
25+ import org .junit .Test ;
2526import org .slf4j .Logger ;
2627import org .slf4j .LoggerFactory ;
2728import quickfix .ApplicationAdapter ;
2829import quickfix .ConfigError ;
2930import quickfix .DefaultMessageFactory ;
3031import quickfix .FixVersions ;
31- import quickfix .Initiator ;
3232import quickfix .MemoryStoreFactory ;
3333import quickfix .Session ;
3434import quickfix .SessionID ;
4343import java .util .concurrent .CountDownLatch ;
4444import java .util .concurrent .TimeUnit ;
4545
46- public class SecureSocketTest extends TestCase {
46+ import static org .junit .Assert .assertNotNull ;
47+ import static org .junit .Assert .assertTrue ;
48+
49+ public class SecureSocketTest {
50+
4751 private final Logger log = LoggerFactory .getLogger (getClass ());
4852 private final int transportProtocol = ProtocolFactory .SOCKET ;
4953
50- protected void setUp () throws Exception {
54+ @ Before
55+ public void setUp () throws Exception {
5156 SystemTime .setTimeSource (null );
5257 }
5358
59+ @ Test
5460 public void testLogonWithBadCertificate () throws Exception {
5561 ServerThread serverThread = new ServerThread ("nonexistent" , "pwd" );
5662 try {
@@ -85,10 +91,12 @@ public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable
8591 }
8692 }
8793
94+ @ Test
8895 public void testLogonWithDefaultCertificate () throws Exception {
8996 doLogonTest (null , null );
9097 }
9198
99+ @ Test
92100 public void testLogonWithCustomCertificate () throws Exception {
93101 doLogonTest ("test.keystore" , "quickfixjtestpw" );
94102 }
@@ -103,6 +111,7 @@ public void testLogonWithCustomCertificate() throws Exception {
103111 * so that it's not cached by another test so that there are no false failures.
104112 * The test-client.keystore key store is just a copy of test.keystore under a different name.
105113 */
114+ @ Test
106115 public void testLogonWithBadCertificateOnInitiatorSide () throws Exception {
107116 SessionID clientSessionID = new SessionID (FixVersions .BEGINSTRING_FIX42 , "TW" , "ISLD" );
108117 SessionSettings settings = getClientSessionSettings (clientSessionID );
@@ -177,14 +186,8 @@ private void assertLoggedOn(ClientApplication clientApplication, Session clientS
177186 }
178187
179188 private class ClientApplication extends ApplicationAdapter {
180- public CountDownLatch logonLatch ;
181- private Initiator initiator ;
182- private boolean stopAfterLogon ;
183189
184- //public void stopAfterLogon(Initiator initiator) {
185- // this.initiator = initiator;
186- // this.stopAfterLogon = true;
187- //}
190+ public CountDownLatch logonLatch ;
188191
189192 public void setUpLogonExpectation () {
190193 logonLatch = new CountDownLatch (1 );
@@ -195,14 +198,11 @@ public void onLogon(SessionID sessionId) {
195198 log .info ("Releasing logon latch" );
196199 logonLatch .countDown ();
197200 }
198- if (stopAfterLogon ) {
199- log .info ("Stopping after logon" );
200- initiator .stop ();
201- }
202201 }
203202 }
204203
205204 private class ServerThread extends Thread {
205+
206206 private final ATServer server ;
207207
208208 public ServerThread (String keyStoreName , String keyStorePassword ) {
@@ -223,5 +223,4 @@ public void waitForInitialization() throws InterruptedException {
223223 server .waitForInitialization ();
224224 }
225225 }
226-
227226}
0 commit comments