Skip to content
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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Migrate MockWebServer to JUnit 5 #1817

wants to merge 6 commits into from

Conversation

schlosna
Copy link
Contributor

@schlosna schlosna commented Nov 11, 2022

Before this PR

Using MockWebServer with JUnit 4 migration support

After this PR

Builds on top of #1815
==COMMIT_MSG==
MockWebServer JUnit 5
==COMMIT_MSG==

Possible downsides?

@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There hasn't been a non-alpha release of mockwebserver3-junit5 yet, but there have been many alpha releases over the past year and a half:

From https://search.maven.org/artifact/com.squareup.okhttp3/mockwebserver3-junit5

Version Release Date
5.0.0-alpha.10 27-Jun-2022
5.0.0-alpha.9 16-Jun-2022
5.0.0-alpha.8 08-Jun-2022
5.0.0-alpha.7 26-Apr-2022
5.0.0-alpha.6 14-Mar-2022
5.0.0-alpha.5 21-Feb-2022
5.0.0-alpha.4 01-Feb-2022
5.0.0-alpha.3 22-Nov-2021
5.0.0-alpha.2 30-Jan-2021

@schlosna schlosna changed the base branch from ds/junit to develop November 11, 2022 17:02
@schlosna schlosna marked this pull request as ready for review November 11, 2022 17:04
@@ -97,6 +88,12 @@ public void close() {}

protected Channel channel;

protected final MockWebServer server;

protected AbstractChannelTest(MockWebServer server) {
Copy link
Contributor Author

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

public final MockWebServer proxyServer = new MockWebServer();
private final MockWebServer proxyServer;

protected AbstractProxyConfigTest(MockWebServer server, MockWebServer proxyServer) {
Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t believe we publish this module 👍

public final MockWebServer server = new MockWebServer();
private final MockWebServer server;

protected AbstractSampleServiceClientTest(MockWebServer server) {
Copy link
Contributor Author

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

@@ -107,7 +106,7 @@ public abstract class AbstractSampleServiceClientTest {

@BeforeEach
public void before() {
server.useHttps(SslSocketFactories.createSslSocketFactory(SSL_CONFIG), false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the removed argument was disabling tunnel proxy:

https://github.com/square/okhttp/blob/parent-4.10.0/mockwebserver/src/main/kotlin/okhttp3/mockwebserver/MockWebServer.kt#L276-L280

tunnelProxy true to expect the HTTP CONNECT method before negotiating TLS.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are all [Test dependencies] changes (below line 64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants