diff --git a/buildSrc/version.properties b/buildSrc/version.properties index a7f46a545cf..51b92558916 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -38,6 +38,8 @@ commonscodec = 1.13 hamcrest = 2.1 securemock = 1.2 mocksocket = 1.2 +mockito = 1.9.5 +objenesis = 1.0 # benchmark dependencies jmh = 1.19 diff --git a/client/rest/build.gradle b/client/rest/build.gradle index 0d995bc05e3..e296ccf9d9f 100644 --- a/client/rest/build.gradle +++ b/client/rest/build.gradle @@ -51,8 +51,8 @@ dependencies { testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testImplementation "junit:junit:${versions.junit}" testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}" - testImplementation "org.elasticsearch:securemock:${versions.securemock}" - testImplementation "org.elasticsearch:mocksocket:${versions.mocksocket}" + testImplementation "org.mockito:mockito-core:${versions.mockito}" + testImplementation "org.objenesis:objenesis:${versions.objenesis}" } tasks.withType(CheckForbiddenApis).configureEach { diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientBuilderIntegTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientBuilderIntegTests.java index c95db3d922d..421536be795 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientBuilderIntegTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientBuilderIntegTests.java @@ -37,7 +37,6 @@ import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpsConfigurator; import com.sun.net.httpserver.HttpsServer; import org.apache.http.HttpHost; -import org.elasticsearch.mocksocket.MockHttpServer; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -73,7 +72,7 @@ public class RestClientBuilderIntegTests extends RestClientTestCase { @BeforeClass public static void startHttpServer() throws Exception { - httpsServer = MockHttpServer.createHttps(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + httpsServer = HttpsServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); httpsServer.setHttpsConfigurator(new HttpsConfigurator(getSslContext())); httpsServer.createContext("/", new ResponseHandler()); httpsServer.start(); diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientGzipCompressionTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientGzipCompressionTests.java index 85b21933e83..8c4d993517f 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientGzipCompressionTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientGzipCompressionTests.java @@ -39,7 +39,6 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; -import org.elasticsearch.mocksocket.MockHttpServer; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -61,7 +60,7 @@ public class RestClientGzipCompressionTests extends RestClientTestCase { @BeforeClass public static void startHttpServer() throws Exception { - httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + httpServer = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); httpServer.createContext("/", new GzipResponseHandler()); httpServer.start(); } diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientMultipleHostsIntegTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientMultipleHostsIntegTests.java index c747e08f931..cfacadb1650 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientMultipleHostsIntegTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientMultipleHostsIntegTests.java @@ -36,7 +36,6 @@ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import org.apache.http.HttpHost; -import org.elasticsearch.mocksocket.MockHttpServer; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -107,7 +106,7 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase { } private static HttpServer createHttpServer() throws Exception { - HttpServer httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + HttpServer httpServer = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); httpServer.start(); //returns a different status code depending on the path for (int statusCode : getAllStatusCodes()) { diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java index c3f1391454e..b412130be77 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java @@ -52,7 +52,6 @@ import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.apache.http.message.BasicHeader; import org.apache.http.nio.entity.NStringEntity; import org.apache.http.util.EntityUtils; -import org.elasticsearch.mocksocket.MockHttpServer; import org.junit.After; import org.junit.Before; @@ -107,7 +106,7 @@ public class RestClientSingleHostIntegTests extends RestClientTestCase { } private HttpServer createHttpServer() throws Exception { - HttpServer httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + HttpServer httpServer = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); httpServer.start(); //returns a different status code depending on the path for (int statusCode : getAllStatusCodes()) { diff --git a/client/sniffer/build.gradle b/client/sniffer/build.gradle index 220835d0097..057446c9818 100644 --- a/client/sniffer/build.gradle +++ b/client/sniffer/build.gradle @@ -47,8 +47,8 @@ dependencies { testImplementation project(":client:test") testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testImplementation "junit:junit:${versions.junit}" - testImplementation "org.elasticsearch:securemock:${versions.securemock}" - testImplementation "org.elasticsearch:mocksocket:${versions.mocksocket}" + testImplementation "org.mockito:mockito-core:${versions.mockito}" + testImplementation "org.objenesis:objenesis:${versions.objenesis}" } tasks.named('forbiddenApisMain').configure { diff --git a/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java b/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java index 97fd3d852ed..38ef722d5c3 100644 --- a/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java +++ b/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java @@ -48,7 +48,6 @@ import org.opensearch.client.Response; import org.opensearch.client.ResponseException; import org.opensearch.client.RestClient; import org.opensearch.client.RestClientTestCase; -import org.elasticsearch.mocksocket.MockHttpServer; import org.junit.After; import org.junit.Before; @@ -153,7 +152,7 @@ public class OpenSearchNodesSnifferTests extends RestClientTestCase { } private static HttpServer createHttpServer(final SniffResponse sniffResponse, final int sniffTimeoutMillis) throws IOException { - HttpServer httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + HttpServer httpServer = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); httpServer.createContext("/_nodes/http", new ResponseHandler(sniffTimeoutMillis, sniffResponse)); return httpServer; }