Skip to content

Commit eb3579e

Browse files
committed
Update to Spring Boot 4
1 parent 77725ec commit eb3579e

File tree

31 files changed

+508
-216
lines changed

31 files changed

+508
-216
lines changed

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ dependencies {
1414
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.1")
1515
implementation("org.owasp:dependency-check-gradle:10.0.3")
1616

17-
implementation("org.springframework.boot:spring-boot-gradle-plugin:3.5.7")
17+
implementation("org.springframework.boot:spring-boot-gradle-plugin:4.0.1")
1818
}

buildSrc/src/main/kotlin/unit-api.publishing.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ java {
1212
withSourcesJar()
1313
}
1414

15-
signing {
15+
/*signing {
1616
val signingKey = findProperty("signingKey").toString()
1717
val signingPassword = findProperty("signingPassword").toString()
1818
useInMemoryPgpKeys(signingKey, signingPassword)
1919
sign(publishing.publications)
20-
}
20+
}*/
2121

2222
publishing {
2323
repositories {

buildSrc/src/main/kotlin/unit-api.spring-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ dependencies {
2222
testImplementation("org.springframework.boot:spring-boot-starter-test") {
2323
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
2424
}
25-
testImplementation("org.spockframework:spock-spring:2.4-M4-groovy-4.0")
25+
testImplementation("org.spockframework:spock-spring:2.4-groovy-5.0")
2626
}

buildSrc/src/main/kotlin/unit-api.test.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ tasks.jacocoTestReport {
2020

2121
dependencies {
2222
testCompileOnly("org.projectlombok:lombok:1.18.32")
23-
testImplementation("org.apache.groovy:groovy:4.0.21")
24-
testImplementation("org.spockframework:spock-core:2.4-M4-groovy-4.0")
23+
testImplementation("org.apache.groovy:groovy:5.0.3")
24+
testImplementation("org.spockframework:spock-core:2.4-groovy-5.0")
2525
testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.13")
2626
testAnnotationProcessor("org.projectlombok:lombok:1.18.32")
27+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2728
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=3.0.10-SNAPSHOT
1+
version=4.0.0-SNAPSHOT
22
org.gradle.caching=true

spring-boot-jackson-starter/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dependencies {
99
api project(":spring-boot-core-starter")
1010

1111
testImplementation 'org.springframework.boot:spring-boot-starter-web'
12+
testImplementation 'org.springframework.boot:spring-boot-starter-restclient'
1213
}

spring-boot-jackson-starter/src/test/groovy/com/raynigon/unit/api/jackson/JacksonStarterApplicationSpec.groovy

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.raynigon.unit.api.jackson
22

3-
import com.fasterxml.jackson.databind.ObjectMapper
3+
import org.springframework.boot.test.web.server.LocalServerPort
4+
import org.springframework.web.client.RestClient
5+
import tools.jackson.databind.ObjectMapper
46
import com.raynigon.unit.api.jackson.helpers.BasicApplicationConfig
57
import com.raynigon.unit.api.jackson.helpers.BasicRestController
68
import com.raynigon.unit.api.jackson.helpers.BasicService
79
import com.raynigon.unit.api.jackson.helpers.WeatherEntity
810
import org.springframework.beans.factory.annotation.Autowired
911
import org.springframework.boot.test.context.SpringBootTest
10-
import org.springframework.boot.test.web.client.TestRestTemplate
11-
import org.springframework.test.context.ContextConfiguration
1212
import org.springframework.test.context.TestPropertySource
13-
import spock.lang.Ignore
1413
import spock.lang.Specification
1514

1615
import static com.raynigon.unit.api.core.units.si.SISystemUnitsConstants.Celsius
@@ -32,18 +31,29 @@ import static com.raynigon.unit.api.core.units.si.SISystemUnitsConstants.Percent
3231
)
3332
class JacksonStarterApplicationSpec extends Specification {
3433

34+
@LocalServerPort
35+
int port
36+
3537
@Autowired
3638
BasicService service
3739

3840
@Autowired
39-
TestRestTemplate restTemplate
41+
RestClient.Builder restClientBuilder
4042

4143
@Autowired
4244
ObjectMapper objectMapper
4345

46+
RestClient restClient
47+
48+
def setup() {
49+
restClient = restClientBuilder
50+
.baseUrl("http://localhost:$port")
51+
.build()
52+
}
53+
4454
def 'context setup works'() {
4555
expect:
46-
objectMapper.getRegisteredModuleIds().contains(new UnitApiModule().getTypeId())
56+
objectMapper.registeredModules().any { it instanceof UnitApiModule }
4757
}
4858

4959
def 'entity creation works'() {
@@ -56,7 +66,12 @@ class JacksonStarterApplicationSpec extends Specification {
5666
]
5767

5868
when:
59-
def response = restTemplate.postForEntity("/api/basic-entity", data, Map.class)
69+
def response = restClient
70+
.post()
71+
.uri("/api/basic-entity")
72+
.body(data)
73+
.retrieve()
74+
.toEntity(Map.class)
6075

6176
then:
6277
response.statusCode.'2xxSuccessful'
@@ -96,8 +111,8 @@ class JacksonStarterApplicationSpec extends Specification {
96111

97112
where:
98113
entity | expected
99-
new WeatherEntity(Celsius(30), Percent(10)) | '{"temperature":30.0,"humidity":"10.0%"}'
100-
new WeatherEntity(Celsius(30), Percent(10.1)) | '{"temperature":30.0,"humidity":"10.1%"}'
101-
new WeatherEntity(Celsius(30), Percent(-10)) | '{"temperature":30.0,"humidity":"-10.0%"}'
114+
new WeatherEntity(Celsius(30), Percent(10)) | '{"humidity":"10.0%","temperature":30.0}'
115+
new WeatherEntity(Celsius(30), Percent(10.1)) | '{"humidity":"10.1%","temperature":30.0}'
116+
new WeatherEntity(Celsius(30), Percent(-10)) | '{"humidity":"-10.0%","temperature":30.0}'
102117
}
103118
}

spring-boot-jackson-starter/src/test/groovy/com/raynigon/unit/api/jackson/helpers/BasicApplicationConfig.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.raynigon.unit.api.jackson.helpers
22

3-
import com.fasterxml.jackson.databind.ObjectMapper
3+
import tools.jackson.databind.ObjectMapper
44
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
55
import org.springframework.context.annotation.Bean
66
import org.springframework.context.annotation.Configuration

spring-boot-jpa-starter/src/test/groovy/com/raynigon/unit/api/jpa/type/QuantityTypeSpec.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import javax.measure.Quantity
1515
import javax.measure.quantity.Length
1616
import java.lang.annotation.Annotation
1717

18-
import static com.raynigon.unit.api.core.units.si.SISystemUnitsConstants.Metre
18+
import static com.raynigon.unit.api.core.units.si.SISystemUnitsConstants.Metre as cMetre
1919

2020
class QuantityTypeSpec extends Specification {
2121

@@ -158,17 +158,17 @@ class QuantityTypeSpec extends Specification {
158158
where:
159159
q0 | q1 | expected
160160
null | null | true
161-
null | Metre(0) | false
162-
Metre(0) | null | false
163-
Metre(0) | Metre(0) | true
161+
null | cMetre(0) | false
162+
cMetre(0) | null | false
163+
cMetre(0) | cMetre(0) | true
164164
}
165165

166166
def 'generate quantity hash code'() {
167167
given:
168168
QuantityType type = new QuantityType()
169169

170170
when:
171-
def result = type.hashCode(Metre(0))
171+
def result = type.hashCode(cMetre(0))
172172

173173
then:
174174
result != 0

spring-boot-springdoc-starter/src/main/java/com/raynigon/unit/api/springdoc/UnitApiPropertyCustomizer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.raynigon.unit.api.springdoc;
22

3-
import com.fasterxml.jackson.databind.type.SimpleType;
3+
import com.fasterxml.jackson.databind.JavaType;
44
import com.raynigon.unit.api.core.annotation.QuantityShape;
55
import com.raynigon.unit.api.core.service.UnitsApiService;
66
import com.raynigon.unit.api.jackson.annotation.JsonUnit;
@@ -72,7 +72,7 @@ public Schema<?> customize(Schema property, AnnotatedType type) {
7272

7373
@SuppressWarnings({"rawtypes", "unchecked"})
7474
private Unit<?> resolveUnit(AnnotatedType type) {
75-
SimpleType quantityType = (SimpleType) type.getType();
75+
JavaType quantityType = (JavaType) type.getType();
7676
Class<?> quantityBoundType = quantityType.getBindings().getBoundType(0).getRawClass();
7777
Unit<?> unit = UnitsApiService.getInstance().getUnit((Class) quantityBoundType);
7878
JsonUnit jsonUnit = resolveJsonUnit(type);
@@ -106,8 +106,8 @@ private Set<Annotation> resolveConstraints(AnnotatedType type) {
106106
}
107107

108108
private boolean isApplicable(Type type) {
109-
return (type instanceof SimpleType)
110-
&& Quantity.class.isAssignableFrom(((SimpleType) type).getRawClass());
109+
return (type instanceof JavaType)
110+
&& Quantity.class.isAssignableFrom(((JavaType) type).getRawClass());
111111
}
112112

113113
private String buildDescription(AnnotatedType type, Schema property, Unit<?> unit, Set<Annotation> constraints) {

0 commit comments

Comments
 (0)