add setDefaultSSLContext #3
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.github.nkzawa.engineio.client;
|
||||
|
||||
import com.github.nkzawa.emitter.Emitter;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
@@ -33,6 +34,11 @@ public class SSLConnectionTest extends Connection {
|
||||
|
||||
private Socket socket;
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Socket.setDefaultSSLContext(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
Socket.Options createOptions() {
|
||||
Socket.Options opts = super.createOptions();
|
||||
@@ -74,17 +80,12 @@ public class SSLConnectionTest extends Connection {
|
||||
socket.on(Socket.EVENT_MESSAGE, new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
assertThat((String)args[0], is("hi"));
|
||||
assertThat((String) args[0], is("hi"));
|
||||
socket.close();
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).on("error", new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
((Exception)args[0]).printStackTrace();
|
||||
}
|
||||
});
|
||||
socket.open();
|
||||
latch.await();
|
||||
@@ -119,4 +120,27 @@ public class SSLConnectionTest extends Connection {
|
||||
socket.open();
|
||||
latch.await();
|
||||
}
|
||||
|
||||
@Test(timeout = TIMEOUT)
|
||||
public void defaultSSLContext() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
Socket.setDefaultSSLContext(createSSLContext());
|
||||
socket = new Socket(createOptions());
|
||||
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
socket.on(Socket.EVENT_MESSAGE, new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
assertThat((String) args[0], is("hi"));
|
||||
socket.close();
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.open();
|
||||
latch.await();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user