> responses;
private KubernetesMixedDispatcher dispatcher;
- private Socket socket;
-
@BeforeEach
void setUp() {
responses = new HashMap<>();
dispatcher = new KubernetesMixedDispatcher(responses);
- socket = Mockito.mock(Socket.class, Mockito.RETURNS_DEEP_STUBS);
}
@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));
// When
- final MockResponse result = dispatcher.dispatch(new RecordedRequest(
- "GET /api/v1/resources/my-resource HTTP/1.1", EMPTY_HEADERS, Collections.emptyList(),
- 0, new Buffer(), 0, socket));
+ final MockResponse result = dispatcher.dispatch(new RecordedRequest("HTTP/1.1", HttpMethod.GET,
+ "/api/v1/resources/my-resource", EMPTY_HEADERS, null));
// Then
assertThat(result)
.hasFieldOrPropertyWithValue("status", "HTTP/1.1 200 OK")
@@ -76,19 +69,17 @@ 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\"}}",
StandardCharsets.UTF_8);
requestBody.flush();
- dispatcher.dispatch(new RecordedRequest(
- "POST /api/v1/resources HTTP/1.1", EMPTY_HEADERS, Collections.emptyList(),
- requestBody.size(), requestBody, 0, socket));
+ dispatcher.dispatch(new RecordedRequest("HTTP/1.1", HttpMethod.POST,
+ "/api/v1/resources", EMPTY_HEADERS, requestBody));
// When
- final MockResponse result = dispatcher.dispatch(new RecordedRequest(
- "GET /api/v1/resources/my-resource HTTP/1.1", EMPTY_HEADERS, Collections.emptyList(),
- 0, new Buffer(), 0, socket));
+ final MockResponse result = dispatcher.dispatch(new RecordedRequest("HTTP/1.1", HttpMethod.GET,
+ "/api/v1/resources/my-resource", EMPTY_HEADERS, null));
// Then
assertThat(result)
.hasFieldOrPropertyWithValue("status", "HTTP/1.1 200 OK")
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 feaa3aec369..60c23af07d8 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/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/MediaType.java b/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/MediaType.java
index 05a49ce013a..bc292fc0726 100644
--- a/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/MediaType.java
+++ b/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/MediaType.java
@@ -20,11 +20,11 @@
import java.util.regex.Pattern;
/**
- * Compatibility layer for OkHttp.
+ * Provides tooling to parse and manipulate media types.
*
- * @deprecated should not be needed anymore
+ *
+ * Compatibility layer for OkHttp.
*/
-@Deprecated
public class MediaType {
private static final String TOKEN = "([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)";
private static final String QUOTED = "\"([^\"]*)\"";
diff --git a/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/WebSocketListener.java b/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/WebSocketListener.java
index d652c015485..7d9a3700077 100644
--- a/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/WebSocketListener.java
+++ b/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/http/WebSocketListener.java
@@ -15,6 +15,8 @@
*/
package io.fabric8.mockwebserver.http;
+import java.nio.charset.StandardCharsets;
+
public abstract class WebSocketListener {
/**
@@ -40,10 +42,11 @@ public void onMessage(WebSocket webSocket, String text) {
*/
@Deprecated
public void onMessage(WebSocket webSocket, ByteString bytes) {
+ onMessage(webSocket, bytes.utf8());
}
public void onMessage(WebSocket webSocket, byte[] bytes) {
- onMessage(webSocket, ByteString.of(bytes));
+ onMessage(webSocket, new String(bytes, StandardCharsets.UTF_8));
}
/**
diff --git a/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/internal/MockServerExpectationImpl.java b/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/internal/MockServerExpectationImpl.java
index 83ad81b1148..c9ee9cd0309 100644
--- a/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/internal/MockServerExpectationImpl.java
+++ b/junit/mockwebserver/src/main/java/io/fabric8/mockwebserver/internal/MockServerExpectationImpl.java
@@ -230,7 +230,7 @@ private ServerResponse createResponse(boolean repeatable, long delay, TimeUnit d
}
private ResponseProvider toString(final ResponseProvider