use of okhttp3.mockwebserver.MockResponse in project zipkin by openzipkin.
the class AWSSignatureVersion4Test method unwrapsJsonError.
@Test
public void unwrapsJsonError() throws InterruptedException, IOException {
// makes sure this isn't wrapped.
thrown.expect(IllegalStateException.class);
thrown.expectMessage("The request signature we calculated does not match the signature you provided.");
es.enqueue(new MockResponse().setResponseCode(403).setBody("{\"message\":\"The request signature we calculated does not match the signature you provided.\"}"));
client.newCall(new Request.Builder().url(es.url("/_template/zipkin_template")).build()).execute();
}
use of okhttp3.mockwebserver.MockResponse in project zipkin by openzipkin.
the class HttpCallTest method propagatesOnDispatcherThreadWhenFatal.
@Test
public void propagatesOnDispatcherThreadWhenFatal() throws Exception {
mws.enqueue(new MockResponse());
http.newCall(request, b -> {
throw new LinkageError();
}).submit(callback);
SimpleTimeLimiter timeLimiter = new SimpleTimeLimiter();
try {
timeLimiter.callWithTimeout(callback::get, 100, TimeUnit.MILLISECONDS, true);
failBecauseExceptionWasNotThrown(UncheckedTimeoutException.class);
} catch (UncheckedTimeoutException expected) {
}
}
use of okhttp3.mockwebserver.MockResponse in project zipkin by openzipkin.
the class HttpCallTest method executionException_conversionException.
@Test
public void executionException_conversionException() throws Exception {
mws.enqueue(new MockResponse());
http.newCall(request, b -> {
throw new IllegalArgumentException("eeek");
}).submit(callback);
try {
callback.get();
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (IllegalArgumentException expected) {
assertThat(expected).isInstanceOf(IllegalArgumentException.class);
}
}
use of okhttp3.mockwebserver.MockResponse in project zipkin by openzipkin.
the class ElasticsearchHttpStorageTest method memoizesIndexTemplate.
@Test
public void memoizesIndexTemplate() throws Exception {
es.enqueue(new MockResponse().setBody("{\"version\":{\"number\":\"2.4.0\"}}"));
// get template
es.enqueue(new MockResponse());
// dependencies request
es.enqueue(new MockResponse());
// dependencies request
es.enqueue(new MockResponse());
long endTs = storage.indexNameFormatter().parseDate("2016-10-02");
storage.spanStore().getDependencies(endTs, TimeUnit.DAYS.toMillis(1));
storage.spanStore().getDependencies(endTs, TimeUnit.DAYS.toMillis(1));
// get version
es.takeRequest();
// get template
es.takeRequest();
assertThat(es.takeRequest().getPath()).startsWith("/zipkin-2016-10-01,zipkin-2016-10-02/dependencylink/_search");
assertThat(es.takeRequest().getPath()).startsWith("/zipkin-2016-10-01,zipkin-2016-10-02/dependencylink/_search");
}
use of okhttp3.mockwebserver.MockResponse 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\"");
}
Aggregations