Skip to content

Commit 4a40a4a

Browse files
authored
chore!: Update Spring and Java (#100)
BREAKING CHANGE: The documentation structure of query parameters has been changed in the new version. Keep in mind that this version is based on Spring 3.x.x
1 parent cd47268 commit 4a40a4a

File tree

10 files changed

+37
-25
lines changed

10 files changed

+37
-25
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up JDK
1717
uses: actions/setup-java@v3
1818
with:
19-
java-version: 17
19+
java-version: 21
2020
distribution: 'temurin'
2121
cache: gradle
2222
- name: Cache Gradle packages

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up JDK
1818
uses: actions/setup-java@v3
1919
with:
20-
java-version: 17
20+
java-version: 21
2121
distribution: 'temurin'
2222
cache: gradle
2323
- name: Cache SonarCloud packages

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Details and background information can be read on our [ePages Developer Blog](ht
1616
<!-- TOC depthFrom:2 depthTo:3 -->
1717

1818
- [Contents](#contents)
19+
- [Versions](#versions)
1920
- [How to include `restdocs-wiremock` into your server project](#how-to-include-restdocs-wiremock-into-your-server-project)
2021
- [Dependencies](#dependencies)
2122
- [Producing snippets](#producing-snippets)
@@ -36,6 +37,16 @@ This repository consists of two libraries:
3637
* `wiremock-spring-boot-starter`: A spring boot starter which adds a `WireMockServer` to your client's ApplicationContext for integration testing.
3738
This is optional, but highly recommended when verifying your client contract in a SpringBootTest.
3839

40+
## Versions
41+
42+
There are multiple major versions of the libraries in different branches.
43+
The following table provides an overview which "restdocs-wiremock" release branch is to be used for microservices on specific Spring Boot versions.
44+
45+
| restdocs-wiremock version | Spring Boot version | Java version |
46+
|-----------------------------------------------------------------------|---------------------|--------------|
47+
| [1.x.x](https://github.com/ePages-de/restdocs-wiremock/releases?q=1.) | 3.3.x | 21 |
48+
| [0.x.x](https://github.com/ePages-de/restdocs-wiremock/releases?q=0.) | 2.7.x | 17 |
49+
3950
## How to include `restdocs-wiremock` into your server project
4051

4152
### Dependencies
@@ -51,7 +62,7 @@ In gradle it would look like this:
5162

5263
```groovy
5364
dependencies {
54-
testCompile('com.epages:restdocs-wiremock:0.8.5')
65+
testCompile('com.epages:restdocs-wiremock:0.8.9')
5566
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
5667
}
5768
```
@@ -62,7 +73,7 @@ When using maven:
6273
<dependency>
6374
<groupId>com.epages</groupId>
6475
<artifactId>restdocs-wiremock</artifactId>
65-
<version>0.8.5</version>
76+
<version>0.8.9</version>
6677
<scope>test</scope>
6778
</dependency>
6879
<dependency>
@@ -230,7 +241,7 @@ On the client side, add a dependency to the test-runtime to the jar containing t
230241
that, the JSON files can be accessed as classpath resources.
231242

232243
```groovy
233-
testRuntime (group:'com.epages', name:'restdocs-server', version:'0.8.5', classifier:'wiremock', ext:'jar')
244+
testRuntime (group:'com.epages', name:'restdocs-server', version:'0.8.9', classifier:'wiremock', ext:'jar')
234245
```
235246

236247
## How to use WireMock in your client tests
@@ -247,7 +258,7 @@ Services based on `spring-cloud-netflix`, i.e. using `feign` and `ribbon`, are a
247258
To add a dependency via gradle, extend your `build.gradle` with the following line:
248259

249260
```groovy
250-
testCompile('com.epages:wiremock-spring-boot-starter:0.8.5')
261+
testCompile('com.epages:wiremock-spring-boot-starter:0.8.9')
251262
```
252263

253264

@@ -257,7 +268,7 @@ When using maven, add the following dependency in test scope.
257268
<dependency>
258269
<groupId>com.epages</groupId>
259270
<artifactId>wiremock-spring-boot-starter</artifactId>
260-
<version>0.8.5</version>
271+
<version>0.8.9</version>
261272
<scope>test</scope>
262273
</dependency>
263274
```

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ subprojects {
4040
mavenCentral()
4141
}
4242

43-
sourceCompatibility = JavaVersion.VERSION_17
44-
targetCompatibility = JavaVersion.VERSION_17
43+
sourceCompatibility = JavaVersion.VERSION_21
44+
targetCompatibility = JavaVersion.VERSION_21
4545

4646
task sourceJar(type: Jar) {
4747
from sourceSets.main.allJava
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

wiremock-spring-boot-starter/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.7.18'
6+
classpath 'org.springframework.boot:spring-boot-gradle-plugin:3.3.2'
77
}
88
}
99

@@ -17,7 +17,7 @@ group = 'com.epages'
1717
description = 'Spring Boot Starter for adding a WireMock server to your integration test'
1818

1919
dependencies {
20-
api 'org.wiremock:wiremock-standalone:3.5.3'
20+
api 'org.wiremock:wiremock-standalone:3.9.1'
2121

2222
implementation 'org.springframework.boot:spring-boot-starter-test'
2323
implementation 'org.springframework.boot:spring-boot-starter'

wiremock-spring-boot-starter/src/main/java/com/epages/wiremock/starter/WireMockListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void afterTestClass(TestContext testContext) {
102102
private void addPropertySourceProperties(TestContext testContext, String[] properties) {
103103
try {
104104
MergedContextConfiguration configuration = (MergedContextConfiguration) ReflectionTestUtils
105-
.getField(testContext, "mergedContextConfiguration");
105+
.getField(testContext, "mergedConfig");
106106
new MergedContextConfigurationProperties(configuration).add(properties);
107107
} catch (RuntimeException ex) {
108108
throw ex;

wiremock/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
dependencies {
2-
// FIXME: Starting with version 2.0.3.RELEASE there are missing dependencies from "org.springframework.web"
3-
// See https://github.com/spring-projects/spring-restdocs/releases/tag/v2.0.4.RELEASE
4-
implementation 'org.springframework.restdocs:spring-restdocs-core:2.0.3.RELEASE'
5-
implementation 'com.jayway.jsonpath:json-path:2.8.0'
2+
// See https://github.com/spring-projects/spring-restdocs/releases/tag/v3.0.0
3+
implementation 'org.springframework.restdocs:spring-restdocs-core:3.0.1'
4+
implementation 'org.springframework:spring-web:6.1.12'
5+
implementation 'com.jayway.jsonpath:json-path:2.9.0'
6+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.2'
67
compileOnly 'junit:junit:4.13.2'
78
testImplementation 'junit:junit:4.13.2'
89
testImplementation 'org.mockito:mockito-core:5.11.0'
9-
testImplementation 'org.skyscreamer:jsonassert:1.5.1'
10-
testImplementation 'com.google.guava:guava:30.0-jre'
10+
testImplementation 'org.skyscreamer:jsonassert:1.5.3'
11+
testImplementation 'com.google.guava:guava:33.2.1-jre'
1112
testImplementation 'org.hamcrest:hamcrest:2.2'
1213
}
1314

wiremock/src/main/java/com/epages/restdocs/WireMockJsonSnippet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected Map<Object, Object> createModel(Operation operation) {
6666
OperationResponse response = operation.getResponse();
6767

6868
Maps.Builder<Object, Object> requestBuilder = Maps.builder()
69-
.put("method", operation.getRequest().getMethod());
69+
.put("method", operation.getRequest().getMethod().name());
7070

7171
urlPathOrUrlPattern(operation, requestBuilder);
7272

@@ -132,11 +132,11 @@ private Map<Object, Object> responseHeaders(OperationResponse response) {
132132
private Map<Object, Object> queryParams(Operation operation) {
133133
Maps.Builder<Object, Object> queryParams = Maps.builder();
134134

135-
Parameters queryStringParameters = new QueryStringParser().parse(operation.getRequest().getUri());
135+
QueryParameters queryStringParameters = QueryParameters.from(operation.getRequest());
136136

137137
for (Map.Entry<String, List<String>> e : queryStringParameters.entrySet()) {
138138
List<String> values = e.getValue();
139-
if (!values.isEmpty()) {
139+
if (!values.isEmpty() && !values.get(0).isEmpty()) {
140140
queryParams.put(e.getKey(), Maps.of("equalTo", values.get(0)));
141141
}
142142
}

wiremock/src/test/java/org/springframework/restdocs/test/OperationBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.springframework.restdocs.operation.OperationRequestPartFactory;
3838
import org.springframework.restdocs.operation.OperationResponse;
3939
import org.springframework.restdocs.operation.OperationResponseFactory;
40-
import org.springframework.restdocs.operation.Parameters;
40+
import org.springframework.restdocs.operation.QueryParameters;
4141
import org.springframework.restdocs.operation.StandardOperation;
4242
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory;
4343
import org.springframework.restdocs.snippet.StandardWriterResolver;
@@ -137,7 +137,7 @@ public final class OperationRequestBuilder {
137137

138138
private HttpHeaders headers = new HttpHeaders();
139139

140-
private Parameters parameters = new Parameters();
140+
private QueryParameters parameters;
141141

142142
private List<OperationRequestPartBuilder> partBuilders = new ArrayList<>();
143143

@@ -151,7 +151,7 @@ private OperationRequest buildRequest() {
151151
parts.add(builder.buildPart());
152152
}
153153
return new OperationRequestFactory().create(this.requestUri, this.method,
154-
this.content, this.headers, this.parameters, parts);
154+
this.content, this.headers, parts);
155155
}
156156

157157
public Operation build() {

0 commit comments

Comments
 (0)