Skip to content

Commit 8b0e757

Browse files
committed
Upgrade to JUnit 5
Closes gh-964
1 parent 0e50933 commit 8b0e757

File tree

90 files changed

+388
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+388
-361
lines changed

buildSrc/src/main/java/org/springframework/gradle/SpringJavaPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.gradle.api.plugins.PluginManager;
3030
import org.gradle.api.tasks.compile.CompileOptions;
3131
import org.gradle.api.tasks.compile.JavaCompile;
32+
import org.gradle.api.tasks.testing.Test;
3233
import org.gradle.jvm.tasks.Jar;
3334
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper;
3435

@@ -92,5 +93,8 @@ public void apply(Project project) {
9293
attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
9394
manifest.attributes(attributes);
9495
}));
96+
project.getTasks().withType(Test.class, (test) -> {
97+
test.useJUnitPlatform();
98+
});
9599
}
96100
}

dependencies/spring-authorization-server-dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies {
1313
constraints {
1414
api "com.nimbusds:nimbus-jose-jwt:9.24.4"
1515
api "javax.servlet:javax.servlet-api:4.0.1"
16-
api "junit:junit:4.13.2"
16+
api "org.junit.jupiter:junit-jupiter:5.9.1"
1717
api "org.assertj:assertj-core:3.23.1"
1818
api "org.mockito:mockito-core:4.8.1"
1919
api "com.squareup.okhttp3:mockwebserver:4.10.0"

oauth2-authorization-server/spring-security-oauth2-authorization-server.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies {
2121

2222
testImplementation "org.springframework.security:spring-security-test"
2323
testImplementation "org.springframework:spring-webmvc"
24-
testImplementation "junit:junit"
24+
testImplementation "org.junit.jupiter:junit-jupiter"
2525
testImplementation "org.assertj:assertj-core"
2626
testImplementation "org.mockito:mockito-core"
2727
testImplementation "com.jayway.jsonpath:json-path"

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationConsentServiceTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
1717

1818
import java.util.List;
1919

20-
import org.junit.Before;
21-
import org.junit.Test;
20+
import org.junit.jupiter.api.BeforeEach;
21+
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.security.core.authority.SimpleGrantedAuthority;
2424

@@ -40,7 +40,7 @@ public class InMemoryOAuth2AuthorizationConsentServiceTests {
4040

4141
private InMemoryOAuth2AuthorizationConsentService authorizationConsentService;
4242

43-
@Before
43+
@BeforeEach
4444
public void setUp() {
4545
this.authorizationConsentService = new InMemoryOAuth2AuthorizationConsentService();
4646
this.authorizationConsentService.save(AUTHORIZATION_CONSENT);

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationServiceTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import java.time.temporal.ChronoUnit;
2020
import java.util.List;
2121

22-
import org.junit.Before;
23-
import org.junit.Test;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
2424

2525
import org.springframework.security.oauth2.core.AuthorizationGrantType;
2626
import org.springframework.security.oauth2.core.OAuth2AccessToken;
@@ -49,7 +49,7 @@ public class InMemoryOAuth2AuthorizationServiceTests {
4949
private static final OAuth2TokenType STATE_TOKEN_TYPE = new OAuth2TokenType(OAuth2ParameterNames.STATE);
5050
private InMemoryOAuth2AuthorizationService authorizationService;
5151

52-
@Before
52+
@BeforeEach
5353
public void setup() {
5454
this.authorizationService = new InMemoryOAuth2AuthorizationService();
5555
}

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationConsentServiceTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import java.sql.Types;
2121
import java.util.List;
2222

23-
import org.junit.After;
24-
import org.junit.Before;
25-
import org.junit.Test;
23+
import org.junit.jupiter.api.AfterEach;
24+
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.Test;
2626

2727
import org.springframework.dao.DataRetrievalFailureException;
2828
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
@@ -75,15 +75,15 @@ public class JdbcOAuth2AuthorizationConsentServiceTests {
7575
private RegisteredClientRepository registeredClientRepository;
7676
private JdbcOAuth2AuthorizationConsentService authorizationConsentService;
7777

78-
@Before
78+
@BeforeEach
7979
public void setUp() {
8080
this.db = createDb();
8181
this.jdbcOperations = new JdbcTemplate(this.db);
8282
this.registeredClientRepository = mock(RegisteredClientRepository.class);
8383
this.authorizationConsentService = new JdbcOAuth2AuthorizationConsentService(this.jdbcOperations, this.registeredClientRepository);
8484
}
8585

86-
@After
86+
@AfterEach
8787
public void tearDown() {
8888
this.db.shutdown();
8989
}

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationServiceTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import java.util.function.Function;
3030

3131
import com.fasterxml.jackson.core.type.TypeReference;
32-
import org.junit.After;
33-
import org.junit.Before;
34-
import org.junit.Test;
32+
import org.junit.jupiter.api.AfterEach;
33+
import org.junit.jupiter.api.BeforeEach;
34+
import org.junit.jupiter.api.Test;
3535

3636
import org.springframework.dao.DataRetrievalFailureException;
3737
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
@@ -88,15 +88,15 @@ public class JdbcOAuth2AuthorizationServiceTests {
8888
private RegisteredClientRepository registeredClientRepository;
8989
private JdbcOAuth2AuthorizationService authorizationService;
9090

91-
@Before
91+
@BeforeEach
9292
public void setUp() {
9393
this.db = createDb();
9494
this.jdbcOperations = new JdbcTemplate(this.db);
9595
this.registeredClientRepository = mock(RegisteredClientRepository.class);
9696
this.authorizationService = new JdbcOAuth2AuthorizationService(this.jdbcOperations, this.registeredClientRepository);
9797
}
9898

99-
@After
99+
@AfterEach
100100
public void tearDown() {
101101
this.db.shutdown();
102102
}

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/OAuth2AuthorizationConsentTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.security.oauth2.server.authorization;
1717

18-
import org.junit.Test;
18+
import org.junit.jupiter.api.Test;
1919

2020
import org.springframework.security.core.authority.SimpleGrantedAuthority;
2121

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/OAuth2AuthorizationServerMetadataTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.HashMap;
2222
import java.util.List;
2323

24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

2626
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
2727
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationServerMetadata.Builder;

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/OAuth2AuthorizationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.time.Instant;
1919
import java.time.temporal.ChronoUnit;
2020

21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.security.oauth2.core.AuthorizationGrantType;
2424
import org.springframework.security.oauth2.core.OAuth2AccessToken;

0 commit comments

Comments
 (0)