19
19
20
20
package quickfix .mina .ssl ;
21
21
22
- import junit .framework .TestCase ;
23
22
import org .apache .mina .core .filterchain .IoFilterAdapter ;
24
23
import org .apache .mina .core .session .IoSession ;
24
+ import org .junit .Before ;
25
+ import org .junit .Test ;
25
26
import org .slf4j .Logger ;
26
27
import org .slf4j .LoggerFactory ;
27
28
import quickfix .ApplicationAdapter ;
28
29
import quickfix .ConfigError ;
29
30
import quickfix .DefaultMessageFactory ;
30
31
import quickfix .FixVersions ;
31
- import quickfix .Initiator ;
32
32
import quickfix .MemoryStoreFactory ;
33
33
import quickfix .Session ;
34
34
import quickfix .SessionID ;
43
43
import java .util .concurrent .CountDownLatch ;
44
44
import java .util .concurrent .TimeUnit ;
45
45
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
+
47
51
private final Logger log = LoggerFactory .getLogger (getClass ());
48
52
private final int transportProtocol = ProtocolFactory .SOCKET ;
49
53
50
- protected void setUp () throws Exception {
54
+ @ Before
55
+ public void setUp () throws Exception {
51
56
SystemTime .setTimeSource (null );
52
57
}
53
58
59
+ @ Test
54
60
public void testLogonWithBadCertificate () throws Exception {
55
61
ServerThread serverThread = new ServerThread ("nonexistent" , "pwd" );
56
62
try {
@@ -85,10 +91,12 @@ public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable
85
91
}
86
92
}
87
93
94
+ @ Test
88
95
public void testLogonWithDefaultCertificate () throws Exception {
89
96
doLogonTest (null , null );
90
97
}
91
98
99
+ @ Test
92
100
public void testLogonWithCustomCertificate () throws Exception {
93
101
doLogonTest ("test.keystore" , "quickfixjtestpw" );
94
102
}
@@ -103,6 +111,7 @@ public void testLogonWithCustomCertificate() throws Exception {
103
111
* so that it's not cached by another test so that there are no false failures.
104
112
* The test-client.keystore key store is just a copy of test.keystore under a different name.
105
113
*/
114
+ @ Test
106
115
public void testLogonWithBadCertificateOnInitiatorSide () throws Exception {
107
116
SessionID clientSessionID = new SessionID (FixVersions .BEGINSTRING_FIX42 , "TW" , "ISLD" );
108
117
SessionSettings settings = getClientSessionSettings (clientSessionID );
@@ -177,14 +186,8 @@ private void assertLoggedOn(ClientApplication clientApplication, Session clientS
177
186
}
178
187
179
188
private class ClientApplication extends ApplicationAdapter {
180
- public CountDownLatch logonLatch ;
181
- private Initiator initiator ;
182
- private boolean stopAfterLogon ;
183
189
184
- //public void stopAfterLogon(Initiator initiator) {
185
- // this.initiator = initiator;
186
- // this.stopAfterLogon = true;
187
- //}
190
+ public CountDownLatch logonLatch ;
188
191
189
192
public void setUpLogonExpectation () {
190
193
logonLatch = new CountDownLatch (1 );
@@ -195,14 +198,11 @@ public void onLogon(SessionID sessionId) {
195
198
log .info ("Releasing logon latch" );
196
199
logonLatch .countDown ();
197
200
}
198
- if (stopAfterLogon ) {
199
- log .info ("Stopping after logon" );
200
- initiator .stop ();
201
- }
202
201
}
203
202
}
204
203
205
204
private class ServerThread extends Thread {
205
+
206
206
private final ATServer server ;
207
207
208
208
public ServerThread (String keyStoreName , String keyStorePassword ) {
@@ -223,5 +223,4 @@ public void waitForInitialization() throws InterruptedException {
223
223
server .waitForInitialization ();
224
224
}
225
225
}
226
-
227
226
}
0 commit comments