Skip to content

Commit bb56ad3

Browse files
committed
Raise minimum supported version of JUnit to 6.0
Closes gh-989
1 parent 5603cfd commit bb56ad3

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

docs/src/docs/asciidoc/getting-started.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,29 +203,29 @@ It then produces documentation snippets for the request and the resulting respon
203203
==== Setting up Your Tests
204204

205205
Exactly how you set up your tests depends on the test framework that you use.
206-
Spring REST Docs provides first-class support for JUnit 5.
206+
Spring REST Docs provides first-class support for JUnit 6.
207207
Other frameworks, such as TestNG, are also supported, although slightly more setup is required.
208208

209209

210210

211-
[[getting-started-documentation-snippets-setup-junit-5]]
212-
===== Setting up Your JUnit 5 Tests
211+
[[getting-started-documentation-snippets-setup-junit]]
212+
===== Setting up Your JUnit 6 Tests
213213

214-
When using JUnit 5, the first step in generating documentation snippets is to apply the `RestDocumentationExtension` to your test class.
214+
When using JUnit 6, the first step in generating documentation snippets is to apply the `RestDocumentationExtension` to your test class.
215215
The following example shows how to do so:
216216

217217
[source,java,indent=0]
218218
----
219219
@ExtendWith(RestDocumentationExtension.class)
220-
public class JUnit5ExampleTests {
220+
public class JUnit6ExampleTests {
221221
----
222222

223223
When testing a typical Spring application, you should also apply the `SpringExtension`:
224224

225225
[source,java,indent=0]
226226
----
227227
@ExtendWith({RestDocumentationExtension.class, SpringExtension.class})
228-
public class JUnit5ExampleTests {
228+
public class JUnit6ExampleTests {
229229
----
230230

231231
The `RestDocumentationExtension` is automatically configured with an output directory based on your project's build tool:
@@ -241,12 +241,12 @@ The `RestDocumentationExtension` is automatically configured with an output dire
241241
| `build/generated-snippets`
242242
|===
243243

244-
If you are using JUnit 5.1, you can override the default by registering the extension as a field in your test class and providing an output directory when creating it.
244+
You can override the default by registering the extension as a field in your test class and providing an output directory when creating it.
245245
The following example shows how to do so:
246246

247247
[source,java,indent=0]
248248
----
249-
public class JUnit5ExampleTests {
249+
public class JUnit6ExampleTests {
250250
251251
@RegisterExtension
252252
final RestDocumentationExtension restDocumentation = new RestDocumentationExtension ("custom");

spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private boolean isTestMethodContext(ExtensionContext context) {
8383
private ManualRestDocumentation getDelegate(ExtensionContext context) {
8484
Namespace namespace = Namespace.create(getClass(), context.getUniqueId());
8585
return context.getStore(namespace)
86-
.getOrComputeIfAbsent(ManualRestDocumentation.class, this::createManualRestDocumentation,
86+
.computeIfAbsent(ManualRestDocumentation.class, this::createManualRestDocumentation,
8787
ManualRestDocumentation.class);
8888
}
8989

spring-restdocs-core/src/testFixtures/java/org/springframework/restdocs/testfixtures/jupiter/OutputCaptureExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte
102102
}
103103

104104
private OutputCapture getOutputCapture(ExtensionContext context) {
105-
return getStore(context).getOrComputeIfAbsent(OutputCapture.class);
105+
return getStore(context).computeIfAbsent(OutputCapture.class);
106106
}
107107

108108
private Store getStore(ExtensionContext context) {

spring-restdocs-core/src/testFixtures/java/org/springframework/restdocs/testfixtures/jupiter/RenderedSnippetTestExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
105105
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
106106
Class<?> parameterType = parameterContext.getParameter().getType();
107107
if (AssertableSnippets.class.equals(parameterType)) {
108-
return getStore(extensionContext).getOrComputeIfAbsent(AssertableSnippets.class,
108+
return getStore(extensionContext).computeIfAbsent(AssertableSnippets.class,
109109
(key) -> new AssertableSnippets(determineOutputDirectory(extensionContext),
110110
determineOperationName(extensionContext), this.templateFormat));
111111
}
112112
if (TemplateFormat.class.equals(parameterType)) {
113113
return this.templateFormat;
114114
}
115-
return getStore(extensionContext).getOrComputeIfAbsent(OperationBuilder.class, (key) -> {
115+
return getStore(extensionContext).computeIfAbsent(OperationBuilder.class, (key) -> {
116116
OperationBuilder operationBuilder = new OperationBuilder(determineOutputDirectory(extensionContext),
117117
determineOperationName(extensionContext), this.templateFormat);
118118
AnnotationUtils.findAnnotation(extensionContext.getRequiredTestMethod(), SnippetTemplate.class)

spring-restdocs-core/src/testFixtures/java/org/springframework/restdocs/testfixtures/jupiter/SnippetTestExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
4141

4242
@Override
4343
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
44-
return getStore(extensionContext).getOrComputeIfAbsent(OperationBuilder.class,
44+
return getStore(extensionContext).computeIfAbsent(OperationBuilder.class,
4545
(key) -> new OperationBuilder(determineOutputDirectory(extensionContext),
4646
determineOperationName(extensionContext)));
4747
}

spring-restdocs-platform/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828
api(enforcedPlatform("io.rest-assured:rest-assured-bom:5.5.6"))
2929
api(enforcedPlatform("org.assertj:assertj-core:3.27.4"))
3030
api(enforcedPlatform("org.mockito:mockito-bom:5.19.0"))
31-
api(enforcedPlatform("org.junit:junit-bom:5.13.4"))
31+
api(enforcedPlatform("org.junit:junit-bom:6.0.0-RC3"))
3232
api(enforcedPlatform("org.springframework:spring-framework-bom:$springFrameworkVersion"))
3333
api(enforcedPlatform("tools.jackson:jackson-bom:3.0.0-rc9"))
3434
}

spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/TomcatServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TomcatServer implements BeforeAllCallback, AfterAllCallback {
5353
@Override
5454
public void beforeAll(ExtensionContext extensionContext) {
5555
Store store = extensionContext.getStore(Namespace.create(TomcatServer.class));
56-
store.getOrComputeIfAbsent(Tomcat.class, (key) -> {
56+
store.computeIfAbsent(Tomcat.class, (key) -> {
5757
Tomcat tomcat = new Tomcat();
5858
tomcat.getConnector().setPort(0);
5959
Context context = tomcat.addContext("/", null);

0 commit comments

Comments
 (0)