-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate MockWebServer to JUnit 5 #1817
base: develop
Are you sure you want to change the base?
Changes from all commits
4f7107a
d0a2d72
9e12be5
0b9c346
bb41646
16d4778
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,14 @@ | |
import java.net.URI; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
import okhttp3.mockwebserver.MockResponse; | ||
import okhttp3.mockwebserver.MockWebServer; | ||
import okhttp3.mockwebserver.RecordedRequest; | ||
import org.junit.Rule; | ||
import mockwebserver3.MockResponse; | ||
import mockwebserver3.MockWebServer; | ||
import mockwebserver3.RecordedRequest; | ||
import mockwebserver3.junit5.internal.MockWebServerExtension; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@EnableRuleMigrationSupport | ||
@ExtendWith(MockWebServerExtension.class) | ||
public abstract class AbstractProxyConfigTest { | ||
|
||
private static final Request request = Request.builder() | ||
|
@@ -62,11 +62,14 @@ public void close() {} | |
}) | ||
.build(); | ||
|
||
@Rule | ||
public final MockWebServer server = new MockWebServer(); | ||
private final MockWebServer server; | ||
|
||
@Rule | ||
public final MockWebServer proxyServer = new MockWebServer(); | ||
private final MockWebServer proxyServer; | ||
|
||
protected AbstractProxyConfigTest(MockWebServer server, MockWebServer proxyServer) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't see any tests out side this repo that extend this class, so while this is technically an API break I think we're fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t believe we publish this module 👍 |
||
this.server = server; | ||
this.proxyServer = proxyServer; | ||
} | ||
|
||
protected abstract Channel create(ClientConfiguration config); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ | |
|
||
package com.palantir.dialogue; | ||
|
||
// CHECKSTYLE:OFF // static import | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
|
@@ -37,18 +35,16 @@ | |
import java.time.OffsetDateTime; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import okhttp3.mockwebserver.MockResponse; | ||
import okhttp3.mockwebserver.MockWebServer; | ||
import okhttp3.mockwebserver.RecordedRequest; | ||
import org.junit.Rule; | ||
import mockwebserver3.MockResponse; | ||
import mockwebserver3.MockWebServer; | ||
import mockwebserver3.RecordedRequest; | ||
import mockwebserver3.junit5.internal.MockWebServerExtension; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.Timeout; | ||
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; | ||
|
||
// CHECKSTYLE:ON | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@EnableRuleMigrationSupport | ||
@ExtendWith(MockWebServerExtension.class) | ||
public abstract class AbstractSampleServiceClientTest { | ||
|
||
abstract SampleServiceBlocking createBlockingClient(URL baseUrl, Duration timeout); | ||
|
@@ -67,8 +63,11 @@ public abstract class AbstractSampleServiceClientTest { | |
static final SslConfiguration SSL_CONFIG = SslConfiguration.of( | ||
Paths.get("src/test/resources/trustStore.jks"), Paths.get("src/test/resources/keyStore.jks"), "keystore"); | ||
|
||
@Rule | ||
public final MockWebServer server = new MockWebServer(); | ||
private final MockWebServer server; | ||
|
||
protected AbstractSampleServiceClientTest(MockWebServer server) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't see any tests out side this repo that extend this class, so while this is technically an API break I think we're fine |
||
this.server = server; | ||
} | ||
|
||
private SampleServiceBlocking blockingClient; | ||
private SampleServiceAsync asyncClient; | ||
|
@@ -107,7 +106,7 @@ public abstract class AbstractSampleServiceClientTest { | |
|
||
@BeforeEach | ||
public void before() { | ||
server.useHttps(SslSocketFactories.createSslSocketFactory(SSL_CONFIG), false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the removed argument was disabling tunnel proxy:
|
||
server.useHttps(SslSocketFactories.createSslSocketFactory(SSL_CONFIG)); | ||
blockingClient = createBlockingClient(server.url("").url(), Duration.ofSeconds(1)); | ||
asyncClient = createAsyncClient(server.url("").url(), Duration.ofSeconds(1)); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ org.glassfish.hk2.external:jakarta.inject:2.6.1 (1 constraints: f410fcc2) | |
org.glassfish.jersey.core:jersey-common:2.31 (1 constraints: da04fa30) | ||
org.hdrhistogram:HdrHistogram:2.1.12 (1 constraints: 3e103aa2) | ||
org.immutables:value:2.8.8 (1 constraints: 14051536) | ||
org.jetbrains:annotations:23.0.0 (1 constraints: 31115ed1) | ||
org.jetbrains:annotations:23.0.0 (2 constraints: 0f20e4ff) | ||
org.mpierce.metrics.reservoir:hdrhistogram-metrics-reservoir:1.1.3 (1 constraints: 0d10f991) | ||
org.slf4j:slf4j-api:1.7.36 (8 constraints: b280891b) | ||
|
||
|
@@ -71,14 +71,16 @@ com.google.truth:truth:1.1 (1 constraints: b71111d7) | |
com.palantir.safe-logging:preconditions-assertj:3.2.0 (1 constraints: 07050036) | ||
com.palantir.tracing:tracing-test-utils:6.15.0 (1 constraints: 3e05563b) | ||
com.spotify.dataenum:dataenum:1.4.1 (1 constraints: e9105ac1) | ||
com.squareup.okhttp3:mockwebserver:3.13.1 (1 constraints: 3a053f3b) | ||
com.squareup.okhttp3:okhttp:3.13.1 (2 constraints: a014ba9d) | ||
com.squareup.okio:okio:1.17.2 (1 constraints: 850cc309) | ||
com.squareup.okhttp3:mockwebserver3:5.0.0-alpha.10 (1 constraints: b514caae) | ||
com.squareup.okhttp3:mockwebserver3-junit5:5.0.0-alpha.10 (1 constraints: c9071c72) | ||
com.squareup.okhttp3:okhttp:5.0.0-alpha.10 (1 constraints: 3a053f3b) | ||
com.squareup.okhttp3:okhttp-jvm:5.0.0-alpha.10 (2 constraints: 392169c2) | ||
com.squareup.okio:okio-jvm:3.2.0 (1 constraints: c90d9c38) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are all |
||
commons-logging:commons-logging:1.2 (2 constraints: 8215ead1) | ||
de.erichseifert.vectorgraphics2d:VectorGraphics2D:0.13 (1 constraints: 8c0a80bb) | ||
de.rototor.pdfbox:graphics2d:0.25 (1 constraints: 8f0a84bb) | ||
io.undertow:undertow-core:2.2.18.Final (1 constraints: 57074361) | ||
junit:junit:4.13.2 (4 constraints: 2d413ec7) | ||
junit:junit:4.13.1 (2 constraints: dc1cc51a) | ||
net.bytebuddy:byte-buddy:1.12.16 (2 constraints: ef164566) | ||
net.bytebuddy:byte-buddy-agent:1.12.16 (1 constraints: 750baee9) | ||
net.jcip:jcip-annotations:1.0 (1 constraints: 560ff165) | ||
|
@@ -91,7 +93,7 @@ org.apache.logging.log4j:log4j-core:2.19.0 (2 constraints: 15169e25) | |
org.apache.logging.log4j:log4j-slf4j-impl:2.19.0 (1 constraints: 3e054a3b) | ||
org.apache.pdfbox:fontbox:2.0.17 (1 constraints: 180b71d8) | ||
org.apache.pdfbox:pdfbox:2.0.17 (1 constraints: b40c5915) | ||
org.apiguardian:apiguardian-api:1.1.2 (6 constraints: 24695e60) | ||
org.apiguardian:apiguardian-api:1.1.2 (5 constraints: 105480ac) | ||
org.assertj:assertj-core:3.23.1 (3 constraints: 5025194c) | ||
org.assertj:assertj-guava:3.3.0 (1 constraints: 08050336) | ||
org.awaitility:awaitility:4.2.0 (1 constraints: 08050536) | ||
|
@@ -102,12 +104,15 @@ org.jboss.logging:jboss-logging:3.4.1.Final (3 constraints: f03036d7) | |
org.jboss.threads:jboss-threads:3.1.0.Final (2 constraints: 561a9b42) | ||
org.jboss.xnio:xnio-api:3.8.7.Final (2 constraints: 771a3146) | ||
org.jboss.xnio:xnio-nio:3.8.7.Final (1 constraints: c80dcb30) | ||
org.jetbrains.kotlin:kotlin-stdlib:1.6.21 (3 constraints: bd2f9e82) | ||
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21 (3 constraints: 3929d928) | ||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21 (1 constraints: e110f6d2) | ||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 (3 constraints: bc2d5d81) | ||
org.jmock:jmock:2.12.0 (1 constraints: 3705353b) | ||
org.jmock:jmock-testjar:2.12.0 (1 constraints: a507a272) | ||
org.junit.jupiter:junit-jupiter:5.9.1 (1 constraints: 11052036) | ||
org.junit.jupiter:junit-jupiter-api:5.9.1 (6 constraints: 6e58d58f) | ||
org.junit.jupiter:junit-jupiter-api:5.9.1 (6 constraints: 4b55e412) | ||
org.junit.jupiter:junit-jupiter-engine:5.9.1 (1 constraints: 0c0ee13b) | ||
org.junit.jupiter:junit-jupiter-migrationsupport:5.9.1 (1 constraints: 11052036) | ||
org.junit.jupiter:junit-jupiter-params:5.9.1 (2 constraints: 1c13903c) | ||
org.junit.platform:junit-platform-commons:1.9.1 (2 constraints: dd200f4b) | ||
org.junit.platform:junit-platform-engine:1.9.1 (1 constraints: ab1029b4) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -40,7 +40,7 @@ org.jmock:jmock = 2.12.0 | |||||||||||||||||||||
org.knowm.xchart:xchart = 3.6.1 | ||||||||||||||||||||||
com.palantir.conjure.verification:* = 0.19.0 | ||||||||||||||||||||||
io.undertow:undertow-core = 2.2.18.Final | ||||||||||||||||||||||
com.squareup.okhttp3:mockwebserver = 3.13.1 | ||||||||||||||||||||||
com.squareup.okhttp3:mockwebserver3-junit5 = 5.0.0-alpha.10 | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There hasn't been a non-alpha release of From https://search.maven.org/artifact/com.squareup.okhttp3/mockwebserver3-junit5
|
||||||||||||||||||||||
org.openjdk.jmh:* = 1.35 | ||||||||||||||||||||||
|
||||||||||||||||||||||
# dependency-upgrader:OFF | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see any tests out side this repo that extend this class, so while this is technically an API break I think we're fine