From 018510fa4054f0c57d004847f39a1fad12ad8b12 Mon Sep 17 00:00:00 2001 From: Amir Livneh Date: Thu, 7 Mar 2019 07:24:05 -0500 Subject: [PATCH] Rename OkHttpClientTestingRule to OkHttpClientTestRule --- .../java/okhttp3/internal/sse/EventSourceHttpTest.java | 6 +++--- ...lientTestingRule.java => OkHttpClientTestRule.java} | 2 +- okhttp-tests/src/test/java/okhttp3/CacheTest.java | 4 ++-- okhttp-tests/src/test/java/okhttp3/CallTest.java | 10 +++++----- .../test/java/okhttp3/ConnectionCoalescingTest.java | 5 ++--- .../src/test/java/okhttp3/ConnectionReuseTest.java | 5 ++--- okhttp-tests/src/test/java/okhttp3/CookiesTest.java | 5 ++--- okhttp-tests/src/test/java/okhttp3/DispatcherTest.java | 5 ++--- okhttp-tests/src/test/java/okhttp3/DuplexTest.java | 5 ++--- .../src/test/java/okhttp3/EventListenerTest.java | 6 +++--- .../src/test/java/okhttp3/InterceptorTest.java | 5 ++--- .../src/test/java/okhttp3/URLConnectionTest.java | 4 ++-- .../test/java/okhttp3/WholeOperationTimeoutTest.java | 5 ++--- .../test/java/okhttp3/internal/http/CancelTest.java | 6 +++--- .../okhttp3/internal/http/ThreadInterruptTest.java | 9 ++++----- .../java/okhttp3/internal/http2/HttpOverHttp2Test.java | 8 ++++---- 16 files changed, 41 insertions(+), 49 deletions(-) rename okhttp-testing-support/src/main/java/okhttp3/{OkHttpClientTestingRule.java => OkHttpClientTestRule.java} (95%) diff --git a/okhttp-sse/src/test/java/okhttp3/internal/sse/EventSourceHttpTest.java b/okhttp-sse/src/test/java/okhttp3/internal/sse/EventSourceHttpTest.java index cf86b5123..71dcbb227 100644 --- a/okhttp-sse/src/test/java/okhttp3/internal/sse/EventSourceHttpTest.java +++ b/okhttp-sse/src/test/java/okhttp3/internal/sse/EventSourceHttpTest.java @@ -17,7 +17,7 @@ package okhttp3.internal.sse; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; -import okhttp3.OkHttpClientTestingRule; +import okhttp3.OkHttpClientTestRule; import okhttp3.Request; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; @@ -31,10 +31,10 @@ import static org.junit.Assert.assertEquals; public final class EventSourceHttpTest { @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private final EventSourceRecorder listener = new EventSourceRecorder(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; @After public void after() { listener.assertExhausted(); diff --git a/okhttp-testing-support/src/main/java/okhttp3/OkHttpClientTestingRule.java b/okhttp-testing-support/src/main/java/okhttp3/OkHttpClientTestRule.java similarity index 95% rename from okhttp-testing-support/src/main/java/okhttp3/OkHttpClientTestingRule.java rename to okhttp-testing-support/src/main/java/okhttp3/OkHttpClientTestRule.java index ed00c865e..c447117e8 100644 --- a/okhttp-testing-support/src/main/java/okhttp3/OkHttpClientTestingRule.java +++ b/okhttp-testing-support/src/main/java/okhttp3/OkHttpClientTestRule.java @@ -21,7 +21,7 @@ import org.junit.runners.model.Statement; import static okhttp3.TestUtil.defaultClient; -public class OkHttpClientTestingRule implements TestRule { +public class OkHttpClientTestRule implements TestRule { public OkHttpClient client = defaultClient(); @Override diff --git a/okhttp-tests/src/test/java/okhttp3/CacheTest.java b/okhttp-tests/src/test/java/okhttp3/CacheTest.java index 378c86c93..ece9069d9 100644 --- a/okhttp-tests/src/test/java/okhttp3/CacheTest.java +++ b/okhttp-tests/src/test/java/okhttp3/CacheTest.java @@ -66,7 +66,7 @@ public final class CacheTest { @Rule public MockWebServer server = new MockWebServer(); @Rule public MockWebServer server2 = new MockWebServer(); @Rule public InMemoryFileSystem fileSystem = new InMemoryFileSystem(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private final HandshakeCertificates handshakeCertificates = localhost(); private OkHttpClient client; @@ -76,7 +76,7 @@ public final class CacheTest { @Before public void setUp() throws Exception { server.setProtocolNegotiationEnabled(false); cache = new Cache(new File("/cache/"), Integer.MAX_VALUE, fileSystem); - client = clientTestingRule.client.newBuilder() + client = clientTestRule.client.newBuilder() .cache(cache) .cookieJar(new JavaNetCookieJar(cookieManager)) .build(); diff --git a/okhttp-tests/src/test/java/okhttp3/CallTest.java b/okhttp-tests/src/test/java/okhttp3/CallTest.java index 7192e6ac3..ab78553ce 100644 --- a/okhttp-tests/src/test/java/okhttp3/CallTest.java +++ b/okhttp-tests/src/test/java/okhttp3/CallTest.java @@ -107,11 +107,11 @@ public final class CallTest { @Rule public final MockWebServer server = new MockWebServer(); @Rule public final MockWebServer server2 = new MockWebServer(); @Rule public final InMemoryFileSystem fileSystem = new InMemoryFileSystem(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private final RecordingEventListener listener = new RecordingEventListener(); private HandshakeCertificates handshakeCertificates = localhost(); - private OkHttpClient client = clientTestingRule.client.newBuilder() + private OkHttpClient client = clientTestRule.client.newBuilder() .eventListener(listener) .build(); private RecordingCallback callback = new RecordingCallback(); @@ -933,7 +933,7 @@ public final class CallTest { /** https://github.com/square/okhttp/issues/1801 */ @Test public void asyncCallEngineInitialized() throws Exception { - OkHttpClient c = clientTestingRule.client.newBuilder() + OkHttpClient c = clientTestRule.client.newBuilder() .addInterceptor(chain -> { throw new IOException(); }) .build(); Request request = new Request.Builder().url(server.url("/")).build(); @@ -3368,7 +3368,7 @@ public final class CallTest { server.enqueue(new MockResponse() .setBody("This gets leaked.")); - client = clientTestingRule.client.newBuilder() + client = clientTestRule.client.newBuilder() .connectionPool(new ConnectionPool(0, 10, TimeUnit.MILLISECONDS)) .build(); @@ -3397,7 +3397,7 @@ public final class CallTest { server.enqueue(new MockResponse() .setBody("This gets leaked.")); - client = clientTestingRule.client.newBuilder() + client = clientTestRule.client.newBuilder() .connectionPool(new ConnectionPool(0, 10, TimeUnit.MILLISECONDS)) .build(); diff --git a/okhttp-tests/src/test/java/okhttp3/ConnectionCoalescingTest.java b/okhttp-tests/src/test/java/okhttp3/ConnectionCoalescingTest.java index 5ef58cf3d..8fb237fbe 100644 --- a/okhttp-tests/src/test/java/okhttp3/ConnectionCoalescingTest.java +++ b/okhttp-tests/src/test/java/okhttp3/ConnectionCoalescingTest.java @@ -29,7 +29,6 @@ import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.tls.HandshakeCertificates; import okhttp3.tls.HeldCertificate; -import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; @@ -40,7 +39,7 @@ import static org.junit.Assert.fail; public final class ConnectionCoalescingTest { @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private OkHttpClient client; @@ -82,7 +81,7 @@ public final class ConnectionCoalescingTest { .sslSocketFactory( handshakeCertificates.sslSocketFactory(), handshakeCertificates.trustManager()) .build(); - clientTestingRule.client = client; + clientTestRule.client = client; HandshakeCertificates serverHandshakeCertificates = new HandshakeCertificates.Builder() .heldCertificate(certificate) diff --git a/okhttp-tests/src/test/java/okhttp3/ConnectionReuseTest.java b/okhttp-tests/src/test/java/okhttp3/ConnectionReuseTest.java index f1d348504..62efebdd1 100644 --- a/okhttp-tests/src/test/java/okhttp3/ConnectionReuseTest.java +++ b/okhttp-tests/src/test/java/okhttp3/ConnectionReuseTest.java @@ -25,7 +25,6 @@ import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.SocketPolicy; import okhttp3.tls.HandshakeCertificates; -import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; @@ -38,10 +37,10 @@ import static org.junit.Assert.fail; public final class ConnectionReuseTest { @Rule public final TestRule timeout = new Timeout(30_000); @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private HandshakeCertificates handshakeCertificates = localhost(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; @Test public void connectionsAreReused() throws Exception { server.enqueue(new MockResponse().setBody("a")); diff --git a/okhttp-tests/src/test/java/okhttp3/CookiesTest.java b/okhttp-tests/src/test/java/okhttp3/CookiesTest.java index 01bbd635d..d28fbb4fe 100644 --- a/okhttp-tests/src/test/java/okhttp3/CookiesTest.java +++ b/okhttp-tests/src/test/java/okhttp3/CookiesTest.java @@ -31,7 +31,6 @@ import java.util.Map; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -44,9 +43,9 @@ import static org.junit.Assert.fail; /** Derived from Android's CookiesTest. */ public class CookiesTest { - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; @Test public void testNetscapeResponse() throws Exception { diff --git a/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java b/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java index 92ff8cdde..7cab7d76d 100644 --- a/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java +++ b/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java @@ -15,7 +15,6 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import okhttp3.RealCall.AsyncCall; -import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -27,14 +26,14 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public final class DispatcherTest { - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); RecordingExecutor executor = new RecordingExecutor(); RecordingCallback callback = new RecordingCallback(); RecordingWebSocketListener webSocketListener = new RecordingWebSocketListener(); Dispatcher dispatcher = new Dispatcher(executor); RecordingEventListener listener = new RecordingEventListener(); - OkHttpClient client = clientTestingRule.client.newBuilder() + OkHttpClient client = clientTestRule.client.newBuilder() .dispatcher(dispatcher) .eventListener(listener) .build(); diff --git a/okhttp-tests/src/test/java/okhttp3/DuplexTest.java b/okhttp-tests/src/test/java/okhttp3/DuplexTest.java index 47fdd93f1..3e39260d8 100644 --- a/okhttp-tests/src/test/java/okhttp3/DuplexTest.java +++ b/okhttp-tests/src/test/java/okhttp3/DuplexTest.java @@ -31,7 +31,6 @@ import okhttp3.mockwebserver.internal.duplex.MockDuplexResponseBody; import okhttp3.tls.HandshakeCertificates; import okio.BufferedSink; import okio.BufferedSource; -import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; @@ -46,11 +45,11 @@ import static org.junit.Assert.fail; public final class DuplexTest { @Rule public final TestRule timeout = new Timeout(30_000, TimeUnit.MILLISECONDS); @Rule public final MockWebServer server = new MockWebServer(); - @Rule public OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private final RecordingEventListener listener = new RecordingEventListener(); private HandshakeCertificates handshakeCertificates = localhost(); - private OkHttpClient client = clientTestingRule.client + private OkHttpClient client = clientTestRule.client .newBuilder() .eventListener(listener) .build(); diff --git a/okhttp-tests/src/test/java/okhttp3/EventListenerTest.java b/okhttp-tests/src/test/java/okhttp3/EventListenerTest.java index 818de4167..f9cf8aa2d 100644 --- a/okhttp-tests/src/test/java/okhttp3/EventListenerTest.java +++ b/okhttp-tests/src/test/java/okhttp3/EventListenerTest.java @@ -79,16 +79,16 @@ import static org.junit.Assume.assumeThat; public final class EventListenerTest { public static final Matcher anyResponse = CoreMatchers.any(Response.class); @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private final RecordingEventListener listener = new RecordingEventListener(); private final HandshakeCertificates handshakeCertificates = localhost(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; private SocksProxy socksProxy; @Before public void setUp() { - client = clientTestingRule.client.newBuilder() + client = clientTestRule.client.newBuilder() .eventListener(listener) .build(); diff --git a/okhttp-tests/src/test/java/okhttp3/InterceptorTest.java b/okhttp-tests/src/test/java/okhttp3/InterceptorTest.java index 9b600e348..89242dcf2 100644 --- a/okhttp-tests/src/test/java/okhttp3/InterceptorTest.java +++ b/okhttp-tests/src/test/java/okhttp3/InterceptorTest.java @@ -39,7 +39,6 @@ import okio.GzipSink; import okio.Okio; import okio.Sink; import okio.Source; -import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -53,9 +52,9 @@ import static org.junit.Assert.fail; public final class InterceptorTest { @Rule public MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; private RecordingCallback callback = new RecordingCallback(); @Test public void applicationInterceptorsCanShortCircuitResponses() throws Exception { diff --git a/okhttp-tests/src/test/java/okhttp3/URLConnectionTest.java b/okhttp-tests/src/test/java/okhttp3/URLConnectionTest.java index 59470280b..f1f070efd 100644 --- a/okhttp-tests/src/test/java/okhttp3/URLConnectionTest.java +++ b/okhttp-tests/src/test/java/okhttp3/URLConnectionTest.java @@ -113,10 +113,10 @@ public final class URLConnectionTest { @Rule public final MockWebServer server = new MockWebServer(); @Rule public final MockWebServer server2 = new MockWebServer(); @Rule public final TemporaryFolder tempDir = new TemporaryFolder(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private HandshakeCertificates handshakeCertificates = localhost(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; private @Nullable Cache cache; @Before public void setUp() { diff --git a/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java b/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java index 7c49986ba..7847332f5 100644 --- a/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java +++ b/okhttp-tests/src/test/java/okhttp3/WholeOperationTimeoutTest.java @@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicReference; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.BufferedSink; -import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -39,9 +38,9 @@ public final class WholeOperationTimeoutTest { private static final String BIG_ENOUGH_BODY = TestUtil.repeat('a', 64 * 1024); @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; @Test public void defaultConfigIsNoTimeout() throws Exception { Request request = new Request.Builder() diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http/CancelTest.java b/okhttp-tests/src/test/java/okhttp3/internal/http/CancelTest.java index 6635103ad..6f11d320b 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http/CancelTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/http/CancelTest.java @@ -28,7 +28,7 @@ import okhttp3.DelegatingServerSocketFactory; import okhttp3.DelegatingSocketFactory; import okhttp3.MediaType; import okhttp3.OkHttpClient; -import okhttp3.OkHttpClientTestingRule; +import okhttp3.OkHttpClientTestRule; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -43,7 +43,7 @@ import org.junit.Test; import static org.junit.Assert.fail; public final class CancelTest { - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); // The size of the socket buffers in bytes. private static final int SOCKET_BUFFER_SIZE = 256 * 1024; @@ -63,7 +63,7 @@ public final class CancelTest { return serverSocket; } }); - client = clientTestingRule.client.newBuilder() + client = clientTestRule.client.newBuilder() .socketFactory(new DelegatingSocketFactory(SocketFactory.getDefault()) { @Override protected Socket configureSocket(Socket socket) throws IOException { socket.setSendBufferSize(SOCKET_BUFFER_SIZE); diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http/ThreadInterruptTest.java b/okhttp-tests/src/test/java/okhttp3/internal/http/ThreadInterruptTest.java index ebafd3416..86364052f 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http/ThreadInterruptTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/http/ThreadInterruptTest.java @@ -28,11 +28,10 @@ import okhttp3.DelegatingServerSocketFactory; import okhttp3.DelegatingSocketFactory; import okhttp3.MediaType; import okhttp3.OkHttpClient; -import okhttp3.OkHttpClientTestingRule; +import okhttp3.OkHttpClientTestRule; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -import okhttp3.TestUtil; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; @@ -45,13 +44,13 @@ import org.junit.Test; import static org.junit.Assert.fail; public final class ThreadInterruptTest { - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); // The size of the socket buffers in bytes. private static final int SOCKET_BUFFER_SIZE = 256 * 1024; private MockWebServer server; - private OkHttpClient client = clientTestingRule.client; + private OkHttpClient client = clientTestRule.client; @Before public void setUp() throws Exception { // Sockets on some platforms can have large buffers that mean writes do not block when @@ -66,7 +65,7 @@ public final class ThreadInterruptTest { return serverSocket; } }); - client = clientTestingRule.client.newBuilder() + client = clientTestRule.client.newBuilder() .socketFactory(new DelegatingSocketFactory(SocketFactory.getDefault()) { @Override protected Socket configureSocket(Socket socket) throws IOException { diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http2/HttpOverHttp2Test.java b/okhttp-tests/src/test/java/okhttp3/internal/http2/HttpOverHttp2Test.java index 23e395b8f..b2952674d 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http2/HttpOverHttp2Test.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/http2/HttpOverHttp2Test.java @@ -40,7 +40,7 @@ import okhttp3.Headers; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; -import okhttp3.OkHttpClientTestingRule; +import okhttp3.OkHttpClientTestRule; import okhttp3.Protocol; import okhttp3.RecordingCookieJar; import okhttp3.RecordingHostnameVerifier; @@ -101,7 +101,7 @@ public final class HttpOverHttp2Test { @Rule public final TemporaryFolder tempDir = new TemporaryFolder(); @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final OkHttpClientTestingRule clientTestingRule = new OkHttpClientTestingRule(); + @Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule(); private OkHttpClient client; private Cache cache; @@ -117,13 +117,13 @@ public final class HttpOverHttp2Test { } private OkHttpClient buildH2PriorKnowledgeClient() { - return clientTestingRule.client.newBuilder() + return clientTestRule.client.newBuilder() .protocols(Arrays.asList(Protocol.H2_PRIOR_KNOWLEDGE)) .build(); } private OkHttpClient buildHttp2Client() { - return clientTestingRule.client.newBuilder() + return clientTestRule.client.newBuilder() .protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)) .sslSocketFactory( handshakeCertificates.sslSocketFactory(), handshakeCertificates.trustManager())