mirror of
https://github.com/square/okhttp.git
synced 2025-07-31 05:04:26 +03:00
Fix android test (#8157)
This commit is contained in:
@ -82,18 +82,18 @@ class LoggingEventListenerTest {
|
|||||||
assertThat(response.body).isNotNull()
|
assertThat(response.body).isNotNull()
|
||||||
response.body.bytes()
|
response.body.bytes()
|
||||||
logRecorder
|
logRecorder
|
||||||
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url}"""))
|
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
||||||
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
||||||
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
||||||
.assertLogMatch(Regex("""dnsEnd: \[.+]"""))
|
.assertLogMatch(Regex("""dnsEnd: \[.+]"""))
|
||||||
.assertLogMatch(Regex("""connectStart: ${url.host}/.+ DIRECT"""))
|
.assertLogMatch(Regex("""connectStart: ${url.host}/.+ DIRECT"""))
|
||||||
.assertLogMatch(Regex("""connectEnd: http/1.1"""))
|
.assertLogMatch(Regex("""connectEnd: http/1.1"""))
|
||||||
.assertLogMatch(Regex("""connectionAcquired: Connection\{${url.host}:\d+, proxy=DIRECT hostAddress=${url.host}/.+ cipherSuite=none protocol=http/1\.1}"""))
|
.assertLogMatch(Regex("""connectionAcquired: Connection\{${url.host}:\d+, proxy=DIRECT hostAddress=${url.host}/.+ cipherSuite=none protocol=http/1\.1\}"""))
|
||||||
.assertLogMatch(Regex("""requestHeadersStart"""))
|
.assertLogMatch(Regex("""requestHeadersStart"""))
|
||||||
.assertLogMatch(Regex("""requestHeadersEnd"""))
|
.assertLogMatch(Regex("""requestHeadersEnd"""))
|
||||||
.assertLogMatch(Regex("""responseHeadersStart"""))
|
.assertLogMatch(Regex("""responseHeadersStart"""))
|
||||||
.assertLogMatch(Regex("""responseHeadersEnd: Response\{protocol=http/1\.1, code=200, message=OK, url=$url}"""))
|
.assertLogMatch(Regex("""responseHeadersEnd: Response\{protocol=http/1\.1, code=200, message=OK, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""responseBodyStart"""))
|
.assertLogMatch(Regex("""responseBodyStart"""))
|
||||||
.assertLogMatch(Regex("""responseBodyEnd: byteCount=6"""))
|
.assertLogMatch(Regex("""responseBodyEnd: byteCount=6"""))
|
||||||
.assertLogMatch(Regex("""connectionReleased"""))
|
.assertLogMatch(Regex("""connectionReleased"""))
|
||||||
@ -107,20 +107,20 @@ class LoggingEventListenerTest {
|
|||||||
server.enqueue(MockResponse())
|
server.enqueue(MockResponse())
|
||||||
client.newCall(request().post("Hello!".toRequestBody(PLAIN)).build()).execute()
|
client.newCall(request().post("Hello!".toRequestBody(PLAIN)).build()).execute()
|
||||||
logRecorder
|
logRecorder
|
||||||
.assertLogMatch(Regex("""callStart: Request\{method=POST, url=$url}"""))
|
.assertLogMatch(Regex("""callStart: Request\{method=POST, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
||||||
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
||||||
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
||||||
.assertLogMatch(Regex("""dnsEnd: \[.+]"""))
|
.assertLogMatch(Regex("""dnsEnd: \[.+]"""))
|
||||||
.assertLogMatch(Regex("""connectStart: ${url.host}/.+ DIRECT"""))
|
.assertLogMatch(Regex("""connectStart: ${url.host}/.+ DIRECT"""))
|
||||||
.assertLogMatch(Regex("""connectEnd: http/1.1"""))
|
.assertLogMatch(Regex("""connectEnd: http/1.1"""))
|
||||||
.assertLogMatch(Regex("""connectionAcquired: Connection\{${url.host}:\d+, proxy=DIRECT hostAddress=${url.host}/.+ cipherSuite=none protocol=http/1\.1}"""))
|
.assertLogMatch(Regex("""connectionAcquired: Connection\{${url.host}:\d+, proxy=DIRECT hostAddress=${url.host}/.+ cipherSuite=none protocol=http/1\.1\}"""))
|
||||||
.assertLogMatch(Regex("""requestHeadersStart"""))
|
.assertLogMatch(Regex("""requestHeadersStart"""))
|
||||||
.assertLogMatch(Regex("""requestHeadersEnd"""))
|
.assertLogMatch(Regex("""requestHeadersEnd"""))
|
||||||
.assertLogMatch(Regex("""requestBodyStart"""))
|
.assertLogMatch(Regex("""requestBodyStart"""))
|
||||||
.assertLogMatch(Regex("""requestBodyEnd: byteCount=6"""))
|
.assertLogMatch(Regex("""requestBodyEnd: byteCount=6"""))
|
||||||
.assertLogMatch(Regex("""responseHeadersStart"""))
|
.assertLogMatch(Regex("""responseHeadersStart"""))
|
||||||
.assertLogMatch(Regex("""responseHeadersEnd: Response\{protocol=http/1\.1, code=200, message=OK, url=$url}"""))
|
.assertLogMatch(Regex("""responseHeadersEnd: Response\{protocol=http/1\.1, code=200, message=OK, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""responseBodyStart"""))
|
.assertLogMatch(Regex("""responseBodyStart"""))
|
||||||
.assertLogMatch(Regex("""responseBodyEnd: byteCount=0"""))
|
.assertLogMatch(Regex("""responseBodyEnd: byteCount=0"""))
|
||||||
.assertLogMatch(Regex("""connectionReleased"""))
|
.assertLogMatch(Regex("""connectionReleased"""))
|
||||||
@ -139,20 +139,20 @@ class LoggingEventListenerTest {
|
|||||||
response.body.bytes()
|
response.body.bytes()
|
||||||
platform.assumeHttp2Support()
|
platform.assumeHttp2Support()
|
||||||
logRecorder
|
logRecorder
|
||||||
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url}"""))
|
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
||||||
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
||||||
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
||||||
.assertLogMatch(Regex("""dnsEnd: \[.+]"""))
|
.assertLogMatch(Regex("""dnsEnd: \[.+]"""))
|
||||||
.assertLogMatch(Regex("""connectStart: ${url.host}/.+ DIRECT"""))
|
.assertLogMatch(Regex("""connectStart: ${url.host}/.+ DIRECT"""))
|
||||||
.assertLogMatch(Regex("""secureConnectStart"""))
|
.assertLogMatch(Regex("""secureConnectStart"""))
|
||||||
.assertLogMatch(Regex("""secureConnectEnd: Handshake\{tlsVersion=TLS_1_[23] cipherSuite=TLS_.* peerCertificates=\[CN=localhost] localCertificates=\[]}"""))
|
.assertLogMatch(Regex("""secureConnectEnd: Handshake\{tlsVersion=TLS_1_[23] cipherSuite=TLS_.* peerCertificates=\[CN=localhost] localCertificates=\[]\}"""))
|
||||||
.assertLogMatch(Regex("""connectEnd: h2"""))
|
.assertLogMatch(Regex("""connectEnd: h2"""))
|
||||||
.assertLogMatch(Regex("""connectionAcquired: Connection\{${url.host}:\d+, proxy=DIRECT hostAddress=${url.host}/.+ cipherSuite=.+ protocol=h2}"""))
|
.assertLogMatch(Regex("""connectionAcquired: Connection\{${url.host}:\d+, proxy=DIRECT hostAddress=${url.host}/.+ cipherSuite=.+ protocol=h2\}"""))
|
||||||
.assertLogMatch(Regex("""requestHeadersStart"""))
|
.assertLogMatch(Regex("""requestHeadersStart"""))
|
||||||
.assertLogMatch(Regex("""requestHeadersEnd"""))
|
.assertLogMatch(Regex("""requestHeadersEnd"""))
|
||||||
.assertLogMatch(Regex("""responseHeadersStart"""))
|
.assertLogMatch(Regex("""responseHeadersStart"""))
|
||||||
.assertLogMatch(Regex("""responseHeadersEnd: Response\{protocol=h2, code=200, message=, url=$url}"""))
|
.assertLogMatch(Regex("""responseHeadersEnd: Response\{protocol=h2, code=200, message=, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""responseBodyStart"""))
|
.assertLogMatch(Regex("""responseBodyStart"""))
|
||||||
.assertLogMatch(Regex("""responseBodyEnd: byteCount=0"""))
|
.assertLogMatch(Regex("""responseBodyEnd: byteCount=0"""))
|
||||||
.assertLogMatch(Regex("""connectionReleased"""))
|
.assertLogMatch(Regex("""connectionReleased"""))
|
||||||
@ -172,7 +172,7 @@ class LoggingEventListenerTest {
|
|||||||
} catch (expected: UnknownHostException) {
|
} catch (expected: UnknownHostException) {
|
||||||
}
|
}
|
||||||
logRecorder
|
logRecorder
|
||||||
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url}"""))
|
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
||||||
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
||||||
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
||||||
@ -197,7 +197,7 @@ class LoggingEventListenerTest {
|
|||||||
} catch (expected: IOException) {
|
} catch (expected: IOException) {
|
||||||
}
|
}
|
||||||
logRecorder
|
logRecorder
|
||||||
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url}"""))
|
.assertLogMatch(Regex("""callStart: Request\{method=GET, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
.assertLogMatch(Regex("""proxySelectStart: $url"""))
|
||||||
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
.assertLogMatch(Regex("""proxySelectEnd: \[DIRECT]"""))
|
||||||
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
.assertLogMatch(Regex("""dnsStart: ${url.host}"""))
|
||||||
@ -222,10 +222,10 @@ class LoggingEventListenerTest {
|
|||||||
listener.cacheMiss(call)
|
listener.cacheMiss(call)
|
||||||
listener.satisfactionFailure(call, response)
|
listener.satisfactionFailure(call, response)
|
||||||
logRecorder
|
logRecorder
|
||||||
.assertLogMatch(Regex("""cacheConditionalHit: Response\{protocol=h2, code=200, message=, url=$url}"""))
|
.assertLogMatch(Regex("""cacheConditionalHit: Response\{protocol=h2, code=200, message=, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""cacheHit: Response\{protocol=h2, code=200, message=, url=$url}"""))
|
.assertLogMatch(Regex("""cacheHit: Response\{protocol=h2, code=200, message=, url=$url\}"""))
|
||||||
.assertLogMatch(Regex("""cacheMiss"""))
|
.assertLogMatch(Regex("""cacheMiss"""))
|
||||||
.assertLogMatch(Regex("""satisfactionFailure: Response\{protocol=h2, code=200, message=, url=$url}"""))
|
.assertLogMatch(Regex("""satisfactionFailure: Response\{protocol=h2, code=200, message=, url=$url\}"""))
|
||||||
.assertNoMoreLogs()
|
.assertNoMoreLogs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user