Skip to content

Commit 9aa9775

Browse files
authored
bump to Java 21 and Spring Boot 3.5 (#15)
1 parent 6fb1f5c commit 9aa9775

File tree

11 files changed

+56
-44
lines changed

11 files changed

+56
-44
lines changed

.github/workflows/broken-links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
broken-link-check:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-latest
1010
name: Check for broken links in README.md
1111
steps:
1212
- name: Checkout code

.github/workflows/maven.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ on:
55
- cron: '0 15 * * *' # daily at 3pm
66
jobs:
77
build-and-test:
8-
runs-on: ubuntu-24.04
8+
runs-on: ubuntu-latest
99
name: Build Application
1010
steps:
1111
- name: Checkout Code
1212
uses: actions/checkout@v4
1313

14-
- name: Setup for JDK 17
14+
- name: Setup for JDK 21
1515
uses: actions/setup-java@v4
1616
with:
1717
distribution: temurin
18-
java-version: 17
18+
java-version: 21
1919
java-package: jdk
2020
cache: maven
2121

.java-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
17.0
1+
21.0

.sdkmanrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=21.0.6-tem

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# TDD with Spring Boot Done Right Online Course
44

5-
[![](https://img.shields.io/badge/Spring%20Boot%20Version-3.1.X-orange)](/pom.xml)
6-
[![](https://img.shields.io/badge/Java%20Version-17-orange)](/pom.xml)
5+
[![](https://img.shields.io/badge/Spring%20Boot%20Version-3.5.X-orange)](/pom.xml)
6+
[![](https://img.shields.io/badge/Java%20Version-21-orange)](/pom.xml)
77
[![](https://img.shields.io/badge/Enroll-Now-orange)](https://rieckpil.de/tdd-with-spring-boot-done-right/)
88

99
- `main` branch: [![Build & Test Maven Project](https://github.com/rieckpil/tdd-with-spring-boot-done-right/actions/workflows/maven.yml/badge.svg?branch=main)](https://github.com/rieckpil/tdd-with-spring-boot-done-right/actions/workflows/maven.yml)
@@ -39,13 +39,13 @@ If you're new to testing with Java and Spring Boot, we highly recommend to first
3939

4040
Mandatory requirements:
4141

42-
* Java 17 (JDK flavour (OpenJDK/Azul/Oracle) does not matter). For the correct Java version setup I can recommend [JEnv](https://www.youtube.com/watch?v=9FVZyeFDXo0) (Mac/Linux) and the [Maven Toolchains Plugin](https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/jdk.html) (Windows)
42+
* Java 21 (JDK flavour (OpenJDK/Azul/Oracle) does not matter). For the correct Java version setup I can recommend [JEnv](https://www.youtube.com/watch?v=9FVZyeFDXo0) (Mac/Linux) and the [Maven Toolchains Plugin](https://maven.apache.org/plugins/maven-toolchains-plugin/toolchains/jdk.html) (Windows)
4343

4444
```
4545
$ java -version
46-
openjdk version "17" 2021-09-14 LTS
47-
OpenJDK Runtime Environment Zulu17.28+13-CA (build 17+35-LTS)
48-
OpenJDK 64-Bit Server VM Zulu17.28+13-CA (build 17+35-LTS, mixed mode, sharing)
46+
openjdk version "21.0.6" 2025-01-21 LTS
47+
OpenJDK Runtime Environment Temurin-21.0.6+7 (build 21.0.6+7-LTS)
48+
OpenJDK 64-Bit Server VM Temurin-21.0.6+7 (build 21.0.6+7-LTS, mixed mode, sharing)
4949
```
5050

5151
* Docker Engine (Community Edition is enough):

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>3.4.5</version>
9+
<version>3.5.0</version>
1010
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

@@ -17,8 +17,8 @@
1717
<description>TDD with Spring Boot Done Right Online Course</description>
1818

1919
<properties>
20-
<java.version>17</java.version>
21-
<wiremock.version>2.33.2</wiremock.version>
20+
<java.version>21</java.version>
21+
<wiremock.version>3.13.0</wiremock.version>
2222
</properties>
2323

2424
<dependencies>
@@ -50,8 +50,8 @@
5050
<scope>test</scope>
5151
</dependency>
5252
<dependency>
53-
<groupId>com.github.tomakehurst</groupId>
54-
<artifactId>wiremock-jre8-standalone</artifactId>
53+
<groupId>org.wiremock</groupId>
54+
<artifactId>wiremock-standalone</artifactId>
5555
<version>${wiremock.version}</version>
5656
<scope>test</scope>
5757
</dependency>
@@ -86,7 +86,7 @@
8686
<configuration>
8787
<java>
8888
<googleJavaFormat>
89-
<version>1.16.0</version>
89+
<version>1.17.0</version>
9090
<style>GOOGLE</style>
9191
</googleJavaFormat>
9292
<importOrder>

src/main/java/de/rieckpil/CommentApiController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
import jakarta.validation.Valid;
77
import org.springframework.http.ResponseEntity;
88
import org.springframework.security.core.Authentication;
9-
import org.springframework.web.bind.annotation.*;
9+
import org.springframework.web.bind.annotation.GetMapping;
10+
import org.springframework.web.bind.annotation.PostMapping;
11+
import org.springframework.web.bind.annotation.RequestBody;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RestController;
1014
import org.springframework.web.util.UriComponents;
1115
import org.springframework.web.util.UriComponentsBuilder;
1216

src/test/java/de/rieckpil/CommentApiControllerTest.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@
88
import org.junit.jupiter.api.Test;
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
11-
import org.springframework.boot.test.mock.mockito.MockBean;
1211
import org.springframework.context.annotation.Import;
1312
import org.springframework.security.test.context.support.WithMockUser;
13+
import org.springframework.test.context.bean.override.mockito.MockitoBean;
1414
import org.springframework.test.web.servlet.MockMvc;
1515

1616
import static org.hamcrest.Matchers.is;
1717
import static org.hamcrest.Matchers.notNullValue;
18-
import static org.mockito.ArgumentMatchers.*;
18+
import static org.mockito.ArgumentMatchers.anyString;
1919
import static org.mockito.Mockito.when;
2020
import static org.springframework.http.HttpHeaders.ACCEPT;
2121
import static org.springframework.http.MediaType.APPLICATION_JSON;
2222
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
2323
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
24-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
24+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
25+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
26+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
27+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
2528

2629
@Import(WebSecurityConfiguration.class)
2730
@WebMvcTest(CommentApiController.class)
2831
class CommentApiControllerTest {
2932

3033
@Autowired private MockMvc mockMvc;
3134

32-
@MockBean private CommentService commentService;
35+
@MockitoBean private CommentService commentService;
3336

3437
@Test
3538
void shouldAllowAnonymousUsersToGetAllComments() throws Exception {
@@ -60,10 +63,10 @@ void shouldRejectAnonymousUsersWhenCreatingComments() throws Exception {
6063
.contentType(APPLICATION_JSON)
6164
.content(
6265
"""
63-
{
64-
"content": "Lorem Ipsum"
65-
}
66-
"""))
66+
{
67+
"content": "Lorem Ipsum"
68+
}
69+
"""))
6770
.andExpect(status().isUnauthorized());
6871
}
6972

@@ -78,10 +81,10 @@ void shouldRejectAuthenticatedUserWithoutAdminRoleWhenCreatingComments() throws
7881
.contentType(APPLICATION_JSON)
7982
.content(
8083
"""
81-
{
82-
"content": "Lorem Ipsum"
83-
}
84-
"""))
84+
{
85+
"content": "Lorem Ipsum"
86+
}
87+
"""))
8588
.andExpect(status().isForbidden());
8689
}
8790

@@ -94,11 +97,12 @@ void shouldFailOnInvalidCommentData() throws Exception {
9497
.perform(
9598
post("/api/comments")
9699
.contentType(APPLICATION_JSON)
97-
.content("""
98-
{
99-
"content": ""
100-
}
101-
"""))
100+
.content(
101+
"""
102+
{
103+
"content": ""
104+
}
105+
"""))
102106
.andExpect(status().isBadRequest());
103107
}
104108

@@ -118,10 +122,10 @@ void shouldCreateCommentWhenUserIsAuthenticatedAndAdmin() throws Exception {
118122
.contentType(APPLICATION_JSON)
119123
.content(
120124
"""
121-
{
122-
"content": "Lorem Ipsum"
123-
}
124-
"""))
125+
{
126+
"content": "Lorem Ipsum"
127+
}
128+
"""))
125129
.andExpect(status().isCreated())
126130
.andExpect(header().exists("Location"))
127131
.andExpect(

src/test/java/de/rieckpil/PostClientTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import org.junit.jupiter.api.extension.RegisterExtension;
99
import org.springframework.web.reactive.function.client.WebClient;
1010

11-
import static com.github.tomakehurst.wiremock.client.WireMock.*;
11+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
12+
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
13+
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
1214
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
1315
import static org.assertj.core.api.Assertions.assertThat;
1416

@@ -22,7 +24,7 @@ class PostClientTest {
2224
new PostClient(WebClient.builder().baseUrl(mockServer.baseUrl()).build());
2325

2426
@Test
25-
void shouldReturnAllPosts() throws Exception {
27+
void shouldReturnAllPosts() {
2628

2729
mockServer.stubFor(
2830
WireMock.get(urlPathEqualTo("/posts"))

src/test/java/de/rieckpil/SampleTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import org.junit.jupiter.api.Test;
44

5-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
6-
75
class SampleTest {
86

97
@Test

0 commit comments

Comments
 (0)