Skip to content

Commit

Permalink
tests running in JDK 9
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored and squarejesse committed May 28, 2016
1 parent 639b279 commit 8ceb748
Show file tree
Hide file tree
Showing 31 changed files with 488 additions and 369 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.SSLContext;
import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.tls.SslClient;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
Expand All @@ -42,9 +41,9 @@ class ApacheHttpClient extends SynchronousHttpClient {
super.prepare(benchmark);
ClientConnectionManager connectionManager = new PoolingClientConnectionManager();
if (benchmark.tls) {
SSLContext sslContext = SslContextBuilder.localhost();
SslClient sslClient = SslClient.localhost();
connectionManager.getSchemeRegistry().register(
new Scheme("https", 443, new SSLSocketFactory(sslContext)));
new Scheme("https", 443, new SSLSocketFactory(sslClient.sslContext)));
}
client = new DefaultHttpClient(connectionManager);
}
Expand Down
7 changes: 3 additions & 4 deletions benchmarks/src/main/java/okhttp3/benchmarks/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLContext;
import okhttp3.HttpUrl;
import okhttp3.Protocol;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.tls.SslClient;
import okhttp3.mockwebserver.Dispatcher;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
Expand Down Expand Up @@ -161,8 +160,8 @@ private MockWebServer startServer() throws IOException {
MockWebServer server = new MockWebServer();

if (tls) {
SSLContext sslContext = SslContextBuilder.localhost();
server.useHttps(sslContext.getSocketFactory(), false);
SslClient sslClient = SslClient.localhost();
server.useHttps(sslClient.socketFactory, false);
server.setProtocols(protocols);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.tls.SslClient;

/** Netty isn't an HTTP client, but it's almost one. */
class NettyHttpClient implements HttpClient {
Expand All @@ -69,8 +68,8 @@ class NettyHttpClient implements HttpClient {
ChannelPipeline pipeline = channel.pipeline();

if (benchmark.tls) {
SSLContext sslContext = SslContextBuilder.localhost();
SSLEngine engine = sslContext.createSSLEngine();
SslClient sslClient = SslClient.localhost();
SSLEngine engine = sslClient.sslContext.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
Expand Down
9 changes: 4 additions & 5 deletions benchmarks/src/main/java/okhttp3/benchmarks/OkHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Call;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.ResponseBody;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.tls.SslClient;

class OkHttp extends SynchronousHttpClient {
private static final boolean VERBOSE = false;
Expand All @@ -40,15 +39,15 @@ class OkHttp extends SynchronousHttpClient {
.build();

if (benchmark.tls) {
SSLContext sslContext = SslContextBuilder.localhost();
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
SslClient sslClient = SslClient.localhost();
SSLSocketFactory socketFactory = sslClient.socketFactory;
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override public boolean verify(String s, SSLSession session) {
return true;
}
};
client = new OkHttpClient.Builder()
.sslSocketFactory(socketFactory)
.sslSocketFactory(socketFactory, sslClient.trustManager)
.hostnameVerifier(hostnameVerifier)
.build();
}
Expand Down
9 changes: 4 additions & 5 deletions benchmarks/src/main/java/okhttp3/benchmarks/OkHttpAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Call;
Expand All @@ -32,7 +31,7 @@
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.tls.SslClient;

class OkHttpAsync implements HttpClient {
private static final boolean VERBOSE = false;
Expand All @@ -55,15 +54,15 @@ class OkHttpAsync implements HttpClient {
.build();

if (benchmark.tls) {
SSLContext sslContext = SslContextBuilder.localhost();
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
SslClient sslClient = SslClient.localhost();
SSLSocketFactory socketFactory = sslClient.socketFactory;
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override public boolean verify(String s, SSLSession session) {
return true;
}
};
client = client.newBuilder()
.sslSocketFactory(socketFactory)
.sslSocketFactory(socketFactory, sslClient.trustManager)
.hostnameVerifier(hostnameVerifier)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.tls.SslClient;

class UrlConnection extends SynchronousHttpClient {
private static final boolean VERBOSE = false;

@Override public void prepare(Benchmark benchmark) {
super.prepare(benchmark);
if (benchmark.tls) {
SSLContext sslContext = SslContextBuilder.localhost();
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
SslClient sslClient = SslClient.localhost();
SSLSocketFactory socketFactory = sslClient.socketFactory;
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override public boolean verify(String s, SSLSession session) {
return true;
Expand Down
129 changes: 0 additions & 129 deletions mockwebserver/src/main/java/okhttp3/internal/SslContextBuilder.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Protocol;
import okhttp3.internal.Platform;
import okhttp3.internal.SslContextBuilder;
import okhttp3.internal.Util;
import okhttp3.internal.tls.SslClient;
import okio.BufferedSink;
import okio.Okio;
import okio.Source;
Expand Down Expand Up @@ -184,7 +184,7 @@ public static void main(String... args) throws Exception {
}

FramedServer server = new FramedServer(new File(args[0]),
SslContextBuilder.localhost().getSocketFactory());
SslClient.localhost().sslContext.getSocketFactory());
server.run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3.internal;
package okhttp3.internal.tls;

import java.math.BigInteger;
import java.security.GeneralSecurityException;
Expand Down
Loading

0 comments on commit 8ceb748

Please sign in to comment.