Skip to content

Commit 1b474c2

Browse files
committed
Update to Spring Boot 4.0.0-RC1
This commit updates testjars to support Spring Boot 4.0.x. Resolves #98 Signed-off-by: Chris Bono <[email protected]>
1 parent 039166a commit 1b474c2

File tree

12 files changed

+58
-53
lines changed

12 files changed

+58
-53
lines changed

samples/oauth2-login-custom-config/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'java'
3-
id 'org.springframework.boot' version '3.4.0'
4-
id 'io.spring.dependency-management' version '1.1.2'
3+
id 'org.springframework.boot' version '4.0.0-RC1'
4+
id 'io.spring.dependency-management' version '1.1.7'
55
}
66

77
group = 'com.example'
@@ -18,10 +18,13 @@ dependencies {
1818
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
1919
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
2020
implementation 'org.springframework.boot:spring-boot-starter-web'
21+
2122
testImplementation project(':spring-boot-testjars')
2223
testImplementation project(':spring-boot-testjars-maven')
2324
testImplementation 'org.springframework.boot:spring-boot-starter-test'
2425
testImplementation 'org.springframework.boot:spring-boot-starter-oauth2-authorization-server'
26+
27+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
2528
}
2629

2730
tasks.named('test') {

samples/oauth2-login-custom-config/src/test/java/testjars/authorizationserver/SecurityConfig.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.springframework.security.config.Customizer;
2929
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
3030
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
31+
import org.springframework.security.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration;
32+
import org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer;
3133
import org.springframework.security.core.userdetails.User;
3234
import org.springframework.security.core.userdetails.UserDetails;
3335
import org.springframework.security.core.userdetails.UserDetailsService;
@@ -38,8 +40,6 @@
3840
import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository;
3941
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
4042
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
41-
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration;
42-
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer;
4343
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
4444
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
4545
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@@ -59,9 +59,14 @@ public class SecurityConfig {
5959

6060
@Bean
6161
@Order(1)
62-
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http)
63-
throws Exception {
64-
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
62+
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) {
63+
OAuth2AuthorizationServerConfigurer authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer();
64+
http
65+
.securityMatcher(authorizationServerConfigurer.getEndpointsMatcher())
66+
.with(authorizationServerConfigurer, Customizer.withDefaults())
67+
.authorizeHttpRequests((authorize) ->
68+
authorize.anyRequest().authenticated()
69+
);
6570
http.getConfigurer(OAuth2AuthorizationServerConfigurer.class)
6671
.oidc(Customizer.withDefaults()); // Enable OpenID Connect 1.0
6772
http
@@ -82,8 +87,7 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
8287

8388
@Bean
8489
@Order(2)
85-
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http)
86-
throws Exception {
90+
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) {
8791
http
8892
.authorizeHttpRequests((authorize) -> authorize
8993
.anyRequest().authenticated()
@@ -96,6 +100,7 @@ public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http)
96100
return http.build();
97101
}
98102

103+
@SuppressWarnings("deprecation")
99104
@Bean
100105
public UserDetailsService userDetailsService() {
101106
UserDetails userDetails = User.withDefaultPasswordEncoder()

samples/oauth2-login/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'java'
3-
id 'org.springframework.boot' version '3.4.0'
4-
id 'io.spring.dependency-management' version '1.1.2'
3+
id 'org.springframework.boot' version '4.0.0-RC1'
4+
id 'io.spring.dependency-management' version '1.1.7'
55
}
66

77
group = 'com.example'
@@ -18,9 +18,12 @@ dependencies {
1818
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
1919
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
2020
implementation 'org.springframework.boot:spring-boot-starter-web'
21+
2122
testImplementation project(':spring-boot-testjars')
2223
testImplementation project(':spring-boot-testjars-maven')
2324
testImplementation 'org.springframework.boot:spring-boot-starter-test'
25+
26+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
2427
}
2528

2629
tasks.named('test') {

spring-boot-testjars-maven/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ checkstyle {
2727

2828
dependencies {
2929
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.40")
30+
3031
api project(':spring-boot-testjars')
31-
api platform('org.springframework.boot:spring-boot-dependencies:3.4.0')
32+
api platform('org.springframework.boot:spring-boot-dependencies:4.0.0-RC1')
3233
api 'org.springframework.boot:spring-boot-starter'
34+
api 'org.springframework.boot:spring-boot-web-server'
3335
api "org.apache.maven:maven-resolver-provider:${mavenVersion}"
3436
api "org.apache.maven.resolver:maven-resolver-api:${mavenResolverVersion}"
3537
api "org.apache.maven.resolver:maven-resolver-spi:${mavenResolverVersion}"
@@ -39,8 +41,11 @@ dependencies {
3941
api "org.apache.maven.resolver:maven-resolver-transport-file:${mavenResolverVersion}"
4042
api "org.apache.maven.resolver:maven-resolver-transport-http:${mavenResolverVersion}"
4143
api "org.apache.maven.resolver:maven-resolver-supplier:${mavenResolverVersion}"
42-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
44+
4345
testImplementation 'org.springframework:spring-web'
46+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
47+
48+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
4449
}
4550

4651
tasks.named('test') {

spring-boot-testjars-maven/src/test/java/org/springframework/experimental/boot/server/exec/MavenClasspathEntryTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,29 @@ void resolveDependencyWhenCustomRepository() {
103103
List<RemoteRepository> repositories = new ArrayList<>();
104104
repositories.add(
105105
new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2/").build());
106-
repositories.add(new RemoteRepository.Builder("sonatype-snapshot", "default",
107-
"https://oss.sonatype.org/content/repositories/snapshots/").build());
108-
MavenClasspathEntry classpathEntry = new MavenClasspathEntry("org.junit:junit5-api:5.0.0-SNAPSHOT",
109-
repositories);
110-
assertThatNoException().isThrownBy(() -> classpathEntry.resolve());
106+
repositories.add(new RemoteRepository.Builder("apache-snapshot", "default",
107+
"https://repository.apache.org/content/repositories/snapshots/").build());
108+
MavenClasspathEntry classpathEntry = new MavenClasspathEntry(
109+
"org.apache.commons:commons-compress:1.29.0-SNAPSHOT", repositories);
110+
assertThatNoException().isThrownBy(classpathEntry::resolve);
111111
}
112112

113113
@Test
114114
void resolveDependencyWhenOrgSpringframeworkSnapshotThenDoesNotRequireCustomRepository() {
115115
MavenClasspathEntry classpathEntry = new MavenClasspathEntry("org.springframework:spring-core:6.2.0-SNAPSHOT");
116-
assertThatNoException().isThrownBy(() -> classpathEntry.resolve());
116+
assertThatNoException().isThrownBy(classpathEntry::resolve);
117117
}
118118

119119
@Test
120120
void resolveDependencyWhenOrgSpringframeworkRc1ThenDoesNotRequireCustomRepository() {
121121
MavenClasspathEntry classpathEntry = new MavenClasspathEntry("org.springframework:spring-core:6.2.0-RC1");
122-
assertThatNoException().isThrownBy(() -> classpathEntry.resolve());
122+
assertThatNoException().isThrownBy(classpathEntry::resolve);
123123
}
124124

125125
@Test
126126
void resolveDependencyWhenOrgSpringframeworkM1ThenDoesNotRequireCustomRepository() {
127127
MavenClasspathEntry classpathEntry = new MavenClasspathEntry("org.springframework:spring-core:6.2.0-M1");
128-
assertThatNoException().isThrownBy(() -> classpathEntry.resolve());
128+
assertThatNoException().isThrownBy(classpathEntry::resolve);
129129
}
130130

131131
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
shouldoverride: willbereplaced
1+
shouldoverride: willbereplaced

spring-boot-testjars-maven/src/test/resources/testjars/authorizationServer/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ spring:
2121
scopes:
2222
- "openid"
2323
- "profile"
24-
require-authorization-consent: true
24+
require-authorization-consent: true

spring-boot-testjars/build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ checkstyle {
2222

2323
dependencies {
2424
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.40")
25+
2526
compileOnly 'org.springframework.boot:spring-boot-loader'
26-
implementation platform('org.springframework.boot:spring-boot-dependencies:3.4.0')
27-
implementation 'org.apache.commons:commons-exec:1.3'
28-
implementation 'org.springframework:spring-test'
27+
28+
implementation platform('org.springframework.boot:spring-boot-dependencies:4.0.0-RC1')
2929
implementation 'org.springframework.boot:spring-boot-testcontainers'
30+
implementation 'org.springframework.boot:spring-boot-web-server'
31+
implementation 'org.springframework:spring-test'
32+
implementation 'org.apache.commons:commons-exec:1.3'
33+
34+
testImplementation 'org.springframework:spring-web'
3035
testImplementation 'org.springframework.boot:spring-boot-loader'
3136
testImplementation 'org.springframework.boot:spring-boot-starter-test'
32-
testImplementation 'org.springframework:spring-web'
37+
38+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
3339
}
3440

3541
tasks.named('test') {

spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/detector/ClassUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class ClassUtils {
3131
* @throws LinkageError if the class file could not be loaded
3232
* @see Class#forName(String, boolean, ClassLoader)
3333
*/
34+
@SuppressWarnings("deprecation")
3435
static Class<?> forName(String name, @Nullable ClassLoader classLoader)
3536
throws ClassNotFoundException, LinkageError {
3637

spring-boot-testjars/src/main/java/org/springframework/experimental/boot/test/context/DynamicPropertyAutoConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@
1717
package org.springframework.experimental.boot.test.context;
1818

1919
import org.springframework.boot.autoconfigure.AutoConfiguration;
20+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2021
import org.springframework.core.Ordered;
2122
import org.springframework.core.annotation.Order;
23+
import org.springframework.test.context.DynamicPropertyRegistrar;
2224

2325
/**
2426
* Automatically imports {@code EnableDynamicProperty}.
2527
*
2628
* @author Rob Winch
29+
* @author Chris Bono
2730
*/
2831
@AutoConfiguration
2932
@Order(Ordered.HIGHEST_PRECEDENCE)
33+
@ConditionalOnClass(DynamicPropertyRegistrar.class)
3034
@EnableDynamicProperty
3135
public class DynamicPropertyAutoConfiguration {
3236

0 commit comments

Comments
 (0)