bump engine.io-client

This commit is contained in:
nkzawa
2017-07-11 21:54:48 +09:00
parent 8f8c138a61
commit 9d6947a015
5 changed files with 48 additions and 26 deletions

View File

@@ -17,7 +17,7 @@ public class ExecutionTest extends Connection {
private static final Logger logger = Logger.getLogger(ExecutionTest.class.getName());
final static int TIMEOUT = 60 * 1000;
final static int TIMEOUT = 100 * 1000;
@Test(timeout = TIMEOUT)
public void execConnection() throws InterruptedException, IOException {

View File

@@ -1,6 +1,7 @@
package io.socket.client;
import io.socket.emitter.Emitter;
import okhttp3.OkHttpClient;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -9,7 +10,9 @@ import org.junit.runners.JUnit4;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -21,15 +24,20 @@ import java.util.concurrent.LinkedBlockingQueue;
@RunWith(JUnit4.class)
public class SSLConnectionTest extends Connection {
// for test on localhost
static HostnameVerifier hostnameVerifier = new javax.net.ssl.HostnameVerifier(){
public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
return hostname.equals("localhost");
}
};
private static OkHttpClient sOkHttpClient;
private Socket socket;
static {
try {
prepareOkHttpClient();
} catch(GeneralSecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
String uri() {
return "https://localhost:" + PORT;
@@ -47,7 +55,7 @@ public class SSLConnectionTest extends Connection {
return new String[] {"DEBUG=socket.io:*", "PORT=" + PORT, "SSL=1"};
}
SSLContext createSSLContext() throws GeneralSecurityException, IOException {
private static void prepareOkHttpClient() throws GeneralSecurityException, IOException {
KeyStore ks = KeyStore.getInstance("JKS");
File file = new File("src/test/resources/keystore.jks");
ks.load(new FileInputStream(file), "password".toCharArray());
@@ -60,21 +68,30 @@ public class SSLConnectionTest extends Connection {
SSLContext sslContext = SSLContext.getInstance("TLSv1");
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
return sslContext;
sOkHttpClient = new OkHttpClient.Builder()
.hostnameVerifier(new HostnameVerifier(){
public boolean verify(String hostname, SSLSession sslSession) {
return hostname.equals("localhost");
}
})
.sslSocketFactory(sslContext.getSocketFactory(),
(X509TrustManager) tmf.getTrustManagers()[0])
.build();
}
@After
public void tearDown() {
IO.setDefaultSSLContext(null);
IO.setDefaultHostnameVerifier(null);
IO.setDefaultOkHttpCallFactory(null);
IO.setDefaultOkHttpWebSocketFactory(null);
}
@Test(timeout = TIMEOUT)
public void connect() throws Exception {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options opts = createOptions();
opts.sslContext = createSSLContext();
opts.hostnameVerifier = hostnameVerifier;
opts.callFactory = sOkHttpClient;
opts.webSocketFactory = sOkHttpClient;
socket = client(opts);
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
@@ -96,8 +113,8 @@ public class SSLConnectionTest extends Connection {
@Test(timeout = TIMEOUT)
public void defaultSSLContext() throws Exception {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.setDefaultSSLContext(createSSLContext());
IO.setDefaultHostnameVerifier(hostnameVerifier);
IO.setDefaultOkHttpWebSocketFactory(sOkHttpClient);
IO.setDefaultOkHttpCallFactory(sOkHttpClient);
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override