Replace com.sun.net.httpserver.Http/Https server usages with MockHttpServer. (elastic/elasticsearch#4476)
Original commit: elastic/x-pack-elasticsearch@4b2d184f53
This commit is contained in:
parent
b72dd8a2d1
commit
f71733ec4d
|
@ -52,6 +52,7 @@ dependencies {
|
||||||
|
|
||||||
// common test deps
|
// common test deps
|
||||||
testCompile 'org.elasticsearch:securemock:1.2'
|
testCompile 'org.elasticsearch:securemock:1.2'
|
||||||
|
testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
|
||||||
testCompile 'org.slf4j:slf4j-log4j12:1.6.2'
|
testCompile 'org.slf4j:slf4j-log4j12:1.6.2'
|
||||||
testCompile 'org.slf4j:slf4j-api:1.6.2'
|
testCompile 'org.slf4j:slf4j-api:1.6.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.elasticsearch.common.io.Streams;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||||
|
import org.elasticsearch.mocksocket.MockHttpServer;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
@ -83,11 +84,11 @@ public class MockWebServer implements Closeable {
|
||||||
public void start() throws IOException {
|
public void start() throws IOException {
|
||||||
InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress().getHostAddress(), 0);
|
InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress().getHostAddress(), 0);
|
||||||
if (sslContext != null) {
|
if (sslContext != null) {
|
||||||
HttpsServer httpsServer = HttpsServer.create(address, 0);
|
HttpsServer httpsServer = MockHttpServer.createHttps(address, 0);
|
||||||
httpsServer.setHttpsConfigurator(new CustomHttpsConfigurator(sslContext, needClientAuth));
|
httpsServer.setHttpsConfigurator(new CustomHttpsConfigurator(sslContext, needClientAuth));
|
||||||
server = httpsServer;
|
server = httpsServer;
|
||||||
} else {
|
} else {
|
||||||
server = HttpServer.create(address, 0);
|
server = MockHttpServer.createHttp(address, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
|
Loading…
Reference in New Issue