diff --git a/httpclient-okhttp/src/test/java/io/fabric8/kubernetes/client/okhttp/ConnectionPoolLeakageTest.java b/httpclient-okhttp/src/test/java/io/fabric8/kubernetes/client/okhttp/ConnectionPoolLeakageTest.java index 676aed37923..c4117f4e554 100644 --- a/httpclient-okhttp/src/test/java/io/fabric8/kubernetes/client/okhttp/ConnectionPoolLeakageTest.java +++ b/httpclient-okhttp/src/test/java/io/fabric8/kubernetes/client/okhttp/ConnectionPoolLeakageTest.java @@ -18,10 +18,10 @@ import io.fabric8.kubernetes.client.http.AsyncBody; import io.fabric8.kubernetes.client.http.HttpClient; import io.fabric8.kubernetes.client.http.HttpResponse; +import io.fabric8.mockwebserver.MockWebServer; +import io.fabric8.mockwebserver.http.MockResponse; import okhttp3.ConnectionPool; import okhttp3.Protocol; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -53,7 +53,7 @@ void setUp() { } @AfterEach - void tearDown() throws Exception { + void tearDown() { server.shutdown(); connectionPool.evictAll(); } @@ -63,7 +63,7 @@ void tearDown() throws Exception { @ValueSource(strings = { "h2_prior_knowledge", "http/1.1" }) void consumeBytes(String protocol) throws Exception { final Protocol p = Protocol.get(protocol); - server.setProtocols(Collections.singletonList(p)); + server.setProtocols(Collections.singletonList(io.fabric8.mockwebserver.vertx.Protocol.get(p.toString()))); server.start(); clientBuilder.getBuilder().protocols(Collections.singletonList(p)); try (HttpClient httpClient = clientBuilder.build()) { diff --git a/junit/kubernetes-server-mock/pom.xml b/junit/kubernetes-server-mock/pom.xml index 7664f239a70..6a3a3176401 100644 --- a/junit/kubernetes-server-mock/pom.xml +++ b/junit/kubernetes-server-mock/pom.xml @@ -41,6 +41,16 @@ io.fabric8 mockwebserver + + org.junit.jupiter + junit-jupiter-api + provided + + + junit + junit + provided + org.junit.jupiter @@ -54,11 +64,6 @@ ${slf4j.version} test - - org.junit.jupiter - junit-jupiter-api - provided - org.junit.jupiter junit-jupiter-params diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java index 3eeb0be96e2..3bbaab28ccf 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java @@ -24,7 +24,7 @@ import io.fabric8.mockwebserver.crud.Attribute; import io.fabric8.mockwebserver.crud.AttributeExtractor; import io.fabric8.mockwebserver.crud.AttributeSet; -import okhttp3.HttpUrl; +import io.fabric8.mockwebserver.http.HttpUrl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java index ce71d854a27..52b977543aa 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java @@ -30,9 +30,8 @@ import io.fabric8.mockwebserver.crud.Attribute; import io.fabric8.mockwebserver.crud.AttributeSet; import io.fabric8.mockwebserver.crud.CrudDispatcher; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okhttp3.mockwebserver.SocketPolicy; +import io.fabric8.mockwebserver.http.MockResponse; +import io.fabric8.mockwebserver.http.RecordedRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -292,7 +291,6 @@ public MockResponse handleWatch(String path) { .filter(entry -> watch.attributeMatches(entry.getKey())) .forEach(entry -> watch.sendWebSocketResponse(entry.getValue(), Action.ADDED)))); watchEventListeners.add(watchEventListener); - mockResponse.setSocketPolicy(SocketPolicy.KEEP_OPEN); return mockResponse.withWebSocketUpgrade(watchEventListener); } diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcher.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcher.java index 6127fc676b2..41e75fd488d 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcher.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcher.java @@ -19,11 +19,11 @@ import io.fabric8.mockwebserver.ServerRequest; import io.fabric8.mockwebserver.ServerResponse; import io.fabric8.mockwebserver.dsl.HttpMethod; +import io.fabric8.mockwebserver.http.Dispatcher; +import io.fabric8.mockwebserver.http.MockResponse; +import io.fabric8.mockwebserver.http.RecordedRequest; import io.fabric8.mockwebserver.internal.MockDispatcher; import io.fabric8.mockwebserver.internal.SimpleRequest; -import okhttp3.mockwebserver.Dispatcher; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; import java.util.Collections; import java.util.List; @@ -58,7 +58,7 @@ public KubernetesMixedDispatcher( } @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { final Queue responseQueue = responses.get( new SimpleRequest(HttpMethod.valueOf(request.getMethod()), request.getPath())); if (responseQueue != null && !responseQueue.isEmpty()) { diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServer.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServer.java index ad87ce4f75a..94536b23819 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServer.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServer.java @@ -35,13 +35,13 @@ import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.mockwebserver.Context; import io.fabric8.mockwebserver.DefaultMockServer; +import io.fabric8.mockwebserver.MockWebServer; import io.fabric8.mockwebserver.ServerRequest; import io.fabric8.mockwebserver.ServerResponse; +import io.fabric8.mockwebserver.http.Dispatcher; import io.fabric8.mockwebserver.internal.MockDispatcher; import io.fabric8.servicecatalog.client.DefaultServiceCatalogClient; import io.fabric8.servicecatalog.client.NamespacedServiceCatalogClient; -import okhttp3.mockwebserver.Dispatcher; -import okhttp3.mockwebserver.MockWebServer; import java.net.HttpURLConnection; import java.net.InetAddress; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServerExtension.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServerExtension.java index 197737e9243..408bafd9377 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServerExtension.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesMockServerExtension.java @@ -21,11 +21,11 @@ import io.fabric8.kubernetes.client.NamespacedKubernetesClient; import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.mockwebserver.Context; +import io.fabric8.mockwebserver.MockWebServer; import io.fabric8.mockwebserver.ServerRequest; import io.fabric8.mockwebserver.ServerResponse; +import io.fabric8.mockwebserver.http.Dispatcher; import io.fabric8.mockwebserver.internal.MockDispatcher; -import okhttp3.mockwebserver.Dispatcher; -import okhttp3.mockwebserver.MockWebServer; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesServer.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesServer.java index 5f8c55487b7..f5ba7b55c73 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesServer.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesServer.java @@ -18,11 +18,11 @@ import io.fabric8.kubernetes.client.NamespacedKubernetesClient; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.mockwebserver.Context; +import io.fabric8.mockwebserver.MockWebServer; import io.fabric8.mockwebserver.ServerRequest; import io.fabric8.mockwebserver.ServerResponse; import io.fabric8.mockwebserver.dsl.MockServerExpectation; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; +import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.rules.ExternalResource; import java.net.InetAddress; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/WatchEventsListener.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/WatchEventsListener.java index 354f7f98c1f..f1ea9253097 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/WatchEventsListener.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/WatchEventsListener.java @@ -22,10 +22,10 @@ import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.mockwebserver.Context; import io.fabric8.mockwebserver.crud.AttributeSet; +import io.fabric8.mockwebserver.http.Response; +import io.fabric8.mockwebserver.http.WebSocket; +import io.fabric8.mockwebserver.http.WebSocketListener; import io.fabric8.mockwebserver.internal.WebSocketMessage; -import okhttp3.Response; -import okhttp3.WebSocket; -import okhttp3.WebSocketListener; import org.slf4j.Logger; import java.util.Set; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherHandler.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherHandler.java index 6cc79611aa1..1121ace7ec5 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherHandler.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherHandler.java @@ -21,8 +21,8 @@ import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.kubernetes.client.utils.Utils; import io.fabric8.mockwebserver.crud.AttributeSet; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; +import io.fabric8.mockwebserver.http.MockResponse; +import io.fabric8.mockwebserver.http.RecordedRequest; import java.net.HttpURLConnection; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PatchHandler.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PatchHandler.java index 60ab3eda4c7..7e5ffc946c5 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PatchHandler.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PatchHandler.java @@ -22,9 +22,9 @@ import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.kubernetes.client.utils.Utils; import io.fabric8.mockwebserver.crud.AttributeSet; +import io.fabric8.mockwebserver.http.MediaType; +import io.fabric8.mockwebserver.http.MockResponse; import io.fabric8.zjsonpatch.JsonPatch; -import okhttp3.MediaType; -import okhttp3.mockwebserver.MockResponse; import java.net.HttpURLConnection; import java.util.Iterator; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PostHandler.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PostHandler.java index f8831598f52..189c1c31765 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PostHandler.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PostHandler.java @@ -23,7 +23,7 @@ import io.fabric8.kubernetes.client.utils.Utils; import io.fabric8.mockwebserver.crud.Attribute; import io.fabric8.mockwebserver.crud.AttributeSet; -import okhttp3.mockwebserver.MockResponse; +import io.fabric8.mockwebserver.http.MockResponse; import java.net.HttpURLConnection; import java.time.ZoneOffset; diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PutHandler.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PutHandler.java index 36b18a32c66..bf86a53c9ce 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PutHandler.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/crud/PutHandler.java @@ -19,7 +19,7 @@ import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.mockwebserver.crud.AttributeSet; -import okhttp3.mockwebserver.MockResponse; +import io.fabric8.mockwebserver.http.MockResponse; import java.net.HttpURLConnection; import java.util.Map; diff --git a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcherTest.java b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcherTest.java index bf578a4dff9..e65673261f9 100644 --- a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcherTest.java +++ b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesMixedDispatcherTest.java @@ -20,12 +20,12 @@ import io.fabric8.mockwebserver.ServerRequest; import io.fabric8.mockwebserver.ServerResponse; import io.fabric8.mockwebserver.dsl.HttpMethod; +import io.fabric8.mockwebserver.http.Buffer; +import io.fabric8.mockwebserver.http.Headers; +import io.fabric8.mockwebserver.http.MockResponse; +import io.fabric8.mockwebserver.http.RecordedRequest; import io.fabric8.mockwebserver.internal.SimpleRequest; import io.fabric8.mockwebserver.internal.SimpleResponse; -import okhttp3.Headers; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -59,7 +59,7 @@ void setUp() { @Test @DisplayName("dispatch, with matching expectation, returns expectation") - void dispatchWithMatchingExpectation() throws Exception { + void dispatchWithMatchingExpectation() { // Given responses.compute(new SimpleRequest(HttpMethod.GET, "/api/v1/resources/my-resource"), (k, v) -> new ArrayDeque<>()) .add(new SimpleResponse(true, 200, "resourceBody", null)); @@ -76,7 +76,7 @@ void dispatchWithMatchingExpectation() throws Exception { @Test @DisplayName("dispatch, with existing CRUD resource, returns CRUD resource") - void dispatchWithCrudExistentResource() throws Exception { + void dispatchWithCrudExistentResource() { // Given final Buffer requestBody = new Buffer(); requestBody.writeString("{\"kind\": \"Resource\", \"apiVersion\": \"v1\",\"metadata\": {\"name\": \"my-resource\"}}", diff --git a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherTestBase.java b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherTestBase.java index ca90eba69fc..6aa679a8e20 100644 --- a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherTestBase.java +++ b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherTestBase.java @@ -19,7 +19,7 @@ import io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; import io.fabric8.mockwebserver.Context; -import okhttp3.mockwebserver.MockWebServer; +import io.fabric8.mockwebserver.MockWebServer; import org.assertj.core.api.Condition; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientProxyTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientProxyTest.java index 505e6490cc7..36932ad7535 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientProxyTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientProxyTest.java @@ -16,7 +16,7 @@ package io.fabric8.kubernetes.client.http; import io.fabric8.mockwebserver.DefaultMockServer; -import okhttp3.mockwebserver.RecordedRequest; +import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpLoggingInterceptorTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpLoggingInterceptorTest.java index 0e3a86f62b0..f4646c42d00 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpLoggingInterceptorTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpLoggingInterceptorTest.java @@ -17,14 +17,14 @@ import io.fabric8.mockwebserver.Context; import io.fabric8.mockwebserver.DefaultMockServer; +import io.fabric8.mockwebserver.MockWebServer; import io.fabric8.mockwebserver.ServerRequest; import io.fabric8.mockwebserver.ServerResponse; +import io.fabric8.mockwebserver.http.Buffer; +import io.fabric8.mockwebserver.http.MockResponse; +import io.fabric8.mockwebserver.http.RecordedRequest; import io.fabric8.mockwebserver.internal.SimpleRequest; import io.fabric8.mockwebserver.utils.ResponseProviders; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java index 51aa847f774..f1ba2be7eda 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java @@ -16,7 +16,7 @@ package io.fabric8.kubernetes.client.http; import io.fabric8.mockwebserver.DefaultMockServer; -import okhttp3.mockwebserver.RecordedRequest; +import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java index a56e417fd13..21184bd36de 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java @@ -16,7 +16,7 @@ package io.fabric8.kubernetes.client.http; import io.fabric8.mockwebserver.DefaultMockServer; -import okhttp3.mockwebserver.RecordedRequest; +import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java index 0c6914bbcb4..dfa940bed65 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java @@ -18,11 +18,13 @@ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; -import okhttp3.Protocol; -import okhttp3.Response; -import okhttp3.WebSocketListener; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; +import io.fabric8.mockwebserver.MockWebServer; +import io.fabric8.mockwebserver.MockWebServerListener; +import io.fabric8.mockwebserver.http.MockResponse; +import io.fabric8.mockwebserver.http.RecordedHttpConnection; +import io.fabric8.mockwebserver.http.Response; +import io.fabric8.mockwebserver.http.WebSocketListener; +import io.fabric8.mockwebserver.vertx.Protocol; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -30,17 +32,11 @@ import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; -import java.io.Closeable; import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.SocketException; import java.net.URI; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -51,8 +47,6 @@ import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; -import javax.net.ServerSocketFactory; - import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractSimultaneousConnectionsTest { @@ -63,7 +57,7 @@ public abstract class AbstractSimultaneousConnectionsTest { private static final int MAX_HTTP_1_CONNECTIONS = 2048; // Should be able to at least make 2048 private static final int MAX_HTTP_1_WS_CONNECTIONS = 1024; // Should be able to at least make 1024 - private RegisteredServerSocketFactory serverSocketFactory; + private RegisteredConnections registeredConnections; private MockWebServer mockWebServer; private ExecutorService httpExecutor; private HttpServer httpServer; @@ -72,9 +66,9 @@ public abstract class AbstractSimultaneousConnectionsTest { @BeforeEach void prepareServerAndBuilder() throws IOException { - serverSocketFactory = new RegisteredServerSocketFactory(); + registeredConnections = new RegisteredConnections(); mockWebServer = new MockWebServer(); - mockWebServer.setServerSocketFactory(serverSocketFactory); + mockWebServer.addListener(registeredConnections); httpExecutor = Executors.newCachedThreadPool(); httpServer = HttpServer.create(new InetSocketAddress(0), 0); httpServer.setExecutor(httpExecutor); @@ -84,8 +78,7 @@ void prepareServerAndBuilder() throws IOException { } @AfterEach - void stopServer() throws IOException { - serverSocketFactory.close(); + void stopServer() { mockWebServer.shutdown(); httpServer.stop(0); httpExecutor.shutdownNow(); @@ -93,7 +86,7 @@ void stopServer() throws IOException { protected abstract HttpClient.Factory getHttpClientFactory(); - private void withHttp1() throws IOException { + private void withHttp1() { mockWebServer.setProtocols(Collections.singletonList(Protocol.HTTP_1_1)); mockWebServer.start(); } @@ -146,14 +139,14 @@ public void http1WebSocketConnectionsBeforeUpgrade() throws Exception { @DisabledOnOs(OS.WINDOWS) public void http1WebSocketConnections() throws Exception { withHttp1(); - final Collection serverSockets = ConcurrentHashMap.newKeySet(); + final Collection serverSockets = ConcurrentHashMap.newKeySet(); final Collection clientSockets = ConcurrentHashMap.newKeySet(); final CyclicBarrier cyclicBarrier = new CyclicBarrier(2); final CountDownLatch latch = new CountDownLatch(MAX_HTTP_1_WS_CONNECTIONS); final MockResponse response = new MockResponse() .withWebSocketUpgrade(new WebSocketListener() { @Override - public void onOpen(okhttp3.WebSocket webSocket, Response response) { + public void onOpen(io.fabric8.mockwebserver.http.WebSocket webSocket, Response response) { try { cyclicBarrier.await(1, TimeUnit.SECONDS); } catch (Exception ignore) { @@ -181,11 +174,11 @@ public void onMessage(WebSocket webSocket, String text) { assertThat(latch.await(60L, TimeUnit.SECONDS)).isTrue(); assertThat(serverSockets.size()) .isEqualTo(MAX_HTTP_1_WS_CONNECTIONS) - .isLessThanOrEqualTo((int) serverSocketFactory.activeConnections()); + .isLessThanOrEqualTo(registeredConnections.activeConnections()); // assertThat(clientSockets) // .hasSize(MAX_HTTP_1_WS_CONNECTIONS); } finally { - for (okhttp3.WebSocket socket : serverSockets) { + for (io.fabric8.mockwebserver.http.WebSocket socket : serverSockets) { socket.close(1000, "done"); } } @@ -237,50 +230,23 @@ public final void await() { } } - private static class RegisteredServerSocketFactory extends ServerSocketFactory implements Closeable { - - private final Set connections = new HashSet<>(); + private static class RegisteredConnections implements MockWebServerListener { - final long activeConnections() { - return connections.stream().filter(Socket::isConnected).filter(s -> !s.isClosed()).count(); - } + private final Set connections = ConcurrentHashMap.newKeySet(); - @Override - public final void close() { - for (Socket socket : connections) { - try { - socket.close(); - } catch (IOException ignored) { - // ignored - } - } - } - - @Override - public ServerSocket createServerSocket() throws IOException { - return new ServerSocket() { - @Override - public Socket accept() throws IOException { - final Socket socket = super.accept(); - connections.add(socket); - return socket; - } - }; - } - - @Override - public ServerSocket createServerSocket(int port) throws IOException { - throw new SocketException("not implemented"); + final int activeConnections() { + return connections.size(); } @Override - public ServerSocket createServerSocket(int port, int backlog) throws IOException { - throw new SocketException("not implemented"); + public void onConnection(RecordedHttpConnection connection) { + connections.add(connection); + MockWebServerListener.super.onConnection(connection); } @Override - public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { - throw new SocketException("not implemented"); + public void onConnectionClosed(RecordedHttpConnection connection) { + connections.remove(connection); } } } diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java index efe680301d4..0aa61eb61ee 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java @@ -40,9 +40,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.junit.Assert.assertNotSame; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertTrue; class CertUtilsTest { diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java index 9eee26acb09..da570cf552d 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java @@ -20,8 +20,8 @@ import io.fabric8.kubernetes.client.informers.ResourceEventHandler; import org.junit.jupiter.api.Test; -import static junit.framework.TestCase.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; class ProcessorListenerTest { diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java index 754f451ab3b..efe1adcf4d9 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java @@ -20,7 +20,7 @@ import io.fabric8.kubernetes.client.informers.ResourceEventHandler; import org.junit.jupiter.api.Test; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; class SharedProcessorTest { @Test diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RequestConfigTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RequestConfigTest.java index c8970107876..84decd5491f 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RequestConfigTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RequestConfigTest.java @@ -22,7 +22,7 @@ import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; import io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor; -import okhttp3.mockwebserver.RecordedRequest; +import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/pom.xml b/pom.xml index a52ec96858d..b4d26ab5b11 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,7 @@ 4.0.17 + 4.13.2 5.10.1 3.25.1 4.2.0 @@ -848,6 +849,12 @@ test + + junit + junit + ${junit4.version} + test + org.junit.jupiter junit-jupiter-api