Skip to content

Commit 2539abd

Browse files
committed
Upgrade to Java 21; upgrade Spring Boot version; various enhancements
1 parent 8bfad15 commit 2539abd

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

pom.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.2.0</version>
8+
<version>3.4.0</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>de.rwu.swen</groupId>
@@ -14,8 +14,7 @@
1414
<name>rwu-spring-boot-demo</name>
1515
<description>rwu-spring-boot-demo</description>
1616
<properties>
17-
<java.version>17</java.version>
18-
<testcontainers.version>1.20.3</testcontainers.version>
17+
<java.version>21</java.version>
1918
</properties>
2019
<dependencies>
2120
<dependency>
@@ -34,7 +33,7 @@
3433
<dependency>
3534
<groupId>org.postgresql</groupId>
3635
<artifactId>postgresql</artifactId>
37-
<version>42.7.4</version>
36+
<scope>runtime</scope>
3837
</dependency>
3938

4039
<dependency>
@@ -51,32 +50,29 @@
5150
<dependency>
5251
<groupId>org.testcontainers</groupId>
5352
<artifactId>testcontainers</artifactId>
54-
<version>${testcontainers.version}</version>
5553
<scope>test</scope>
5654
</dependency>
5755
<dependency>
5856
<groupId>org.testcontainers</groupId>
5957
<artifactId>junit-jupiter</artifactId>
60-
<version>${testcontainers.version}</version>
6158
<scope>test</scope>
6259
</dependency>
6360
<dependency>
6461
<groupId>org.testcontainers</groupId>
6562
<artifactId>postgresql</artifactId>
66-
<version>${testcontainers.version}</version>
6763
<scope>test</scope>
6864
</dependency>
6965
<dependency>
7066
<groupId>io.rest-assured</groupId>
7167
<artifactId>spring-mock-mvc</artifactId>
72-
<version>5.5.0</version>
7368
<scope>test</scope>
7469
</dependency>
7570

7671
<dependency>
7772
<groupId>org.springframework.boot</groupId>
7873
<artifactId>spring-boot-devtools</artifactId>
7974
<optional>true</optional>
75+
<scope>runtime</scope>
8076
</dependency>
8177
</dependencies>
8278

src/main/java/de/rwu/swen/demo/RwuSpringBootDemoApplication.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
import org.springframework.boot.autoconfigure.SpringBootApplication;
88
import org.springframework.context.annotation.Bean;
99
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
10+
import org.springframework.data.web.config.EnableSpringDataWebSupport;
11+
12+
import static org.springframework.data.web.config.EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO;
1013

1114
@SpringBootApplication
1215
@EnableJpaRepositories
16+
@EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO)
1317
public class RwuSpringBootDemoApplication {
1418

15-
Logger LOGGER = LoggerFactory.getLogger(RwuSpringBootDemoApplication.class);
19+
private static final Logger LOGGER = LoggerFactory.getLogger(RwuSpringBootDemoApplication.class);
1620

1721
public static void main(String[] args) {
1822
SpringApplication.run(RwuSpringBootDemoApplication.class, args);

src/test/java/de/rwu/swen/demo/RwuSpringBootDemoApplicationTests.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import org.junit.jupiter.api.Test;
77
import org.springframework.boot.test.context.SpringBootTest;
88
import org.springframework.boot.test.context.TestConfiguration;
9-
import org.springframework.boot.test.mock.mockito.MockBean;
109
import org.springframework.boot.test.web.server.LocalServerPort;
1110
import org.springframework.context.annotation.Bean;
1211
import org.springframework.context.annotation.Primary;
1312
import org.springframework.http.HttpStatus;
13+
import org.springframework.test.context.bean.override.mockito.MockitoBean;
1414
import org.springframework.test.context.jdbc.Sql;
15-
import org.testcontainers.containers.PostgreSQLContainer;
16-
import org.testcontainers.junit.jupiter.Container;
1715

1816
import static io.restassured.RestAssured.given;
1917
import static org.hamcrest.CoreMatchers.equalTo;
@@ -26,13 +24,10 @@ class RwuSpringBootDemoApplicationTests {
2624
public static final int HTTP_OK = HttpStatus.OK.value();
2725
private static final int HTTP_NOT_FOUND = HttpStatus.NOT_FOUND.value();
2826

29-
@Container
30-
public static PostgreSQLContainer<?> container = new PostgreSQLContainer<>("postgres:16");
31-
3227
/**
33-
* Prevent InitDb to create DB entries in table student.
28+
* Replace with mock, so that no entries are created in student DB table.
3429
*/
35-
@MockBean
30+
@MockitoBean
3631
private InitDb initDb;
3732

3833
@TestConfiguration
@@ -58,10 +53,6 @@ public void beforeEach() {
5853
RestAssured.baseURI = "http://localhost";
5954
}
6055

61-
@Test
62-
void contextLoads() {
63-
}
64-
6556
@Test
6657
void testRepoChangedForTest() {
6758

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spring.datasource.url=jdbc:tc:postgresql:16:///postgres
1+
spring.datasource.url=jdbc:tc:postgresql:17:///postgres
22
spring.jpa.hibernate.ddl-auto=create
33

44
paging.page-size=3

0 commit comments

Comments
 (0)