Search in sources :

Example 1 with HTTP_2

use of okhttp3.Protocol.HTTP_2 in project okhttp by square.

the class LoggingEventListenerTest method testCacheEvents.

@Test
public void testCacheEvents() {
    Request request = new Request.Builder().url(url).build();
    Call call = client.newCall(request);
    Response response = new Response.Builder().request(request).code(200).message("").protocol(HTTP_2).build();
    EventListener listener = loggingEventListenerFactory.create(call);
    listener.cacheConditionalHit(call, response);
    listener.cacheHit(call, response);
    listener.cacheMiss(call);
    listener.satisfactionFailure(call, response);
    logRecorder.assertLogMatch("cacheConditionalHit: Response\\{protocol=h2, code=200, message=, url=" + url + "\\}").assertLogMatch("cacheHit: Response\\{protocol=h2, code=200, message=, url=" + url + "\\}").assertLogMatch("cacheMiss").assertLogMatch("satisfactionFailure: Response\\{protocol=h2, code=200, message=, url=" + url + "\\}").assertNoMoreLogs();
}
Also used : Response(okhttp3.Response) MockResponse(mockwebserver3.MockResponse) Call(okhttp3.Call) Request(okhttp3.Request) EventListener(okhttp3.EventListener) Test(org.junit.jupiter.api.Test)

Aggregations

MockResponse (mockwebserver3.MockResponse)1 Call (okhttp3.Call)1 EventListener (okhttp3.EventListener)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 Test (org.junit.jupiter.api.Test)1