mirror of
https://github.com/square/okhttp.git
synced 2025-12-25 00:01:02 +03:00
Workaround native image params issue (#6401)
This commit is contained in:
@@ -21,6 +21,8 @@ import okhttp3.internal.publicsuffix.PublicSuffixDatabase
|
||||
import org.assertj.core.api.AssertionsForClassTypes.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource
|
||||
|
||||
class SampleTest {
|
||||
@JvmField @RegisterExtension val clientRule = OkHttpClientTestRule()
|
||||
@@ -56,4 +58,13 @@ class SampleTest {
|
||||
assertThat(it.available()).isGreaterThan(30000)
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(SampleTestProvider::class)
|
||||
fun testParams(mode: String) {
|
||||
}
|
||||
}
|
||||
|
||||
class SampleTestProvider: SimpleProvider() {
|
||||
override fun arguments() = listOf("A", "B")
|
||||
}
|
||||
|
||||
@@ -26,6 +26,21 @@ class TestRegistration : Feature {
|
||||
registerKnownTests(access)
|
||||
|
||||
registerJupiterClasses(access)
|
||||
|
||||
registerParamProvider(access, "okhttp3.SampleTestProvider")
|
||||
registerParamProvider(access, "okhttp3.internal.http.CancelModelParamProvider")
|
||||
registerParamProvider(access, "okhttp3.internal.cache.FileSystemParamProvider")
|
||||
registerParamProvider(access, "okhttp3.internal.http2.HttpOverHttp2Test\$ProtocolParamProvider")
|
||||
registerParamProvider(access, "okhttp3.internal.io.FileSystemParamProvider")
|
||||
}
|
||||
|
||||
private fun registerParamProvider(access: Feature.BeforeAnalysisAccess, provider: String) {
|
||||
val providerClass = access.findClassByName(provider)
|
||||
if (providerClass != null) {
|
||||
registerTest(access, providerClass)
|
||||
} else {
|
||||
println("Missing $provider")
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerJupiterClasses(access: Feature.BeforeAnalysisAccess) {
|
||||
@@ -74,5 +89,8 @@ class TestRegistration : Feature {
|
||||
java.declaredFields.forEach {
|
||||
RuntimeReflection.register(it)
|
||||
}
|
||||
java.methods.forEach {
|
||||
RuntimeReflection.register(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@ dependencies {
|
||||
api deps.conscrypt
|
||||
api deps.corretto
|
||||
api deps.openjsse
|
||||
|
||||
api deps.junit5Api
|
||||
api deps.junit5JupiterParams
|
||||
|
||||
compileOnly deps.jsr305
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Square, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider
|
||||
|
||||
abstract class SimpleProvider: ArgumentsProvider {
|
||||
override fun provideArguments(context: ExtensionContext) =
|
||||
arguments().map { Arguments.of(it) }.stream()
|
||||
|
||||
abstract fun arguments(): List<Any>
|
||||
}
|
||||
@@ -15,15 +15,6 @@
|
||||
*/
|
||||
package okhttp3.internal.cache
|
||||
|
||||
import java.io.Closeable
|
||||
import java.io.EOFException
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.Flushable
|
||||
import java.io.IOException
|
||||
import java.util.ArrayList
|
||||
import java.util.LinkedHashMap
|
||||
import java.util.NoSuchElementException
|
||||
import okhttp3.internal.assertThreadHoldsLock
|
||||
import okhttp3.internal.cache.DiskLruCache.Editor
|
||||
import okhttp3.internal.closeQuietly
|
||||
@@ -34,12 +25,11 @@ import okhttp3.internal.isCivilized
|
||||
import okhttp3.internal.okHttpName
|
||||
import okhttp3.internal.platform.Platform
|
||||
import okhttp3.internal.platform.Platform.Companion.WARN
|
||||
import okio.BufferedSink
|
||||
import okio.ForwardingSource
|
||||
import okio.Sink
|
||||
import okio.Source
|
||||
import okio.blackholeSink
|
||||
import okio.buffer
|
||||
import okio.*
|
||||
import java.io.*
|
||||
import java.io.EOFException
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* A cache that uses a bounded amount of space on a filesystem. Each cache entry has a string key
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ import okhttp3.Protocol.HTTP_1_1
|
||||
import okhttp3.RecordingEventListener
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.SimpleProvider
|
||||
import okhttp3.internal.http.CancelTest.CancelMode.CANCEL
|
||||
import okhttp3.internal.http.CancelTest.CancelMode.INTERRUPT
|
||||
import okhttp3.internal.http.CancelTest.ConnectionType.H2
|
||||
@@ -48,10 +49,11 @@ import okio.Buffer
|
||||
import okio.BufferedSink
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Timeout
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.MethodSource
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource
|
||||
import java.io.IOException
|
||||
import java.net.ServerSocket
|
||||
import java.net.Socket
|
||||
@@ -59,6 +61,7 @@ import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.net.ServerSocketFactory
|
||||
import javax.net.SocketFactory
|
||||
|
||||
@Timeout(30)
|
||||
class CancelTest {
|
||||
@JvmField @RegisterExtension val platform = PlatformRule()
|
||||
|
||||
@@ -132,7 +135,7 @@ class CancelTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("cancelModes")
|
||||
@ArgumentsSource(CancelModelParamProvider::class)
|
||||
fun cancelWritingRequestBody(mode: Pair<CancelMode, ConnectionType>) {
|
||||
setUp(mode)
|
||||
server.enqueue(MockResponse())
|
||||
@@ -167,7 +170,7 @@ class CancelTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("cancelModes")
|
||||
@ArgumentsSource(CancelModelParamProvider::class)
|
||||
fun cancelReadingResponseBody(mode: Pair<CancelMode, ConnectionType>) {
|
||||
setUp(mode)
|
||||
val responseBodySize = 8 * 1024 * 1024 // 8 MiB.
|
||||
@@ -200,7 +203,7 @@ class CancelTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("cancelModes")
|
||||
@ArgumentsSource(CancelModelParamProvider::class)
|
||||
fun cancelAndFollowup(mode: Pair<CancelMode, ConnectionType>) {
|
||||
setUp(mode)
|
||||
val responseBodySize = 8 * 1024 * 1024 // 8 MiB.
|
||||
@@ -296,11 +299,11 @@ class CancelTest {
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun cancelModes() =
|
||||
CancelMode.values().flatMap { c -> ConnectionType.values().map { x -> Pair(c, x) } }
|
||||
|
||||
// The size of the socket buffers in bytes.
|
||||
private const val SOCKET_BUFFER_SIZE = 256 * 1024
|
||||
}
|
||||
}
|
||||
|
||||
class CancelModelParamProvider: SimpleProvider() {
|
||||
override fun arguments() = CancelTest.CancelMode.values().flatMap { c -> CancelTest.ConnectionType.values().map { x -> Pair(c, x) } }
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.net.HttpURLConnection;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -60,6 +59,7 @@ import okhttp3.RecordingHostnameVerifier;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.SimpleProvider;
|
||||
import okhttp3.TestLogHandler;
|
||||
import okhttp3.TestUtil;
|
||||
import okhttp3.internal.DoubleInetAddressDns;
|
||||
@@ -79,8 +79,7 @@ import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Arrays.asList;
|
||||
@@ -103,9 +102,11 @@ public final class HttpOverHttp2Test {
|
||||
|
||||
private static final HandshakeCertificates handshakeCertificates = localhost();
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static Collection<Protocol> data() {
|
||||
return asList(Protocol.H2_PRIOR_KNOWLEDGE, Protocol.HTTP_2);
|
||||
public static class ProtocolParamProvider extends SimpleProvider {
|
||||
@Override
|
||||
public List<Object> arguments() {
|
||||
return asList(Protocol.H2_PRIOR_KNOWLEDGE, Protocol.HTTP_2);
|
||||
}
|
||||
}
|
||||
|
||||
@TempDir public File tempDir;
|
||||
@@ -158,7 +159,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void get(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -184,7 +185,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void get204Response(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -212,7 +213,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void head(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -239,7 +240,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void emptyResponse(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws IOException {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -255,7 +256,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void noDefaultContentLengthOnStreamingPost(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -286,7 +287,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void userSuppliedContentLengthHeader(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -322,7 +323,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void closeAfterFlush(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -360,7 +361,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void connectionReuse(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -388,7 +389,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void connectionWindowUpdateAfterCanceling(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -431,7 +432,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void connectionWindowUpdateOnClose(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -460,7 +461,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void concurrentRequestWithEmptyFlowControlWindow(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -498,7 +499,7 @@ public final class HttpOverHttp2Test {
|
||||
|
||||
/** https://github.com/square/okhttp/issues/373 */
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
@Disabled public void synchronousRequest(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -515,7 +516,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void gzippedResponseBody(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -532,7 +533,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void authenticate(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -562,7 +563,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void redirect(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -585,7 +586,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void readAfterLastByte(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -607,7 +608,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void readResponseHeaderTimeout(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -647,7 +648,7 @@ public final class HttpOverHttp2Test {
|
||||
* seconds. If our implementation is acting correctly, it will not throw, as it is progressing.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void readTimeoutMoreGranularThanBodySize(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -675,7 +676,7 @@ public final class HttpOverHttp2Test {
|
||||
* time.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void readTimeoutOnSlowConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -715,7 +716,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void connectionTimeout(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -754,7 +755,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void responsesAreCached(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws IOException {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -794,7 +795,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void conditionalCache(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws IOException {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -830,7 +831,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void responseCachedWithoutConsumingFullBody(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws IOException {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -861,7 +862,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void sendRequestCookies(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -888,7 +889,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void receiveResponseCookies(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -910,7 +911,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void cancelWithStreamNotCompleted(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -940,7 +941,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromOneRefusedStreamReusesConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -968,7 +969,7 @@ public final class HttpOverHttp2Test {
|
||||
* certain HTTP/2 errors. https://github.com/square/okhttp/issues/5547
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void noRecoveryFromTwoRefusedStreams(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -993,7 +994,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromOneInternalErrorRequiresNewConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1001,7 +1002,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromOneCancelRequiresNewConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1032,7 +1033,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromMultipleRefusedStreamsRequiresNewConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1064,7 +1065,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromCancelReusesConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1101,7 +1102,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromMultipleCancelReusesConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1197,7 +1198,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void noRecoveryFromRefusedStreamWithRetryDisabled(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1205,7 +1206,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void noRecoveryFromInternalErrorWithRetryDisabled(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1213,7 +1214,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void noRecoveryFromCancelWithRetryDisabled(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1243,7 +1244,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void recoverFromConnectionNoNewStreamsOnFollowUp(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1313,7 +1314,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void nonAsciiResponseHeader(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1332,7 +1333,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void serverSendsPushPromise_GET(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1365,7 +1366,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void serverSendsPushPromise_HEAD(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1397,7 +1398,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void noDataFramesSentWithNullRequestBody(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1421,7 +1422,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void emptyDataFrameSentWithEmptyBody(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1452,7 +1453,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void pingsTransmitted(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1488,7 +1489,7 @@ public final class HttpOverHttp2Test {
|
||||
|
||||
@Flaky
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void missingPongsFailsConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1533,7 +1534,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void streamTimeoutDegradesConnectionAfterNoPong(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1582,7 +1583,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void oneStreamTimeoutDoesNotBreakConnection(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1655,7 +1656,7 @@ public final class HttpOverHttp2Test {
|
||||
* confirm that the third concurrent request prepared a new connection.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void settingsLimitsMaxConcurrentStreams(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1707,7 +1708,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void connectionNotReusedAfterShutdown(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1737,7 +1738,7 @@ public final class HttpOverHttp2Test {
|
||||
* writing our request, we get a GOAWAY frame from the server.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void connectionShutdownAfterHealthCheck(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1782,7 +1783,7 @@ public final class HttpOverHttp2Test {
|
||||
|
||||
@Flaky
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void responseHeadersAfterGoaway(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1820,7 +1821,7 @@ public final class HttpOverHttp2Test {
|
||||
* <p>This test uses proxy tunnels to get a hook while a connection is being established.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void concurrentHttp2ConnectionsDeduplicated(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1906,7 +1907,7 @@ public final class HttpOverHttp2Test {
|
||||
|
||||
/** https://github.com/square/okhttp/issues/3103 */
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void domainFronting(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -1968,7 +1969,7 @@ public final class HttpOverHttp2Test {
|
||||
|
||||
/** https://github.com/square/okhttp/issues/4875 */
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void shutdownAfterLateCoalescing(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
@@ -2005,7 +2006,7 @@ public final class HttpOverHttp2Test {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
@ArgumentsSource(ProtocolParamProvider.class)
|
||||
public void cancelWhileWritingRequestBodySendsCancelToServer(
|
||||
Protocol protocol, MockWebServer mockWebServer) throws Exception {
|
||||
setUp(protocol, mockWebServer);
|
||||
|
||||
@@ -15,14 +15,24 @@
|
||||
*/
|
||||
package okhttp3.internal.io
|
||||
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import okhttp3.SimpleProvider
|
||||
import okhttp3.TestUtil
|
||||
import okio.buffer
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.MethodSource
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
class FileSystemParamProvider: SimpleProvider() {
|
||||
override fun arguments() = listOf(
|
||||
FileSystem.SYSTEM to TestUtil.windows,
|
||||
InMemoryFileSystem() to false,
|
||||
WindowsFileSystem(FileSystem.SYSTEM) to true,
|
||||
WindowsFileSystem(InMemoryFileSystem()) to true
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that our file system abstraction is consistent and sufficient for OkHttp's needs. We're
|
||||
@@ -34,23 +44,13 @@ class FileSystemTest {
|
||||
private lateinit var fileSystem: FileSystem
|
||||
private var windows: Boolean = false
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun parameters(): List<Pair<FileSystem, Boolean>> = listOf(
|
||||
FileSystem.SYSTEM to TestUtil.windows,
|
||||
InMemoryFileSystem() to false,
|
||||
WindowsFileSystem(FileSystem.SYSTEM) to true,
|
||||
WindowsFileSystem(InMemoryFileSystem()) to true
|
||||
)
|
||||
}
|
||||
|
||||
internal fun setUp(fileSystem: FileSystem, windows: Boolean) {
|
||||
this.fileSystem = fileSystem
|
||||
this.windows = windows
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `delete open for writing fails on Windows`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
@@ -64,7 +64,7 @@ class FileSystemTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `delete open for appending fails on Windows`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
@@ -79,7 +79,7 @@ class FileSystemTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `delete open for reading fails on Windows`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
@@ -94,7 +94,7 @@ class FileSystemTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `rename target exists succeeds on all platforms`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
@@ -107,7 +107,7 @@ class FileSystemTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `rename source is open fails on Windows`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
@@ -124,7 +124,7 @@ class FileSystemTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `rename target is open fails on Windows`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
@@ -141,7 +141,7 @@ class FileSystemTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
@ArgumentsSource(FileSystemParamProvider::class)
|
||||
fun `delete contents of parent of file open for reading fails on Windows`(
|
||||
parameters: Pair<FileSystem, Boolean>
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user