Skip to content

Commit 58e90c4

Browse files
committed
Spring Boot 4.0.0 RC2
1 parent 4dd5935 commit 58e90c4

File tree

43 files changed

+542
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+542
-182
lines changed

build.gradle.kts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
id("pl.allegro.tech.build.axion-release") version "1.21.0"
1515
jacoco
1616
java
17-
kotlin("jvm") version "2.0.21" apply false
17+
kotlin("jvm") version "2.2.21" apply false
1818
}
1919

2020
repositories {
@@ -28,10 +28,14 @@ scmVersion {
2828
}
2929

3030
hooks {
31-
pre("fileUpdate", mapOf(
31+
pre(
32+
"fileUpdate",
33+
mapOf(
3234
"file" to "README.md",
3335
"pattern" to "{v,p -> /('$'v)/}",
34-
"replacement" to """{v, p -> "'$'v"}]))"""))
36+
"replacement" to """{v, p -> "'$'v"}]))""",
37+
),
38+
)
3539
pre("commit")
3640
}
3741
}
@@ -40,7 +44,7 @@ val scmVer = scmVersion.version
4044

4145
fun Project.isSampleProject() = this.name.contains("sample")
4246

43-
val nonSampleProjects = subprojects.filterNot { it.isSampleProject() }
47+
val nonSampleProjects = subprojects.filterNot { it.isSampleProject() }
4448

4549
allprojects {
4650

@@ -60,13 +64,16 @@ allprojects {
6064
}
6165
}
6266

