From f71733ec4d1fdaf1998375e095b268ccd58bff91 Mon Sep 17 00:00:00 2001 From: Tim B Date: Thu, 5 Jan 2017 11:29:31 -0600 Subject: [PATCH] Replace com.sun.net.httpserver.Http/Https server usages with MockHttpServer. (elastic/elasticsearch#4476) Original commit: elastic/x-pack-elasticsearch@4b2d184f533e6820f37ebb3b37821903df1e4fd3 --- elasticsearch/build.gradle | 1 + .../test/java/org/elasticsearch/test/http/MockWebServer.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/elasticsearch/build.gradle b/elasticsearch/build.gradle index e5ec5f661bd..1565469d379 100644 --- a/elasticsearch/build.gradle +++ b/elasticsearch/build.gradle @@ -52,6 +52,7 @@ dependencies { // common test deps testCompile 'org.elasticsearch:securemock:1.2' + testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}" testCompile 'org.slf4j:slf4j-log4j12:1.6.2' testCompile 'org.slf4j:slf4j-api:1.6.2' } diff --git a/elasticsearch/src/test/java/org/elasticsearch/test/http/MockWebServer.java b/elasticsearch/src/test/java/org/elasticsearch/test/http/MockWebServer.java index 0246499925f..f6d0b244144 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/test/http/MockWebServer.java +++ b/elasticsearch/src/test/java/org/elasticsearch/test/http/MockWebServer.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; +import org.elasticsearch.mocksocket.MockHttpServer; import javax.net.ssl.SSLContext; import java.io.Closeable; @@ -83,11 +84,11 @@ public class MockWebServer implements Closeable { public void start() throws IOException { InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress().getHostAddress(), 0); if (sslContext != null) { - HttpsServer httpsServer = HttpsServer.create(address, 0); + HttpsServer httpsServer = MockHttpServer.createHttps(address, 0); httpsServer.setHttpsConfigurator(new CustomHttpsConfigurator(sslContext, needClientAuth)); server = httpsServer; } else { - server = HttpServer.create(address, 0); + server = MockHttpServer.createHttp(address, 0); } server.start();