use of okhttp3.mockwebserver.RecordedRequest in project sonarqube by SonarSource.
the class HttpConnectorTest method use_basic_authentication.
@Test
public void use_basic_authentication() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder().url(serverUrl).credentials("theLogin", "thePassword").build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("theLogin", "thePassword"));
}
use of okhttp3.mockwebserver.RecordedRequest in project zipkin by openzipkin.
the class HttpBulkSpanIndexerTest method doesntWriteSpanId.
@Test
public void doesntWriteSpanId() throws Exception {
es.enqueue(new MockResponse());
indexer.add("test_zipkin_http-2016-10-01", TestObjects.LOTS_OF_SPANS[0], (Long) null);
indexer.execute(callback);
callback.get();
RecordedRequest request = es.takeRequest();
assertThat(request.getBody().readByteString().utf8()).doesNotContain("\"_id\"");
}
use of okhttp3.mockwebserver.RecordedRequest in project spring-framework by spring-projects.
the class AbstractMockWebServerTestCase method getRequest.
private MockResponse getRequest(RecordedRequest request, byte[] body, String contentType) {
if (request.getMethod().equals("OPTIONS")) {
return new MockResponse().setResponseCode(200).setHeader("Allow", "GET, OPTIONS, HEAD, TRACE");
}
Buffer buf = new Buffer();
buf.write(body);
MockResponse response = new MockResponse().setHeader("Content-Length", body.length).setBody(buf).setResponseCode(200);
if (contentType != null) {
response = response.setHeader("Content-Type", contentType);
}
return response;
}
use of okhttp3.mockwebserver.RecordedRequest in project spring-framework by spring-projects.
the class AbstractMockWebServerTestCase method putRequest.
private MockResponse putRequest(RecordedRequest request, String expectedRequestContent) {
assertTrue("Invalid request content-length", Integer.parseInt(request.getHeader("Content-Length")) > 0);
String requestContentType = request.getHeader("Content-Type");
assertNotNull("No content-type", requestContentType);
Charset charset = StandardCharsets.ISO_8859_1;
if (requestContentType.contains("charset=")) {
String charsetName = requestContentType.split("charset=")[1];
charset = Charset.forName(charsetName);
}
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
return new MockResponse().setResponseCode(202);
}
use of okhttp3.mockwebserver.RecordedRequest in project spring-framework by spring-projects.
the class AbstractMockWebServerTestCase method postRequest.
private MockResponse postRequest(RecordedRequest request, String expectedRequestContent, String location, String contentType, byte[] responseBody) {
assertEquals(1, request.getHeaders().values("Content-Length").size());
assertTrue("Invalid request content-length", Integer.parseInt(request.getHeader("Content-Length")) > 0);
String requestContentType = request.getHeader("Content-Type");
assertNotNull("No content-type", requestContentType);
Charset charset = StandardCharsets.ISO_8859_1;
if (requestContentType.contains("charset=")) {
String charsetName = requestContentType.split("charset=")[1];
charset = Charset.forName(charsetName);
}
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
Buffer buf = new Buffer();
buf.write(responseBody);
return new MockResponse().setHeader("Location", baseUrl + location).setHeader("Content-Type", contentType).setHeader("Content-Length", responseBody.length).setBody(buf).setResponseCode(201);
}
Aggregations