mirror of
https://github.com/square/okhttp.git
synced 2025-08-01 16:06:56 +03:00
Improve PlatformRule autodetection (#4920)
Run more platforms in circleci. Auto detect platform in IDE. Surface more platform assumptions in tests.
This commit is contained in:
@ -25,6 +25,7 @@ import javax.net.ssl.HostnameVerifier;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.PlatformRule;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.RecordingHostnameVerifier;
|
||||
import okhttp3.Request;
|
||||
@ -51,6 +52,7 @@ import static org.junit.Assume.assumeThat;
|
||||
public final class HttpLoggingInterceptorTest {
|
||||
private static final MediaType PLAIN = MediaType.get("text/plain; charset=utf-8");
|
||||
|
||||
@Rule public final PlatformRule platform = new PlatformRule();
|
||||
@Rule public final MockWebServer server = new MockWebServer();
|
||||
|
||||
private final HandshakeCertificates handshakeCertificates = localhost();
|
||||
@ -784,6 +786,8 @@ public final class HttpLoggingInterceptorTest {
|
||||
}
|
||||
|
||||
@Test public void duplexRequestsAreNotLogged() throws Exception {
|
||||
platform.assumeHttp2Support();
|
||||
|
||||
server.useHttps(handshakeCertificates.sslSocketFactory(), false); // HTTP/2
|
||||
url = server.url("/");
|
||||
|
||||
|
@ -20,6 +20,7 @@ import java.net.UnknownHostException;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.PlatformRule;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
@ -41,6 +42,7 @@ import static org.junit.Assert.fail;
|
||||
public final class LoggingEventListenerTest {
|
||||
private static final MediaType PLAIN = MediaType.get("text/plain");
|
||||
|
||||
@Rule public final PlatformRule platform = new PlatformRule();
|
||||
@Rule public final MockWebServer server = new MockWebServer();
|
||||
|
||||
private final HandshakeCertificates handshakeCertificates = localhost();
|
||||
@ -139,6 +141,8 @@ public final class LoggingEventListenerTest {
|
||||
assertThat(response.body()).isNotNull();
|
||||
response.body().bytes();
|
||||
|
||||
platform.assumeHttp2Support();
|
||||
|
||||
logRecorder
|
||||
.assertLogMatch("callStart: Request\\{method=GET, url=" + url + ", tags=\\{\\}\\}")
|
||||
.assertLogMatch("dnsStart: " + url.host())
|
||||
|
Reference in New Issue
Block a user