mirror of
https://github.com/square/okhttp.git
synced 2025-04-19 07:42:15 +03:00
Launcher for quick tests (#6437)
This commit is contained in:
parent
ec1d18d143
commit
083315a473
17
.junit.run/Not Slow.run.xml
Normal file
17
.junit.run/Not Slow.run.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Not Slow" type="JUnit" factoryName="JUnit" singleton="false">
|
||||
<useClassPathOnly />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="tags" />
|
||||
<option name="VM_PARAMETERS" value="-ea -Djunit.jupiter.extensions.autodetection.enabled=true" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="wholeProject" />
|
||||
</option>
|
||||
<tag value="!Slow & !Slowish & !Remote & !Android" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -60,6 +60,7 @@ import org.junit.jupiter.api.Assertions.fail
|
||||
import org.junit.jupiter.api.Assumptions.assumeTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
@ -88,6 +89,7 @@ import javax.net.ssl.X509TrustManager
|
||||
* Run with "./gradlew :android-test:connectedCheck" and make sure ANDROID_SDK_ROOT is set.
|
||||
*/
|
||||
@ExtendWith(MockWebServerExtension::class)
|
||||
@Tag("Slow")
|
||||
class OkHttpTest(val server: MockWebServer) {
|
||||
@Suppress("RedundantVisibilityModifier")
|
||||
@JvmField
|
||||
|
@ -22,12 +22,14 @@ import okhttp3.Request
|
||||
import okhttp3.tls.HandshakeCertificates
|
||||
import okhttp3.tls.decodeCertificatePem
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.security.cert.X509Certificate
|
||||
|
||||
/**
|
||||
* Test for new Let's Encrypt Root Certificate.
|
||||
*/
|
||||
@Tag("Remote")
|
||||
class LetsEncryptClientTest {
|
||||
@Test fun get() {
|
||||
// These tests wont actually run before Android 8.0 as per
|
||||
|
@ -44,6 +44,7 @@ import okhttp3.tls.HeldCertificate;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -63,6 +64,7 @@ import static org.junit.Assume.assumeFalse;
|
||||
|
||||
@SuppressWarnings({"ArraysAsListWithZeroOrOneArgument", "deprecation"})
|
||||
@Timeout(30)
|
||||
@Tag("Slow")
|
||||
public final class MockWebServerTest {
|
||||
@RegisterExtension public PlatformRule platform = new PlatformRule();
|
||||
|
||||
|
@ -43,6 +43,7 @@ import okhttp3.tls.HeldCertificate;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -60,6 +61,7 @@ import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||
|
||||
@SuppressWarnings({"ArraysAsListWithZeroOrOneArgument", "deprecation"})
|
||||
@Timeout(30)
|
||||
@Tag("Slow")
|
||||
public final class MockWebServerTest {
|
||||
@RegisterExtension public PlatformRule platform = new PlatformRule();
|
||||
|
||||
|
@ -28,8 +28,8 @@ class SampleTest {
|
||||
@JvmField @RegisterExtension val clientRule = OkHttpClientTestRule()
|
||||
|
||||
@Test
|
||||
fun failingTest() {
|
||||
assertThat("hello").isEqualTo("goodbye")
|
||||
fun passingTest() {
|
||||
assertThat("hello").isEqualTo("hello")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -36,6 +36,7 @@ import okhttp3.testing.PlatformRule;
|
||||
import okio.Buffer;
|
||||
import okio.ByteString;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@ExtendWith(MockWebServerExtension.class)
|
||||
@Tag("Slowish")
|
||||
public class DnsOverHttpsTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
|
||||
|
@ -28,6 +28,7 @@ import okhttp3.sse.EventSources;
|
||||
import okhttp3.testing.PlatformRule;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -35,6 +36,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockWebServerExtension.class)
|
||||
@Tag("Slowish")
|
||||
public final class EventSourceHttpTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
|
||||
|
@ -49,6 +49,7 @@ import okio.GzipSink;
|
||||
import okio.Okio;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@ -59,6 +60,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slow")
|
||||
public final class CacheTest {
|
||||
private static final HostnameVerifier NULL_HOSTNAME_VERIFIER = (name, session) -> true;
|
||||
|
||||
|
@ -83,6 +83,7 @@ import okio.Okio;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -2215,6 +2216,7 @@ public final class CallTest {
|
||||
assertThat(server.takeRequest().getSequenceNumber()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void follow20Redirects() throws Exception {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
server.enqueue(new MockResponse()
|
||||
@ -2229,6 +2231,7 @@ public final class CallTest {
|
||||
.assertBody("Success!");
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void follow20Redirects_Async() throws Exception {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
server.enqueue(new MockResponse()
|
||||
@ -2245,6 +2248,7 @@ public final class CallTest {
|
||||
.assertBody("Success!");
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void doesNotFollow21Redirects() throws Exception {
|
||||
for (int i = 0; i < 21; i++) {
|
||||
server.enqueue(new MockResponse()
|
||||
@ -2261,6 +2265,7 @@ public final class CallTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void doesNotFollow21Redirects_Async() throws Exception {
|
||||
for (int i = 0; i < 21; i++) {
|
||||
server.enqueue(new MockResponse()
|
||||
@ -2323,10 +2328,12 @@ public final class CallTest {
|
||||
assertThat(server.getRequestCount()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Tag("Slowish")
|
||||
@Test public void cancelDuringHttpConnect() throws Exception {
|
||||
cancelDuringConnect("http");
|
||||
}
|
||||
|
||||
@Tag("Slowish")
|
||||
@Test public void cancelDuringHttpsConnect() throws Exception {
|
||||
cancelDuringConnect("https");
|
||||
}
|
||||
@ -2768,6 +2775,7 @@ public final class CallTest {
|
||||
expect100ContinueEmptyRequestBody();
|
||||
}
|
||||
|
||||
@Tag("Slowish")
|
||||
@Test public void expect100ContinueTimesOutWithoutContinue() throws Exception {
|
||||
server.enqueue(new MockResponse()
|
||||
.setSocketPolicy(SocketPolicy.NO_RESPONSE));
|
||||
@ -2793,6 +2801,7 @@ public final class CallTest {
|
||||
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Tag("Slowish")
|
||||
@Test public void expect100ContinueTimesOutWithoutContinue_HTTP2() throws Exception {
|
||||
enableProtocol(Protocol.HTTP_2);
|
||||
expect100ContinueTimesOutWithoutContinue();
|
||||
@ -2820,6 +2829,7 @@ public final class CallTest {
|
||||
serverRespondsWithUnsolicited100Continue();
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void serverRespondsWith100ContinueOnly() throws Exception {
|
||||
client = client.newBuilder()
|
||||
.readTimeout(Duration.ofSeconds(1))
|
||||
@ -2844,6 +2854,7 @@ public final class CallTest {
|
||||
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("abc");
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void serverRespondsWith100ContinueOnly_HTTP2() throws Exception {
|
||||
enableProtocol(Protocol.HTTP_2);
|
||||
serverRespondsWith100ContinueOnly();
|
||||
@ -2867,11 +2878,13 @@ public final class CallTest {
|
||||
assertThat(server.takeRequest().getSequenceNumber()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void successfulExpectContinuePermitsConnectionReuseWithHttp2() throws Exception {
|
||||
enableProtocol(Protocol.HTTP_2);
|
||||
successfulExpectContinuePermitsConnectionReuse();
|
||||
}
|
||||
|
||||
@Tag("Slow")
|
||||
@Test public void unsuccessfulExpectContinuePreventsConnectionReuse() throws Exception {
|
||||
server.enqueue(new MockResponse());
|
||||
server.enqueue(new MockResponse());
|
||||
@ -3604,6 +3617,7 @@ public final class CallTest {
|
||||
+ " Did you forget to close a response body?");
|
||||
}
|
||||
|
||||
@Tag("Slowish")
|
||||
@Test public void asyncLeakedResponseBodyLogsStackTrace() throws Exception {
|
||||
server.enqueue(new MockResponse()
|
||||
.setBody("This gets leaked."));
|
||||
|
@ -34,6 +34,7 @@ import okhttp3.testing.PlatformRule;
|
||||
import okhttp3.tls.HandshakeCertificates;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@ -41,6 +42,7 @@ import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slowish")
|
||||
public final class ConnectionCoalescingTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
@RegisterExtension public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
@ -25,6 +25,7 @@ import mockwebserver3.SocketPolicy;
|
||||
import okhttp3.testing.PlatformRule;
|
||||
import okhttp3.tls.HandshakeCertificates;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -36,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Timeout(30)
|
||||
@Tag("Slowish")
|
||||
public final class ConnectionReuseTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
@RegisterExtension public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
@ -5,6 +5,7 @@ import java.io.InterruptedIOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@ -12,6 +13,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slowish")
|
||||
public final class DispatcherTest {
|
||||
@RegisterExtension public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
||||
|
@ -37,6 +37,7 @@ import okio.BufferedSource;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -48,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Timeout(30)
|
||||
@Tag("Slowish")
|
||||
public final class DuplexTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
@RegisterExtension public OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
@ -69,6 +69,7 @@ import org.hamcrest.Matcher;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -83,6 +84,7 @@ import static org.junit.Assume.assumeThat;
|
||||
|
||||
@Flaky // STDOUT logging enabled for test
|
||||
@Timeout(30)
|
||||
@Tag("Slow")
|
||||
public final class EventListenerTest {
|
||||
public static final Matcher<Response> anyResponse = CoreMatchers.any(Response.class);
|
||||
|
||||
|
@ -41,12 +41,14 @@ import okio.Okio;
|
||||
import okio.Sink;
|
||||
import okio.Source;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slow")
|
||||
public final class InterceptorTest {
|
||||
@RegisterExtension public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
||||
|
@ -76,6 +76,8 @@ import okio.BufferedSink
|
||||
import okio.BufferedSource
|
||||
import okio.ByteString
|
||||
import okio.Timeout
|
||||
import org.junit.jupiter.api.Assumptions.assumeFalse
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@ -95,6 +97,11 @@ import org.junit.jupiter.api.Test
|
||||
)
|
||||
@Disabled
|
||||
class KotlinSourceModernTest {
|
||||
@BeforeEach
|
||||
fun disabled() {
|
||||
assumeFalse(true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun address() {
|
||||
val address: Address = newAddress()
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import java.io.EOFException
|
||||
import java.net.ProtocolException
|
||||
import okhttp3.Headers.Companion.headersOf
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
@ -24,8 +22,12 @@ import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
import okio.Buffer
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Assertions.fail
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.io.EOFException
|
||||
import java.net.ProtocolException
|
||||
|
||||
@Tag("Slowish")
|
||||
class MultipartReaderTest {
|
||||
@Test fun `parse multipart`() {
|
||||
val multipart = """
|
||||
@ -47,23 +49,27 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
assertThat(parts.boundary).isEqualTo("simple boundary")
|
||||
|
||||
val partAbc = parts.nextPart()!!
|
||||
assertThat(partAbc.headers).isEqualTo(headersOf(
|
||||
assertThat(partAbc.headers).isEqualTo(
|
||||
headersOf(
|
||||
"Content-Type", "text/plain; charset=utf-8",
|
||||
"Content-ID", "abc"
|
||||
))
|
||||
)
|
||||
)
|
||||
assertThat(partAbc.body.readUtf8()).isEqualTo("abcd\r\nefgh")
|
||||
|
||||
val partIjk = parts.nextPart()!!
|
||||
assertThat(partIjk.headers).isEqualTo(headersOf(
|
||||
assertThat(partIjk.headers).isEqualTo(
|
||||
headersOf(
|
||||
"Content-Type", "text/plain; charset=utf-8",
|
||||
"Content-ID", "ijk"
|
||||
))
|
||||
)
|
||||
)
|
||||
assertThat(partIjk.body.readUtf8()).isEqualTo("ijkl\r\nmnop\r\n")
|
||||
|
||||
assertThat(parts.nextPart()).isNull()
|
||||
@ -79,7 +85,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val responseBody = multipart.toResponseBody(
|
||||
"application/multipart; boundary=\"simple boundary\"".toMediaType())
|
||||
"application/multipart; boundary=\"simple boundary\"".toMediaType()
|
||||
)
|
||||
|
||||
val parts = MultipartReader(responseBody)
|
||||
assertThat(parts.boundary).isEqualTo("simple boundary")
|
||||
@ -100,8 +107,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -126,8 +133,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
try {
|
||||
@ -151,8 +158,8 @@ class MultipartReaderTest {
|
||||
.replace(Regex("(?m)abcd\r\n"), "abcd\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -174,8 +181,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -199,8 +206,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
parts.nextPart()!!
|
||||
@ -225,8 +232,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val partAbc = parts.nextPart()!!
|
||||
@ -253,8 +260,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -270,8 +277,8 @@ class MultipartReaderTest {
|
||||
|
||||
@Test fun `cannot call nextPart after calling close`() {
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer()
|
||||
boundary = "simple boundary",
|
||||
source = Buffer()
|
||||
)
|
||||
|
||||
parts.close()
|
||||
@ -291,8 +298,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
try {
|
||||
@ -315,8 +322,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -337,8 +344,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -359,8 +366,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -381,8 +388,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val part = parts.nextPart()!!
|
||||
@ -400,8 +407,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
try {
|
||||
@ -422,8 +429,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
parts.nextPart()
|
||||
@ -451,8 +458,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "-",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "-",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
val partAbc = parts.nextPart()!!
|
||||
@ -479,8 +486,8 @@ class MultipartReaderTest {
|
||||
.replace("\n", "\r\n")
|
||||
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
boundary = "simple boundary",
|
||||
source = Buffer().writeUtf8(multipart)
|
||||
)
|
||||
|
||||
assertThat(parts.nextPart()).isNotNull()
|
||||
@ -490,8 +497,8 @@ class MultipartReaderTest {
|
||||
|
||||
@Test fun `empty source`() {
|
||||
val parts = MultipartReader(
|
||||
boundary = "simple boundary",
|
||||
source = Buffer()
|
||||
boundary = "simple boundary",
|
||||
source = Buffer()
|
||||
)
|
||||
|
||||
try {
|
||||
@ -516,24 +523,30 @@ class MultipartReaderTest {
|
||||
val reader = MultipartReader(bodyContent, "boundary")
|
||||
|
||||
val quickPart = reader.nextPart()!!
|
||||
assertThat(quickPart.headers).isEqualTo(headersOf(
|
||||
assertThat(quickPart.headers).isEqualTo(
|
||||
headersOf(
|
||||
"Content-Type", "text/plain; charset=utf-8",
|
||||
"Content-Length", "5"
|
||||
))
|
||||
)
|
||||
)
|
||||
assertThat(quickPart.body.readUtf8()).isEqualTo("Quick")
|
||||
|
||||
val brownPart = reader.nextPart()!!
|
||||
assertThat(brownPart.headers).isEqualTo(headersOf(
|
||||
assertThat(brownPart.headers).isEqualTo(
|
||||
headersOf(
|
||||
"Content-Disposition", "form-data; name=\"color\"",
|
||||
"Content-Length", "5"
|
||||
))
|
||||
)
|
||||
)
|
||||
assertThat(brownPart.body.readUtf8()).isEqualTo("Brown")
|
||||
|
||||
val foxPart = reader.nextPart()!!
|
||||
assertThat(foxPart.headers).isEqualTo(headersOf(
|
||||
assertThat(foxPart.headers).isEqualTo(
|
||||
headersOf(
|
||||
"Content-Disposition", "form-data; name=\"animal\"; filename=\"fox.txt\"",
|
||||
"Content-Length", "3"
|
||||
))
|
||||
)
|
||||
)
|
||||
assertThat(foxPart.body.readUtf8()).isEqualTo("Fox")
|
||||
|
||||
assertThat(reader.nextPart()).isNull()
|
||||
|
@ -27,12 +27,14 @@ import okio.BufferedSink
|
||||
import okio.IOException
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.Timeout
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
import org.junit.jupiter.api.fail
|
||||
|
||||
@Timeout(30)
|
||||
@Tag("Slowish")
|
||||
class ServerTruncatesRequestTest(
|
||||
val server: MockWebServer
|
||||
) {
|
||||
@ -63,14 +65,16 @@ class ServerTruncatesRequestTest(
|
||||
|
||||
private fun serverTruncatesRequestOnLongPost(https: Boolean) {
|
||||
server.enqueue(MockResponse()
|
||||
.setSocketPolicy(SocketPolicy.DO_NOT_READ_REQUEST_BODY)
|
||||
.setBody("abc")
|
||||
.apply { this.http2ErrorCode = ErrorCode.NO_ERROR.httpCode })
|
||||
.setSocketPolicy(SocketPolicy.DO_NOT_READ_REQUEST_BODY)
|
||||
.setBody("abc")
|
||||
.apply { this.http2ErrorCode = ErrorCode.NO_ERROR.httpCode })
|
||||
|
||||
val call = client.newCall(Request.Builder()
|
||||
val call = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.post(SlowRequestBody)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
|
||||
call.execute().use { response ->
|
||||
assertThat(response.body!!.string()).isEqualTo("abc")
|
||||
@ -115,16 +119,18 @@ class ServerTruncatesRequestTest(
|
||||
enableProtocol(Protocol.HTTP_2)
|
||||
|
||||
server.enqueue(MockResponse()
|
||||
.setSocketPolicy(SocketPolicy.DO_NOT_READ_REQUEST_BODY)
|
||||
.setBody("abc")
|
||||
.apply { this.http2ErrorCode = ErrorCode.NO_ERROR.httpCode })
|
||||
.setSocketPolicy(SocketPolicy.DO_NOT_READ_REQUEST_BODY)
|
||||
.setBody("abc")
|
||||
.apply { this.http2ErrorCode = ErrorCode.NO_ERROR.httpCode })
|
||||
|
||||
val requestBody = AsyncRequestBody()
|
||||
|
||||
val call = client.newCall(Request.Builder()
|
||||
val call = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.post(requestBody)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
|
||||
call.execute().use { response ->
|
||||
assertThat(response.body!!.string()).isEqualTo("abc")
|
||||
@ -171,10 +177,12 @@ class ServerTruncatesRequestTest(
|
||||
|
||||
server.enqueue(mockResponse)
|
||||
|
||||
val call = client.newCall(Request.Builder()
|
||||
val call = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.post(SlowRequestBody)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
|
||||
call.execute().use { response ->
|
||||
assertThat(response.body!!.string()).isEqualTo("abc")
|
||||
@ -193,10 +201,12 @@ class ServerTruncatesRequestTest(
|
||||
}
|
||||
}
|
||||
|
||||
val callA = client.newCall(Request.Builder()
|
||||
val callA = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.post(requestBody)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
|
||||
try {
|
||||
callA.execute()
|
||||
@ -209,9 +219,11 @@ class ServerTruncatesRequestTest(
|
||||
|
||||
// Confirm that the connection pool was not corrupted by making another call. This doesn't use
|
||||
// makeSimpleCall() because it uses the MockResponse enqueued above.
|
||||
val callB = client.newCall(Request.Builder()
|
||||
val callB = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
callB.execute().use { response ->
|
||||
assertThat(response.body!!.string()).isEqualTo("abc")
|
||||
}
|
||||
@ -219,9 +231,11 @@ class ServerTruncatesRequestTest(
|
||||
|
||||
private fun makeSimpleCall() {
|
||||
server.enqueue(MockResponse().setBody("healthy"))
|
||||
val callB = client.newCall(Request.Builder()
|
||||
val callB = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
callB.execute().use { response ->
|
||||
assertThat(response.body!!.string()).isEqualTo("healthy")
|
||||
}
|
||||
@ -238,8 +252,8 @@ class ServerTruncatesRequestTest(
|
||||
private fun enableTls() {
|
||||
client = client.newBuilder()
|
||||
.sslSocketFactory(
|
||||
handshakeCertificates.sslSocketFactory(),
|
||||
handshakeCertificates.trustManager
|
||||
handshakeCertificates.sslSocketFactory(),
|
||||
handshakeCertificates.trustManager
|
||||
)
|
||||
.hostnameVerifier(RecordingHostnameVerifier())
|
||||
.build()
|
||||
|
@ -81,6 +81,7 @@ import okio.Utf8;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
@ -110,6 +111,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/** Android's URLConnectionTest, ported to exercise OkHttp's Call API. */
|
||||
@Tag("Slow")
|
||||
public final class URLConnectionTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
@RegisterExtension public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
@ -27,6 +27,7 @@ import mockwebserver3.MockWebServer;
|
||||
import okhttp3.testing.Flaky;
|
||||
import okio.BufferedSink;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -35,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Timeout(30)
|
||||
@Tag("Slow")
|
||||
public final class WholeOperationTimeoutTest {
|
||||
/** A large response body. Smaller bodies might successfully read after the socket is closed! */
|
||||
private static final String BIG_ENOUGH_BODY = TestUtil.repeat('a', 64 * 1024);
|
||||
|
@ -29,6 +29,7 @@ import okio.buffer
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Timeout
|
||||
import org.junit.jupiter.api.fail
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
@ -49,6 +50,7 @@ class FileSystemParamProvider: SimpleProvider() {
|
||||
}
|
||||
|
||||
@Timeout(60)
|
||||
@Tag("Slow")
|
||||
class DiskLruCacheTest {
|
||||
private lateinit var fileSystem: FaultyFileSystem
|
||||
private var windows: Boolean = false
|
||||
@ -492,7 +494,7 @@ class DiskLruCacheTest {
|
||||
writeFile(getCleanFile("k1", 1), "B")
|
||||
fileSystem.sink(journalFile).buffer().use {
|
||||
it.writeUtf8(
|
||||
"""
|
||||
"""
|
||||
|${DiskLruCache.MAGIC}
|
||||
|${DiskLruCache.VERSION_1}
|
||||
|100
|
||||
@ -1058,7 +1060,7 @@ class DiskLruCacheTest {
|
||||
|
||||
// Cause the rebuild action to fail.
|
||||
fileSystem.setFaultyRename(
|
||||
File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true
|
||||
File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true
|
||||
)
|
||||
taskFaker.runNextTask()
|
||||
|
||||
@ -1959,7 +1961,8 @@ class DiskLruCacheTest {
|
||||
creator.commit()
|
||||
val snapshotAfterCommit = cache.snapshots()
|
||||
assertThat(snapshotAfterCommit.hasNext()).withFailMessage(
|
||||
"Entry has been removed during creation.").isTrue()
|
||||
"Entry has been removed during creation."
|
||||
).isTrue()
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ -2158,13 +2161,14 @@ class DiskLruCacheTest {
|
||||
|
||||
private fun assertJournalEquals(vararg expectedBodyLines: String) {
|
||||
assertThat(readJournalLines()).isEqualTo(
|
||||
listOf(DiskLruCache.MAGIC, DiskLruCache.VERSION_1, "100", "2", "") + expectedBodyLines)
|
||||
listOf(DiskLruCache.MAGIC, DiskLruCache.VERSION_1, "100", "2", "") + expectedBodyLines
|
||||
)
|
||||
}
|
||||
|
||||
private fun createJournal(vararg bodyLines: String) {
|
||||
createJournalWithHeader(
|
||||
DiskLruCache.MAGIC,
|
||||
DiskLruCache.VERSION_1, "100", "2", "", *bodyLines
|
||||
DiskLruCache.MAGIC,
|
||||
DiskLruCache.VERSION_1, "100", "2", "", *bodyLines
|
||||
)
|
||||
}
|
||||
|
||||
@ -2177,7 +2181,8 @@ class DiskLruCacheTest {
|
||||
vararg bodyLines: String
|
||||
) {
|
||||
fileSystem.sink(journalFile).buffer().use { sink ->
|
||||
sink.writeUtf8("""
|
||||
sink.writeUtf8(
|
||||
"""
|
||||
|$magic
|
||||
|$version
|
||||
|$appVersion
|
||||
|
@ -30,12 +30,14 @@ import okio.Pipe;
|
||||
import okio.Source;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slowish")
|
||||
public final class RelayTest {
|
||||
@TempDir File tempDir;
|
||||
private ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.data.Offset
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
@ -31,6 +32,7 @@ import org.junit.jupiter.api.Test
|
||||
* This test is doing real sleeping with tolerances of 250 ms. Hopefully that's enough for even the
|
||||
* busiest of CI servers.
|
||||
*/
|
||||
@Tag("Slowish")
|
||||
class TaskRunnerRealBackendTest {
|
||||
private val log = LinkedBlockingDeque<String>()
|
||||
|
||||
|
@ -49,6 +49,7 @@ 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.Tag
|
||||
import org.junit.jupiter.api.Timeout
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
import org.junit.jupiter.api.fail
|
||||
@ -62,6 +63,7 @@ import javax.net.ServerSocketFactory
|
||||
import javax.net.SocketFactory
|
||||
|
||||
@Timeout(30)
|
||||
@Tag("Slow")
|
||||
class CancelTest {
|
||||
@JvmField @RegisterExtension val platform = PlatformRule()
|
||||
|
||||
@ -125,7 +127,9 @@ class CancelTest {
|
||||
return socket
|
||||
}
|
||||
})
|
||||
.sslSocketFactory(handshakeCertificates.sslSocketFactory(), handshakeCertificates.trustManager)
|
||||
.sslSocketFactory(
|
||||
handshakeCertificates.sslSocketFactory(), handshakeCertificates.trustManager
|
||||
)
|
||||
.eventListener(listener)
|
||||
.apply {
|
||||
if (connectionType == HTTPS) { protocols(listOf(HTTP_1_1)) }
|
||||
@ -140,25 +144,25 @@ class CancelTest {
|
||||
setUp(mode)
|
||||
server.enqueue(MockResponse())
|
||||
val call = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.post(object : RequestBody() {
|
||||
override fun contentType(): MediaType? {
|
||||
return null
|
||||
}
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.post(object : RequestBody() {
|
||||
override fun contentType(): MediaType? {
|
||||
return null
|
||||
}
|
||||
|
||||
@Throws(
|
||||
IOException::class
|
||||
) override fun writeTo(sink: BufferedSink) {
|
||||
for (i in 0..9) {
|
||||
sink.writeByte(0)
|
||||
sink.flush()
|
||||
sleep(100)
|
||||
}
|
||||
fail("Expected connection to be closed")
|
||||
}
|
||||
})
|
||||
.build()
|
||||
@Throws(
|
||||
IOException::class
|
||||
) override fun writeTo(sink: BufferedSink) {
|
||||
for (i in 0..9) {
|
||||
sink.writeByte(0)
|
||||
sink.flush()
|
||||
sleep(100)
|
||||
}
|
||||
fail("Expected connection to be closed")
|
||||
}
|
||||
})
|
||||
.build()
|
||||
)
|
||||
cancelLater(call, 500)
|
||||
try {
|
||||
@ -175,17 +179,17 @@ class CancelTest {
|
||||
setUp(mode)
|
||||
val responseBodySize = 8 * 1024 * 1024 // 8 MiB.
|
||||
server.enqueue(
|
||||
MockResponse()
|
||||
.setBody(
|
||||
Buffer()
|
||||
.write(ByteArray(responseBodySize))
|
||||
)
|
||||
.throttleBody(64 * 1024, 125, MILLISECONDS)
|
||||
MockResponse()
|
||||
.setBody(
|
||||
Buffer()
|
||||
.write(ByteArray(responseBodySize))
|
||||
)
|
||||
.throttleBody(64 * 1024, 125, MILLISECONDS)
|
||||
) // 500 Kbps
|
||||
val call = client.newCall(
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.build()
|
||||
Request.Builder()
|
||||
.url(server.url("/"))
|
||||
.build()
|
||||
)
|
||||
val response = call.execute()
|
||||
cancelLater(call, 500)
|
||||
@ -208,12 +212,12 @@ class CancelTest {
|
||||
setUp(mode)
|
||||
val responseBodySize = 8 * 1024 * 1024 // 8 MiB.
|
||||
server.enqueue(
|
||||
MockResponse()
|
||||
.setBody(
|
||||
Buffer()
|
||||
.write(ByteArray(responseBodySize))
|
||||
)
|
||||
.throttleBody(64 * 1024, 125, MILLISECONDS)
|
||||
MockResponse()
|
||||
.setBody(
|
||||
Buffer()
|
||||
.write(ByteArray(responseBodySize))
|
||||
)
|
||||
.throttleBody(64 * 1024, 125, MILLISECONDS)
|
||||
) // 500 Kbps
|
||||
server.enqueue(MockResponse().apply {
|
||||
setResponseCode(200)
|
||||
@ -305,5 +309,7 @@ class CancelTest {
|
||||
}
|
||||
|
||||
class CancelModelParamProvider: SimpleProvider() {
|
||||
override fun arguments() = CancelTest.CancelMode.values().flatMap { c -> CancelTest.ConnectionType.values().map { x -> Pair(c, x) } }
|
||||
override fun arguments() = CancelTest.CancelMode.values().flatMap { c -> CancelTest.ConnectionType.values().map { x -> Pair(
|
||||
c, x
|
||||
) } }
|
||||
}
|
||||
|
@ -39,11 +39,13 @@ import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slowish")
|
||||
public final class ThreadInterruptTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
@RegisterExtension public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
|
||||
|
@ -39,6 +39,7 @@ import okio.Okio;
|
||||
import okio.Sink;
|
||||
import okio.Source;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
|
||||
@ -64,6 +65,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Timeout(5)
|
||||
@Tag("Slow")
|
||||
public final class Http2ConnectionTest {
|
||||
private final MockHttp2Peer peer = new MockHttp2Peer();
|
||||
|
||||
|
@ -75,6 +75,7 @@ import okio.GzipSink;
|
||||
import okio.Okio;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
@ -96,6 +97,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
/** Test how HTTP/2 interacts with HTTP features. */
|
||||
@Timeout(60)
|
||||
@Flaky
|
||||
@Tag("Slow")
|
||||
public final class HttpOverHttp2Test {
|
||||
// Flaky https://github.com/square/okhttp/issues/4632
|
||||
// Flaky https://github.com/square/okhttp/issues/4633
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package okhttp3.internal.http2;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static okhttp3.internal.http2.Settings.DEFAULT_INITIAL_WINDOW_SIZE;
|
||||
import static okhttp3.internal.http2.Settings.MAX_CONCURRENT_STREAMS;
|
||||
|
@ -47,6 +47,7 @@ import okhttp3.testing.PlatformVersion;
|
||||
import okhttp3.tls.HandshakeCertificates;
|
||||
import okhttp3.tls.HeldCertificate;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@ -58,6 +59,7 @@ import static okhttp3.tls.internal.TlsUtil.newTrustManager;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slowish")
|
||||
@ExtendWith(MockWebServerExtension.class)
|
||||
public final class ClientAuthTest {
|
||||
@RegisterExtension public final PlatformRule platform = new PlatformRule();
|
||||
|
@ -33,6 +33,7 @@ import okio.Pipe;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static okhttp3.internal.ws.RealWebSocket.DEFAULT_MINIMUM_DEFLATE_SIZE;
|
||||
@ -40,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Tag("Slow")
|
||||
public final class RealWebSocketTest {
|
||||
// NOTE: Fields are named 'client' and 'server' for cognitive simplicity. This differentiation has
|
||||
// zero effect on the behavior of the WebSocket API which is why tests are only written once
|
||||
|
@ -51,6 +51,7 @@ import okio.ByteString;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@ -62,6 +63,7 @@ import static org.assertj.core.data.Offset.offset;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Flaky
|
||||
@Tag("Slow")
|
||||
public final class WebSocketHttpTest {
|
||||
// Flaky https://github.com/square/okhttp/issues/4515
|
||||
// Flaky https://github.com/square/okhttp/issues/4953
|
||||
|
@ -32,8 +32,10 @@ import java.util.stream.Collectors;
|
||||
import okio.BufferedSource;
|
||||
import okio.Okio;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Tag("Slow")
|
||||
public final class OsgiTest {
|
||||
/** Each is the Bundle-SymbolicName of an OkHttp module's OSGi configuration. */
|
||||
private static final List<String> REQUIRED_BUNDLES = Arrays.asList(
|
||||
|
@ -16,6 +16,7 @@
|
||||
package okhttp3
|
||||
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource
|
||||
import java.io.File
|
||||
@ -50,6 +51,7 @@ internal class MainTestProvider : SimpleProvider() {
|
||||
}
|
||||
|
||||
@Disabled("Don't run by default")
|
||||
@Tag("Slow")
|
||||
class AllMainsTest {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(MainTestProvider::class)
|
||||
|
Loading…
x
Reference in New Issue
Block a user