Skip to content

Commit d9884a2

Browse files
committed
Upgrade to Spring Boot 3.0.2.
Closes #653
1 parent c3bb060 commit d9884a2

File tree

7 files changed

+76
-54
lines changed

7 files changed

+76
-54
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
logging.level.root=INFO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
4+
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
5+
<encoder>
6+
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="info">
11+
<appender-ref ref="console" />
12+
</root>
13+
14+
</configuration>

pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<groupId>org.springframework.boot</groupId>
1515
<artifactId>spring-boot-starter-parent</artifactId>
16-
<version>3.0.0</version>
16+
<version>3.0.2</version>
1717
</parent>
1818

1919
<modules>
@@ -156,8 +156,8 @@
156156
<url>https://repo1.maven.org/maven2/</url>
157157
</repository>
158158
<repository>
159-
<id>spring-libs-snapshot</id>
160-
<url>https://repo.spring.io/libs-snapshot</url>
159+
<id>spring-snapshot</id>
160+
<url>https://repo.spring.io/snapshot/</url>
161161
</repository>
162162
</repositories>
163163

@@ -168,8 +168,8 @@
168168
<url>https://repo1.maven.org/maven2/</url>
169169
</pluginRepository>
170170
<pluginRepository>
171-
<id>spring-libs-snapshot</id>
172-
<url>https://repo.spring.io/libs-snapshot</url>
171+
<id>spring-snapshot</id>
172+
<url>https://repo.spring.io/snapshot/</url>
173173
</pluginRepository>
174174
</pluginRepositories>
175175

rest/headers/pom.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131

3232
<dependency>
3333
<groupId>org.springframework.restdocs</groupId>
34-
<artifactId>spring-restdocs</artifactId>
35-
<version>1.0.0.M1</version>
34+
<artifactId>spring-restdocs-mockmvc</artifactId>
3635
<scope>test</scope>
3736
</dependency>
3837

3938
</dependencies>
4039

41-
</project>
40+
</project>

rest/headers/src/test/java/example/springdata/rest/headers/WebIntegrationTests.java

+42-33
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@
1717

1818
import static org.hamcrest.CoreMatchers.*;
1919
import static org.springframework.http.HttpHeaders.*;
20-
import static org.springframework.restdocs.RestDocumentation.*;
20+
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*;
2121
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
2222
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
2323

2424
import org.junit.jupiter.api.BeforeEach;
2525
import org.junit.jupiter.api.Test;
26+
import org.junit.jupiter.api.extension.ExtendWith;
2627