63-
6467
subprojects {
6568

66-
val jacksonVersion by extra { "2.19.2" }
67-
val springBootVersion by extra { "3.5.7" }
68-
val springRestDocsVersion by extra { "3.0.5" }
69-
val junitVersion by extra { "5.12.2" }
69+
val jacksonVersion by extra { "3.0.2" }
70+
val jackson2Version by extra { "2.20.1" }
71+
val jacksonAnnotationsVersion by extra { "2.20" }
72+
val springBootVersion by extra { "4.0.0-RC2" }
73+
val springRestDocsVersion by extra { "4.0.0-RC1" }
74+
val springRestDocsRestAssuredVersion by extra { "4.0.0-M3" }
75+
val junitVersion by extra { "6.0.1" }
76+
val jmustacheVersion by extra { "1.16" }
7077

7178
tasks.withType<KotlinCompile> {
7279
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
@@ -103,8 +110,24 @@ tasks {
103110
val jacocoRootReport by registering(JacocoReport::class) {
104111
description = "Generates an aggregate report from all subprojects"
105112
group = "Coverage reports"
106-
sourceDirectories.setFrom(files(nonSampleProjects.flatMap { it.sourceSets["main"].allSource.srcDirs.filter { it.exists() && !it.path.endsWith("restdocs-api-spec-postman-generator/src/main/java") } } ))
107-
classDirectories.setFrom(files(nonSampleProjects.flatMap { it.sourceSets["main"].output }.filter { !it.path.endsWith("restdocs-api-spec-postman-generator/build/classes/java/main") } ))
113+
sourceDirectories.setFrom(
114+
files(
115+
nonSampleProjects.flatMap {
116+
it.sourceSets["main"].allSource.srcDirs.filter {
117+
it.exists() &&
118+
!it.path.endsWith("restdocs-api-spec-postman-generator/src/main/java")
119+
}
120+
},
121+
),
122+
)
123+
classDirectories.setFrom(
124+
files(
125+
nonSampleProjects
126+
.flatMap {
127+
it.sourceSets["main"].output
128+
}.filter { !it.path.endsWith("restdocs-api-spec-postman-generator/build/classes/java/main") },
129+
),
130+
)
108131
executionData(files(nonSampleProjects.map { it.layout.buildDirectory.file("jacoco/test.exec") }))
109132
reports {
110133
html.required.set(false)

restdocs-api-spec-gradle-plugin/build.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pluginBundle {
3636
}
3737
}
3838

39-
4039
val jacksonVersion: String by extra
4140
val junitVersion: String by extra
4241

@@ -51,8 +50,9 @@ dependencies {
5150
implementation(project(":restdocs-api-spec-openapi-generator"))
5251
implementation(project(":restdocs-api-spec-openapi3-generator"))
5352
implementation(project(":restdocs-api-spec-postman-generator"))
54-
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
55-
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
53+
implementation("tools.jackson.core:jackson-databind:$jacksonVersion")
54+
implementation("tools.jackson.module:jackson-module-kotlin:$jacksonVersion")
55+
implementation("tools.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
5656

5757
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
5858
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
@@ -76,7 +76,11 @@ val createTestKitFiles by tasks.registering {
7676

7777
doLast {
7878
outputDir.get().asFile.mkdirs()
79-
val destFile = project.layout.buildDirectory.file("jacoco/test.exec").get().asFile.path
79+
val destFile =
80+
project.layout.buildDirectory
81+
.file("jacoco/test.exec")
82+
.get()
83+
.asFile.path
8084
val outFile = outputDir.get().file("testkit-gradle.properties").asFile
8185
outFile.writeText("org.gradle.jvmargs=-javaagent:${jacocoRuntime.asPath}=destfile=$destFile")
8286
}

restdocs-api-spec-gradle-plugin/src/main/kotlin/com/epages/restdocs/apispec/gradle/ApiSpecTask.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.epages.restdocs.apispec.gradle
22

33
import com.epages.restdocs.apispec.model.ResourceModel
4-
import com.fasterxml.jackson.databind.DeserializationFeature
5-
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
6-
import com.fasterxml.jackson.module.kotlin.readValue
74
import org.gradle.api.DefaultTask
85
import org.gradle.api.tasks.Input
96
import org.gradle.api.tasks.TaskAction
7+
import tools.jackson.databind.DeserializationFeature
8+
import tools.jackson.module.kotlin.jacksonMapperBuilder
9+
import tools.jackson.module.kotlin.jacksonObjectMapper
10+
import tools.jackson.module.kotlin.readValue
1011
import java.io.File
1112

1213
abstract class ApiSpecTask : DefaultTask() {
@@ -28,7 +29,7 @@ abstract class ApiSpecTask : DefaultTask() {
2829
private val snippetsDirectoryFile
2930
get() = project.file(snippetsDirectory)
3031

31-
private val objectMapper = jacksonObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
32+
private val objectMapper = jacksonMapperBuilder().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build()
3233

3334
open fun applyExtension(extension: ApiSpecExtension) {
3435
outputDirectory = extension.outputDirectory

restdocs-api-spec-gradle-plugin/src/main/kotlin/com/epages/restdocs/apispec/gradle/OpenApiExtension.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.epages.restdocs.apispec.gradle
22

33
import com.epages.restdocs.apispec.model.Oauth2Configuration
4-
import com.fasterxml.jackson.databind.ObjectMapper
5-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
6-
import com.fasterxml.jackson.module.kotlin.readValue
74
import groovy.lang.Closure
85
import io.swagger.v3.oas.models.info.Contact
96
import io.swagger.v3.oas.models.servers.Server
107
import org.gradle.api.Project
8+
import tools.jackson.databind.ObjectMapper
9+
import tools.jackson.dataformat.yaml.YAMLFactory
10+
import tools.jackson.module.kotlin.readValue
1111
import java.io.File
1212

1313
abstract class OpenApiBaseExtension(

restdocs-api-spec-gradle-plugin/src/main/kotlin/com/epages/restdocs/apispec/gradle/PostmanTask.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package com.epages.restdocs.apispec.gradle
22

33
import com.epages.restdocs.apispec.model.ResourceModel
44
import com.epages.restdocs.apispec.postman.PostmanCollectionGenerator
5-
import com.fasterxml.jackson.databind.SerializationFeature
6-
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
75
import org.gradle.api.tasks.Input
86
import org.gradle.api.tasks.Optional
7+
import tools.jackson.databind.SerializationFeature
8+
import tools.jackson.module.kotlin.jacksonMapperBuilder
9+
import tools.jackson.module.kotlin.jacksonObjectMapper
910

1011
open class PostmanTask : ApiSpecTask() {
1112
@Input
@@ -23,7 +24,7 @@ open class PostmanTask : ApiSpecTask() {
2324
override fun outputFileExtension() = "json"
2425

2526
override fun generateSpecification(resourceModels: List<ResourceModel>): String =
26-
jacksonObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(
27+
jacksonMapperBuilder().enable(SerializationFeature.INDENT_OUTPUT).build().writeValueAsString(
2728
PostmanCollectionGenerator.generate(
2829
resources = resourceModels,
2930
title = title,

restdocs-api-spec-jsonschema/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ dependencies {
1414
implementation(kotlin("stdlib-jdk8"))
1515
implementation(project(":restdocs-api-spec-model"))
1616
implementation("com.github.erosb:everit-json-schema:1.11.0")
17-
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
18-
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
17+
implementation("tools.jackson.core:jackson-databind:$jacksonVersion")
18+
implementation("tools.jackson.module:jackson-module-kotlin:$jacksonVersion")
1919

2020
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
2121
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGenerator.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import com.epages.restdocs.apispec.jsonschema.ConstraintResolver.minInteger
1010
import com.epages.restdocs.apispec.jsonschema.ConstraintResolver.minLengthString
1111
import com.epages.restdocs.apispec.model.Attributes
1212
import com.epages.restdocs.apispec.model.FieldDescriptor
13-
import com.fasterxml.jackson.databind.SerializationFeature
14-
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
1513
import org.everit.json.schema.ArraySchema
1614
import org.everit.json.schema.BooleanSchema
1715
import org.everit.json.schema.CombinedSchema
@@ -24,6 +22,9 @@ import org.everit.json.schema.ObjectSchema
2422
import org.everit.json.schema.Schema
2523
import org.everit.json.schema.StringSchema
2624
import org.everit.json.schema.internal.JSONPrinter
25+
import tools.jackson.databind.SerializationFeature
26+
import tools.jackson.module.kotlin.jacksonMapperBuilder
27+
import tools.jackson.module.kotlin.jacksonObjectMapper
2728
import java.io.StringWriter
2829
import java.util.Collections.emptyList
2930
import java.util.function.Predicate
@@ -89,7 +90,7 @@ class JsonSchemaFromFieldDescriptorsGenerator {
8990
}
9091

9192
private fun toFormattedString(schema: Schema): String {
92-
val objectMapper = jacksonObjectMapper().enable(SerializationFeature.INDENT_OUTPUT)
93+
val objectMapper = jacksonMapperBuilder().enable(SerializationFeature.INDENT_OUTPUT).build()
9394
return StringWriter().use {
9495
schema.describeTo(JSONPrinter(it))
9596
objectMapper.writeValueAsString(objectMapper.readTree(it.toString()))

restdocs-api-spec-mockmvc/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ dependencies {
1717
api(project(":restdocs-api-spec"))
1818
implementation("org.springframework.restdocs:spring-restdocs-mockmvc:$springRestDocsVersion")
1919

20-
testImplementation("org.springframework.boot:spring-boot-starter-test:$springBootVersion") {
21-
exclude("junit")
22-
}
20+
testImplementation("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
21+
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test:$springBootVersion")
22+
testImplementation("org.springframework.boot:spring-boot-restdocs:$springBootVersion")
2323
testImplementation("org.springframework.boot:spring-boot-starter-validation:$springBootVersion")
2424
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
2525
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2626
testImplementation("org.junit-pioneer:junit-pioneer:2.3.0")
27+
testImplementation(testFixtures(project(":restdocs-api-spec")))
2728
testImplementation("org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion")
2829
}
2930

restdocs-api-spec-mockmvc/src/test/kotlin/com/epages/restdocs/apispec/MockMvcRestDocumentationWrapperIntegrationTest.kt

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
package com.epages.restdocs.apispec
22

3+
import com.epages.apispec.restdocs.HalTestUtils
34
import com.epages.restdocs.apispec.ResourceDocumentation.resource
45
import org.assertj.core.api.Assertions.assertThatCode
56
import org.assertj.core.api.BDDAssertions.then
7+
import org.junit.jupiter.api.BeforeEach
68
import org.junit.jupiter.api.Test
79
import org.junit.jupiter.api.extension.ExtendWith
8-
import org.springframework.beans.factory.annotation.Autowired
9-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
10+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
1011
import org.springframework.hateoas.MediaTypes.HAL_JSON
1112
import org.springframework.http.MediaType.APPLICATION_JSON
13+
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter
14+
import org.springframework.restdocs.RestDocumentationContextProvider
15+
import org.springframework.restdocs.RestDocumentationExtension
1216
import org.springframework.restdocs.headers.HeaderDocumentation.headerWithName
1317
import org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders
1418
import org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders
1519
import org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel
1620
import org.springframework.restdocs.hypermedia.HypermediaDocumentation.links
1721
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document
22+
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration
1823
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post
1924
import org.springframework.restdocs.operation.preprocess.OperationRequestPreprocessor
2025
import org.springframework.restdocs.payload.PayloadDocumentation.beneathPath
@@ -24,17 +29,41 @@ import org.springframework.restdocs.payload.PayloadDocumentation.responseFields
2429
import org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath
2530
import org.springframework.restdocs.request.RequestDocumentation.parameterWithName
2631
import org.springframework.restdocs.request.RequestDocumentation.pathParameters
27-
import org.springframework.test.context.junit.jupiter.SpringExtension
2832
import org.springframework.test.web.servlet.MockMvc
2933
import org.springframework.test.web.servlet.result.MockMvcResultHandlers.print
3034
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
35+
import org.springframework.test.web.servlet.setup.MockMvcBuilders
36+
import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder
37+
import org.springframework.web.context.WebApplicationContext
38+
import tools.jackson.databind.json.JsonMapper
3139
import java.io.File
3240

33-
@ExtendWith(SpringExtension::class)
41+
@ExtendWith(value = [RestDocumentationExtension::class])
3442
@WebMvcTest
35-
class MockMvcRestDocumentationWrapperIntegrationTest(
36-
@Autowired private val mockMvc: MockMvc,
37-
) : ResourceSnippetIntegrationTest() {
43+
class MockMvcRestDocumentationWrapperIntegrationTest : ResourceSnippetIntegrationTest() {
44+
private lateinit var mockMvc: MockMvc
45+
46+
private lateinit var mapper: JsonMapper
47+
48+
@BeforeEach
49+
fun setUpModule() {
50+
}
51+
52+
@BeforeEach
53+
fun setUp(
54+
webApplicationContext: WebApplicationContext,
55+
restDocumentation: RestDocumentationContextProvider,
56+
) {
57+
this.mapper = HalTestUtils.halMapper()
58+
this.mockMvc =
59+
MockMvcBuilders
60+
.standaloneSetup(webApplicationContext, TestApplication.TestController())
61+
.apply<StandaloneMockMvcBuilder>(documentationConfiguration(restDocumentation))
62+
.setMessageConverters(
63+
JacksonJsonHttpMessageConverter(this.mapper),
64+
).build()
65+
}
66+
3867
@Test
3968
fun should_document_both_restdocs_and_resource() {
4069
givenEndpointInvoked()

restdocs-api-spec-mockmvc/src/test/kotlin/com/epages/restdocs/apispec/ResourceSnippetIntegrationTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import org.hibernate.validator.constraints.Length
77
import org.junit.jupiter.api.extension.ExtendWith
88
import org.springframework.boot.SpringApplication
99
import org.springframework.boot.autoconfigure.SpringBootApplication
10-
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs
11-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
10+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
1211
import org.springframework.context.ConfigurableApplicationContext
1312
import org.springframework.hateoas.EntityModel
1413
import org.springframework.hateoas.IanaLinkRelations
1514
import org.springframework.hateoas.Link
15+
import org.springframework.hateoas.server.EntityLinks
1616
import org.springframework.hateoas.server.mvc.BasicLinkBuilder.linkToCurrentMapping
1717
import org.springframework.http.HttpHeaders.ACCEPT
1818
import org.springframework.http.HttpHeaders.CONTENT_TYPE
@@ -31,7 +31,6 @@ import java.util.UUID
3131

3232
@ExtendWith(SpringExtension::class)
3333
@WebMvcTest
34-
@AutoConfigureRestDocs
3534
open class ResourceSnippetIntegrationTest {
3635
val operationName = "test-${System.currentTimeMillis()}"
3736

@@ -70,7 +69,7 @@ open class ResourceSnippetIntegrationTest {
7069
return ResponseEntity
7170
.ok()
7271
.header("X-Custom-Header", customHeader)
73-
.body<EntityModel<TestDataHolder>>(resource)
72+
.body(resource)
7473
}
7574
}
7675
}

0 commit comments

Comments
 (0)