Upgrade WireMock to 4.x
MSALUpgrade WireMock to 4.x, which requires Java 17, ships Jetty 12.1 by default, splits JUnit support out into separate modules and makes the primary domain classes immutable. Note that RequestMethod.GET_OR_HEAD is a multi method matcher in 4.x rather than a method named GET_OR_HEAD, so code reading a name off that particular constant needs a look.
org. openrewrite. java. testing. wiremock. Wiremock3to4Migrationmod run . --recipe= org. openrewrite. java. testing. wiremock. Wiremock3to4MigrationInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Keep a single
Content-Typeresponse header while still on WireMock 3 - Move Jetty EE10 usages to EE11 alongside
wiremock-jetty12 - Upgrade WireMock to 3.x
- Change Gradle or Maven dependency
org.wiremock:wiremock-jetty12 - Upgrade Gradle or Maven dependency versions
org.wiremock:wiremock:4.0.0-beta.41 - Upgrade Gradle or Maven dependency versions
org.wiremock:wiremock-standalone:4.0.0-beta.41 - Add Gradle or Maven dependency
org.wiremock:wiremock-junit5:4.0.0-beta.41 - Add Gradle or Maven dependency
org.wiremock:wiremock-junit4:4.0.0-beta.41 - Add Gradle or Maven dependency
org.eclipse.jetty:jetty-client:12.1.x - Add Gradle or Maven dependency
org.eclipse.jetty:jetty-proxy:12.1.x - Add Gradle or Maven dependency
org.eclipse.jetty:jetty-xml:12.1.x - Add
wiremock-httpclient-apache5where its types are used - Move WireMock types to their 4.x packages
- Replace WireMock constructors removed in 4.x
- Replace WireMock setter calls with
transform() - Drop
@OverridefromremoveLast()in custom WireMock request journal stores - Migrate the
uuidfield in WireMock stub mapping files toid - Preserve the UTF-8 default of
ContentTypeHeader.charset() - Migrate
RequestMethod.isOneOfto the matcher it became - Change method name
com.github.tomakehurst.wiremock.stubbing.StubMapping getUuid()togetId - Change method name
com.github.tomakehurst.wiremock.http.RequestMethod value()togetName - Change method name
com.github.tomakehurst.wiremock.matching.RequestPattern getMatcher()togetInlineCustomMatcher