Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 7a8f337

Browse files
author
Corneil du Plessis
committed
Updates for JUnit5 and AssertJ
1 parent 646f1e7 commit 7a8f337

File tree

172 files changed

+1087
-1061
lines changed

Some content is hidden

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

172 files changed

+1087
-1061
lines changed

spring-cloud-common-security-config/spring-cloud-common-security-config-core/src/test/java/org/springframework/cloud/common/security/core/support/OAuth2AccessTokenProvidingClientHttpRequestInterceptorTests.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
class OAuth2AccessTokenProvidingClientHttpRequestInterceptorTests {
4141

4242
@Test
43-
void testOAuth2AccessTokenProvidingClientHttpRequestInterceptorWithEmptyConstructior() {
43+
void oAuth2AccessTokenProvidingClientHttpRequestInterceptorWithEmptyConstructior() {
4444
assertThatThrownBy(() -> new OAuth2AccessTokenProvidingClientHttpRequestInterceptor(""))
4545
.isInstanceOf(IllegalArgumentException.class)
4646
.hasMessage("staticOauthAccessToken must not be null or empty.");
4747
}
4848

4949
@Test
50-
void testOAuth2AccessTokenProvidingClientHttpRequestInterceptorWithStaticTokenConstructor() {
50+
void oAuth2AccessTokenProvidingClientHttpRequestInterceptorWithStaticTokenConstructor() {
5151
final OAuth2AccessTokenProvidingClientHttpRequestInterceptor interceptor =
5252
new OAuth2AccessTokenProvidingClientHttpRequestInterceptor("foobar");
5353

@@ -56,39 +56,42 @@ void testOAuth2AccessTokenProvidingClientHttpRequestInterceptorWithStaticTokenCo
5656
}
5757

5858
@Test
59-
void testInterceptWithStaticToken() throws IOException {
59+
void interceptWithStaticToken() throws IOException {
6060
final OAuth2AccessTokenProvidingClientHttpRequestInterceptor interceptor =
6161
new OAuth2AccessTokenProvidingClientHttpRequestInterceptor("foobar");
6262
final HttpHeaders headers = setupTest(interceptor);
6363

64-
assertThat(headers).hasSize(1);
65-
assertThat(headers).contains(entry("Authorization", Collections.singletonList("Bearer foobar")));
64+
assertThat(headers)
65+
.hasSize(1)
66+
.contains(entry("Authorization", Collections.singletonList("Bearer foobar")));
6667
}
6768

6869
@Test
69-
void testInterceptWithAuthentication() throws IOException {
70+
void interceptWithAuthentication() throws IOException {
7071
final OAuth2TokenUtilsService oauth2TokenUtilsService = mock(OAuth2TokenUtilsService.class);
7172
when(oauth2TokenUtilsService.getAccessTokenOfAuthenticatedUser()).thenReturn("foo-bar-123-token");
7273

7374
final OAuth2AccessTokenProvidingClientHttpRequestInterceptor interceptor =
7475
new OAuth2AccessTokenProvidingClientHttpRequestInterceptor(oauth2TokenUtilsService);
7576
final HttpHeaders headers = setupTest(interceptor);
7677

77-
assertThat(headers).hasSize(1);
78-
assertThat(headers).contains(entry("Authorization", Collections.singletonList("Bearer foo-bar-123-token")));
78+
assertThat(headers)
79+
.hasSize(1)
80+
.contains(entry("Authorization", Collections.singletonList("Bearer foo-bar-123-token")));
7981
}
8082

8183
@Test
82-
void testInterceptWithAuthenticationAndStaticToken() throws IOException {
84+
void interceptWithAuthenticationAndStaticToken() throws IOException {
8385
final OAuth2TokenUtilsService oauth2TokenUtilsService = mock(OAuth2TokenUtilsService.class);
8486
when(oauth2TokenUtilsService.getAccessTokenOfAuthenticatedUser()).thenReturn("foo-bar-123-token");
8587

8688
final OAuth2AccessTokenProvidingClientHttpRequestInterceptor interceptor =
8789
new OAuth2AccessTokenProvidingClientHttpRequestInterceptor("foobar");
8890
final HttpHeaders headers = setupTest(interceptor);
8991

90-
assertThat(headers).hasSize(1);
91-
assertThat(headers).contains(entry("Authorization", Collections.singletonList("Bearer foobar")));
92+
assertThat(headers)
93+
.hasSize(1)
94+
.contains(entry("Authorization", Collections.singletonList("Bearer foobar")));
9295
}
9396

9497
private HttpHeaders setupTest( OAuth2AccessTokenProvidingClientHttpRequestInterceptor interceptor) throws IOException {

spring-cloud-common-security-config/spring-cloud-common-security-config-web/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,10 @@
7171
<artifactId>mockwebserver</artifactId>
7272
<scope>test</scope>
7373
</dependency>
74+
<dependency>
75+
<groupId>junit</groupId>
76+
<artifactId>junit</artifactId>
77+
<scope>test</scope>
78+
</dependency>
7479
</dependencies>
7580
</project>

spring-cloud-dataflow-audit/src/test/java/org/springframework/cloud/dataflow/server/audit/service/DefaultAuditRecordServiceTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void initializationWithNullParameters() {
7070
}
7171

7272
@Test
73-
void testPopulateAndSaveAuditRecord() {
73+
void populateAndSaveAuditRecord() {
7474
final AuditRecordService auditRecordService = new DefaultAuditRecordService(this.auditRecordRepository);
7575
auditRecordService.populateAndSaveAuditRecord(AuditOperationType.SCHEDULE, AuditActionType.CREATE, "1234",
7676
"my data", "test-platform");

spring-cloud-dataflow-build/pom.xml

+2-20
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
<checkstyle.version>${maven-checkstyle-plugin.version}</checkstyle.version>
4848
<puppycrawl-tools-checkstyle.version>8.29</puppycrawl-tools-checkstyle.version>
4949
<spring-javaformat.version>0.0.9</spring-javaformat.version>
50-
<maven-failsafe-plugin.version>3.0.0</maven-failsafe-plugin.version>
50+
<maven-failsafe-plugin.version>3.1.2</maven-failsafe-plugin.version>
5151
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
5252
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
5353
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
5454
<maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
55-
<maven-surefire-plugin.version>3.0.0</maven-surefire-plugin.version>
55+
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
5656
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
5757
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
5858
<git-commit-id-plugin.version>4.9.9</git-commit-id-plugin.version>
@@ -108,24 +108,6 @@
108108
</dependencyManagement>
109109
<dependencies>
110110
<!-- Boot removed junit4/vintage deps, we're not yet ready, so give it all -->
111-
<dependency>
112-
<groupId>junit</groupId>
113-
<artifactId>junit</artifactId>
114-
<version>${junit.version}</version>
115-
<scope>test</scope>
116-
</dependency>
117-
<dependency>
118-
<groupId>org.junit.vintage</groupId>
119-
<artifactId>junit-vintage-engine</artifactId>
120-
<version>${junit-jupiter.version}</version>
121-
<scope>test</scope>
122-
<exclusions>
123-
<exclusion>
124-
<artifactId>hamcrest-core</artifactId>
125-
<groupId>org.hamcrest</groupId>
126-
</exclusion>
127-
</exclusions>
128-
</dependency>
129111
</dependencies>
130112
<organization>
131113
<name>Pivotal Software, Inc.</name>

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AboutDocumentation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
* @author Corneil du Plessis
3535
*/
3636
@SuppressWarnings("NewClassNamingConvention")
37-
public class AboutDocumentation extends BaseDocumentation {
37+
class AboutDocumentation extends BaseDocumentation {
3838

3939
@Test
40-
public void getMetaInformation() throws Exception {
40+
void getMetaInformation() throws Exception {
4141
this.mockMvc.perform(
4242
get("/about")
4343
.accept(MediaType.APPLICATION_JSON))

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/ApiDocumentation.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@
4242
* @author Corneil du Plessis
4343
*/
4444
@SuppressWarnings("NewClassNamingConvention")
45-
public class ApiDocumentation extends BaseDocumentation {
45+
class ApiDocumentation extends BaseDocumentation {
4646

4747
@Test
48-
public void headers() throws Exception {
48+
void headers() throws Exception {
4949
this.mockMvc.perform(get("/")).andExpect(status().isOk())
5050
.andDo(this.documentationHandler.document(responseHeaders(headerWithName("Content-Type")
5151
.description("The Content-Type of the payload, e.g. " + "`application/hal+json`"))));
5252
}
5353

5454
@Test
55-
public void errors() throws Exception {
55+
void errors() throws Exception {
5656
this.mockMvc
5757
.perform(get("/error").requestAttr(RequestDispatcher.ERROR_STATUS_CODE, 400)
5858
.requestAttr(RequestDispatcher.ERROR_REQUEST_URI, "/apps").requestAttr(
@@ -72,7 +72,7 @@ public void errors() throws Exception {
7272
}
7373

7474
@Test
75-
public void index() throws Exception {
75+
void index() throws Exception {
7676
this.mockMvc.perform(get("/"))
7777
.andExpect(status().isOk())
7878
.andDo(this.documentationHandler.document(links(

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AppRegistryDocumentation.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
* @author Corneil du Plessis
4646
*/
4747
@SuppressWarnings("NewClassNamingConvention")
48-
public class AppRegistryDocumentation extends BaseDocumentation {
48+
class AppRegistryDocumentation extends BaseDocumentation {
4949

5050
@Test
51-
public void appDefault() throws Exception {
51+
void appDefault() throws Exception {
5252
registerApp(ApplicationType.source, "http", "4.0.0");
5353
registerApp(ApplicationType.source, "http", "5.0.0");
5454

@@ -70,7 +70,7 @@ public void appDefault() throws Exception {
7070
}
7171

7272
@Test
73-
public void registeringAnApplicationVersion() throws Exception {
73+
void registeringAnApplicationVersion() throws Exception {
7474
this.mockMvc.perform(
7575
post("/apps/{type}/{name}/{version:.+}", ApplicationType.source, "http", "4.0.0").queryParam("uri",
7676
"maven://org.springframework.cloud.stream.app:http-source-rabbit:4.0.0")
@@ -98,7 +98,7 @@ public void registeringAnApplicationVersion() throws Exception {
9898

9999

100100
@Test
101-
public void bulkRegisteringApps() throws Exception {
101+
void bulkRegisteringApps() throws Exception {
102102
this.mockMvc.perform(
103103
post("/apps")
104104
.param("apps", "source.http=maven://org.springframework.cloud.stream.app:http-source-rabbit:4.0.0")
@@ -117,7 +117,7 @@ public void bulkRegisteringApps() throws Exception {
117117
}
118118

119119
@Test
120-
public void getApplicationsFiltered() throws Exception {
120+
void getApplicationsFiltered() throws Exception {
121121
registerApp(ApplicationType.source, "http", "5.0.0");
122122
registerApp(ApplicationType.source, "time", "5.0.0");
123123
this.mockMvc.perform(
@@ -153,7 +153,7 @@ public void getApplicationsFiltered() throws Exception {
153153
}
154154

155155
@Test
156-
public void getSingleApplication() throws Exception {
156+
void getSingleApplication() throws Exception {
157157
registerApp(ApplicationType.source, "http", "5.0.0");
158158
this.mockMvc.perform(
159159
get("/apps/{type}/{name}", ApplicationType.source, "http").accept(MediaType.APPLICATION_JSON)
@@ -189,7 +189,7 @@ public void getSingleApplication() throws Exception {
189189
}
190190

191191
@Test
192-
public void registeringAnApplication() throws Exception {
192+
void registeringAnApplication() throws Exception {
193193
this.mockMvc.perform(
194194
post("/apps/{type}/{name}", ApplicationType.source, "http")
195195
.queryParam("uri", "maven://org.springframework.cloud.stream.app:http-source-rabbit:5.0.0")
@@ -213,7 +213,7 @@ public void registeringAnApplication() throws Exception {
213213
}
214214

215215
@Test
216-
public void unregisteringAnApplication() throws Exception {
216+
void unregisteringAnApplication() throws Exception {
217217
registerApp(ApplicationType.source, "http", "5.0.0");
218218

219219
this.mockMvc.perform(
@@ -231,7 +231,7 @@ public void unregisteringAnApplication() throws Exception {
231231
}
232232

233233
@Test
234-
public void unregisteringAllApplications() throws Exception {
234+
void unregisteringAllApplications() throws Exception {
235235
registerApp(ApplicationType.source, "http", "4.0.0");
236236
registerApp(ApplicationType.source, "http", "5.0.0");
237237
this.mockMvc.perform(

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AuditRecordsDocumentation.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
*/
4141
@SuppressWarnings("NewClassNamingConvention")
4242
@TestMethodOrder(MethodOrderer.MethodName.class)
43-
public class AuditRecordsDocumentation extends BaseDocumentation {
43+
class AuditRecordsDocumentation extends BaseDocumentation {
4444

4545
@BeforeEach
46-
public void setup() throws Exception {
46+
void setup() throws Exception {
4747
this.mockMvc.perform(
4848
post("/apps/{type}/time", "source")
4949
.param("uri", "maven://org.springframework.cloud.stream.app:time-source-rabbit:1.2.0.RELEASE"))
@@ -61,7 +61,7 @@ public void setup() throws Exception {
6161
}
6262

6363
@Test
64-
public void listAllAuditRecords() throws Exception {
64+
void listAllAuditRecords() throws Exception {
6565
this.mockMvc.perform(
6666
get("/audit-records")
6767
.param("page", "0")
@@ -91,7 +91,7 @@ public void listAllAuditRecords() throws Exception {
9191
}
9292

9393
@Test
94-
public void getAuditRecord() throws Exception {
94+
void getAuditRecord() throws Exception {
9595
this.mockMvc.perform(
9696
get("/audit-records/{id}", "5"))
9797
.andExpect(status().isOk())
@@ -114,15 +114,15 @@ public void getAuditRecord() throws Exception {
114114
}
115115

116116
@Test
117-
public void getAuditActionTypes() throws Exception {
117+
void getAuditActionTypes() throws Exception {
118118
this.mockMvc.perform(
119119
get("/audit-records/audit-action-types"))
120120
.andExpect(status().isOk()
121121
);
122122
}
123123

124124
@Test
125-
public void getAuditOperationTypes() throws Exception {
125+
void getAuditOperationTypes() throws Exception {
126126
this.mockMvc.perform(
127127
get("/audit-records/audit-operation-types"))
128128
.andExpect(status().isOk()

0 commit comments

Comments
 (0)