2728
import org.springframework.beans.factory.annotation.Autowired;
2829
import org.springframework.boot.test.context.SpringBootTest;
29-
import org.springframework.restdocs.config.RestDocumentationConfigurer;
30+
import org.springframework.restdocs.JUnitRestDocumentation;
31+
import org.springframework.restdocs.RestDocumentationContextProvider;
32+
import org.springframework.restdocs.RestDocumentationExtension;
33+
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
3034
import org.springframework.test.web.servlet.MockMvc;
3135
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
3236
import org.springframework.web.context.WebApplicationContext;
@@ -37,47 +41,52 @@
3741
* @soundtrack The Intersphere - Out of phase (Live at Alte Feuerwache Mannheim)
3842
*/
3943
@SpringBootTest
44+
@ExtendWith(RestDocumentationExtension.class)
4045
public class WebIntegrationTests {
4146

42-
@Autowired WebApplicationContext context;
43-
@Autowired CustomerRepository customers;
47+
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
4448

45-
private MockMvc mvc;
49+
@Autowired
50+
WebApplicationContext context;
51+
@Autowired
52+
CustomerRepository customers;
4653

47-
@BeforeEach
48-
public void setUp() {
54+
private MockMvc mvc;
4955

50-
this.mvc = MockMvcBuilders.webAppContextSetup(context).//
51-
apply(new RestDocumentationConfigurer()).//
52-
build();
53-
}
56+
@BeforeEach
57+
public void setUp(RestDocumentationContextProvider restDocumentation) {
5458

55-
@Test
56-
public void executeConditionalGetRequests() throws Exception {
59+
this.mvc = MockMvcBuilders.webAppContextSetup(context).//
60+
apply(MockMvcRestDocumentation.documentationConfiguration(restDocumentation)).//
61+
build();
62+
}
5763

58-
var customer = customers.findAll().iterator().next();
59-
var uri = new UriTemplate("/customers/{id}").expand(customer.getId());
64+
@Test
65+
public void executeConditionalGetRequests() throws Exception {
6066

61-
var response = mvc.perform(get(uri)).//
62-
andExpect(header().string(ETAG, is(notNullValue()))).//
63-
andExpect(header().string(LAST_MODIFIED, is(notNullValue()))).//
64-
andReturn().getResponse();
67+
var customer = customers.findAll().iterator().next();
68+
var uri = new UriTemplate("/customers/{id}").expand(customer.getId());
6569

66-
// ETag-based
70+
var response = mvc.perform(get(uri)).//
71+
andExpect(header().string(ETAG, is(notNullValue()))).//
72+
andExpect(header().string(LAST_MODIFIED, is(notNullValue()))).//
73+
andReturn().getResponse();
6774

68-
response = mvc.perform(get(uri).header(IF_NONE_MATCH, response.getHeader(ETAG))).//
69-
andExpect(status().isNotModified()).//
70-
andExpect(header().string(ETAG, is(notNullValue()))).//
71-
andExpect(header().string(LAST_MODIFIED, is(notNullValue()))).//
72-
andDo(document("if-none-match")).//
73-
andReturn().getResponse();
75+
// ETag-based
7476

75-
// Last-modified-based
77+
response = mvc.perform(get(uri).header(IF_NONE_MATCH, response.getHeader(ETAG))).//
78+
andExpect(status().isNotModified()).//
79+
andExpect(header().string(ETAG, is(notNullValue()))).//
80+
andExpect(header().string(LAST_MODIFIED, is(notNullValue()))).//
81+
andDo(document("if-none-match")).//
82+
andReturn().getResponse();
7683

77-
mvc.perform(get(uri).header(IF_MODIFIED_SINCE, response.getHeader(LAST_MODIFIED))).//
78-
andExpect(status().isNotModified()).//
79-
andExpect(header().string(ETAG, is(notNullValue()))).//
80-
andExpect(header().string(LAST_MODIFIED, is(notNullValue()))).//
81-
andDo(document("if-modified-since"));
82-
}
84+
// Last-modified-based
85+
86+
mvc.perform(get(uri).header(IF_MODIFIED_SINCE, response.getHeader(LAST_MODIFIED))).//
87+
andExpect(status().isNotModified()).//
88+
andExpect(header().string(ETAG, is(notNullValue()))).//
89+
andExpect(header().string(LAST_MODIFIED, is(notNullValue()))).//
90+
andDo(document("if-modified-since"));
91+
}
8392
}

rest/security/src/main/java/example/springdata/rest/security/Application.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
2727
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
2828
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
29-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
3029
import org.springframework.security.core.context.SecurityContextHolder;
3130
import org.springframework.security.core.userdetails.User;
3231
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
3332
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
33+
import org.springframework.security.web.SecurityFilterChain;
3434

3535
/**
3636
* This example shows various ways to secure Spring Data REST applications using Spring Security
@@ -79,7 +79,7 @@ public static void main(String[] args) {
7979
@Configuration
8080
@EnableGlobalMethodSecurity(prePostEnabled = true)
8181
@EnableWebSecurity
82-
static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
82+
static class SecurityConfiguration {
8383

8484
/**
8585
* This section defines the user accounts which can be used for authentication as well as the roles each user has.
@@ -107,16 +107,15 @@ InMemoryUserDetailsManager userDetailsManager() {
107107
*
108108
* @param http
109109
* @throws Exception
110-
* @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.web.builders.HttpSecurity)
111110
*/
112-
@Override
113-
protected void configure(HttpSecurity http) throws Exception {
114-
115-
http.httpBasic().and().authorizeRequests().//
116-
antMatchers(HttpMethod.POST, "/employees").hasRole("ADMIN").//
117-
antMatchers(HttpMethod.PUT, "/employees/**").hasRole("ADMIN").//
118-
antMatchers(HttpMethod.PATCH, "/employees/**").hasRole("ADMIN").and().//
119-
csrf().disable();
111+
@Bean
112+
protected SecurityFilterChain configure(HttpSecurity http) throws Exception {
113+
114+
return http.httpBasic().and().authorizeRequests().//
115+
requestMatchers(HttpMethod.POST, "/employees").hasRole("ADMIN").//
116+
requestMatchers(HttpMethod.PUT, "/employees/**").hasRole("ADMIN").//
117+
requestMatchers(HttpMethod.PATCH, "/employees/**").hasRole("ADMIN").and().//
118+
csrf().disable().build();
120119
}
121120
}
122121
}

rest/security/src/test/java/example/springdata/rest/security/UrlLevelSecurityTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ void allowsAccessToRootResource() throws Exception {
6868

6969
mvc.perform(get("/").//
7070
accept(MediaTypes.HAL_JSON)).//
71-
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
72-
andExpect(status().isOk());
71+
andExpect(status().isOk()).//
72+
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON));
7373
}
7474

7575
@Test

0 commit comments

Comments
 (0)