Skip to content

Commit

Permalink
Launcher for quick tests (#6437)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored Nov 21, 2020
1 parent ec1d18d commit 083315a
Show file tree
Hide file tree
Showing 34 changed files with 242 additions and 116 deletions.
17 changes: 17 additions & 0 deletions .junit.run/Not Slow.run.xml
Original file line number Diff line number Diff line change
@@ -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 &amp; !Slowish &amp; !Remote &amp; !Android" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
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;
Expand All @@ -63,6 +64,7 @@

@SuppressWarnings({"ArraysAsListWithZeroOrOneArgument", "deprecation"})
@Timeout(30)
@Tag("Slow")
public final class MockWebServerTest {
@RegisterExtension public PlatformRule platform = new PlatformRule();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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;
Expand All @@ -60,6 +61,7 @@

@SuppressWarnings({"ArraysAsListWithZeroOrOneArgument", "deprecation"})
@Timeout(30)
@Tag("Slow")
public final class MockWebServerTest {
@RegisterExtension public PlatformRule platform = new PlatformRule();

Expand Down
4 changes: 2 additions & 2 deletions native-image-tests/src/main/kotlin/okhttp3/SampleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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;
Expand All @@ -46,6 +47,7 @@
import static org.junit.jupiter.api.Assertions.fail;

@ExtendWith(MockWebServerExtension.class)
@Tag("Slowish")
public class DnsOverHttpsTest {
@RegisterExtension public final PlatformRule platform = new PlatformRule();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
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;

import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(MockWebServerExtension.class)
@Tag("Slowish")
public final class EventSourceHttpTest {
@RegisterExtension public final PlatformRule platform = new PlatformRule();

Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/CacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
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;

Expand All @@ -59,6 +60,7 @@
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;

Expand Down
14 changes: 14 additions & 0 deletions okhttp/src/test/java/okhttp3/CallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
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;
Expand Down Expand Up @@ -2215,6 +2216,7 @@ public void interceptorCallsProceedWithoutClosingPriorResponse() throws Exceptio
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()
Expand All @@ -2229,6 +2231,7 @@ public void interceptorCallsProceedWithoutClosingPriorResponse() throws Exceptio
.assertBody("Success!");
}

@Tag("Slow")
@Test public void follow20Redirects_Async() throws Exception {
for (int i = 0; i < 20; i++) {
server.enqueue(new MockResponse()
Expand All @@ -2245,6 +2248,7 @@ public void interceptorCallsProceedWithoutClosingPriorResponse() throws Exceptio
.assertBody("Success!");
}

@Tag("Slow")
@Test public void doesNotFollow21Redirects() throws Exception {
for (int i = 0; i < 21; i++) {
server.enqueue(new MockResponse()
Expand All @@ -2261,6 +2265,7 @@ public void interceptorCallsProceedWithoutClosingPriorResponse() throws Exceptio
}
}

@Tag("Slow")
@Test public void doesNotFollow21Redirects_Async() throws Exception {
for (int i = 0; i < 21; i++) {
server.enqueue(new MockResponse()
Expand Down Expand Up @@ -2323,10 +2328,12 @@ private String stringFill(char fillChar, int length) {
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");
}
Expand Down Expand Up @@ -2768,6 +2775,7 @@ public void cancelWhileRequestHeadersAreSent_HTTP_2() throws Exception {
expect100ContinueEmptyRequestBody();
}

@Tag("Slowish")
@Test public void expect100ContinueTimesOutWithoutContinue() throws Exception {
server.enqueue(new MockResponse()
.setSocketPolicy(SocketPolicy.NO_RESPONSE));
Expand All @@ -2793,6 +2801,7 @@ public void cancelWhileRequestHeadersAreSent_HTTP_2() throws Exception {
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("");
}

@Tag("Slowish")
@Test public void expect100ContinueTimesOutWithoutContinue_HTTP2() throws Exception {
enableProtocol(Protocol.HTTP_2);
expect100ContinueTimesOutWithoutContinue();
Expand Down Expand Up @@ -2820,6 +2829,7 @@ public void cancelWhileRequestHeadersAreSent_HTTP_2() throws Exception {
serverRespondsWithUnsolicited100Continue();
}

@Tag("Slow")
@Test public void serverRespondsWith100ContinueOnly() throws Exception {
client = client.newBuilder()
.readTimeout(Duration.ofSeconds(1))
Expand All @@ -2844,6 +2854,7 @@ public void cancelWhileRequestHeadersAreSent_HTTP_2() throws Exception {
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("abc");
}

@Tag("Slow")
@Test public void serverRespondsWith100ContinueOnly_HTTP2() throws Exception {
enableProtocol(Protocol.HTTP_2);
serverRespondsWith100ContinueOnly();
Expand All @@ -2867,11 +2878,13 @@ public void cancelWhileRequestHeadersAreSent_HTTP_2() throws Exception {
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());
Expand Down Expand Up @@ -3604,6 +3617,7 @@ private RequestBody requestBody(final boolean chunked, final long size, final in
+ " Did you forget to close a response body?");
}

@Tag("Slowish")
@Test public void asyncLeakedResponseBodyLogsStackTrace() throws Exception {
server.enqueue(new MockResponse()
.setBody("This gets leaked."));
Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/ConnectionCoalescingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
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;

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();
Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/ConnectionReuseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand All @@ -36,6 +37,7 @@
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();
Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/DispatcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
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;

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();

Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/DuplexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand All @@ -48,6 +49,7 @@
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();
Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/EventListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
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;
Expand All @@ -83,6 +84,7 @@

@Flaky // STDOUT logging enabled for test
@Timeout(30)
@Tag("Slow")
public final class EventListenerTest {
public static final Matcher<Response> anyResponse = CoreMatchers.any(Response.class);

Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/test/java/okhttp3/InterceptorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
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();

Expand Down
7 changes: 7 additions & 0 deletions okhttp/src/test/java/okhttp3/KotlinSourceModernTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down
Loading

0 comments on commit 083315a

Please sign in to comment.