Skip to content

Commit 2a52c47

Browse files
committed
Merge branch '3.0.x'
Closes gh-34870
2 parents a031bf4 + ace8cff commit 2a52c47

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -33,7 +33,9 @@
3333
*/
3434
public class RestDocsTestExecutionListener extends AbstractTestExecutionListener {
3535

36-
private static final String REST_DOCS_CLASS = "org.springframework.restdocs.ManualRestDocumentation";
36+
private static final boolean REST_DOCS_PRESENT = ClassUtils.isPresent(
37+
"org.springframework.restdocs.ManualRestDocumentation",
38+
RestDocsTestExecutionListener.class.getClassLoader());
3739

3840
@Override
3941
public int getOrder() {
@@ -42,22 +44,18 @@ public int getOrder() {
4244

4345
@Override
4446
public void beforeTestMethod(TestContext testContext) throws Exception {
45-
if (restDocsIsPresent()) {
47+
if (REST_DOCS_PRESENT) {
4648
new DocumentationHandler().beforeTestMethod(testContext);
4749
}
4850
}
4951

5052
@Override
5153
public void afterTestMethod(TestContext testContext) throws Exception {
52-
if (restDocsIsPresent()) {
54+
if (REST_DOCS_PRESENT) {
5355
new DocumentationHandler().afterTestMethod(testContext);
5456
}
5557
}
5658

57-
private boolean restDocsIsPresent() {
58-
return ClassUtils.isPresent(REST_DOCS_CLASS, getClass().getClassLoader());
59-
}
60-
6159
private static class DocumentationHandler {
6260

6361
private void beforeTestMethod(TestContext testContext) {

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerTestExecutionListener.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -33,7 +33,9 @@
3333
*/
3434
public class MockWebServiceServerTestExecutionListener extends AbstractTestExecutionListener {
3535

36-
private static final String MOCK_SERVER_CLASS = "org.springframework.ws.test.client.MockWebServiceServer";
36+
private static final boolean MOCK_SERVER_PRESENT = ClassUtils.isPresent(
37+
"org.springframework.ws.test.client.MockWebServiceServer",
38+
MockWebServiceServerTestExecutionListener.class.getClassLoader());
3739

3840
@Override
3941
public int getOrder() {
@@ -42,7 +44,7 @@ public int getOrder() {
4244

4345
@Override
4446
public void afterTestMethod(TestContext testContext) {
45-
if (isMockWebServiceServerPresent()) {
47+
if (MOCK_SERVER_PRESENT) {
4648
ApplicationContext applicationContext = testContext.getApplicationContext();
4749
String[] names = applicationContext.getBeanNamesForType(MockWebServiceServer.class, false, false);
4850
for (String name : names) {
@@ -53,8 +55,4 @@ public void afterTestMethod(TestContext testContext) {
5355
}
5456
}
5557

56-
private boolean isMockWebServiceServerPresent() {
57-
return ClassUtils.isPresent(MOCK_SERVER_CLASS, getClass().getClassLoader());
58-
}
59-
6058
}

0 commit comments

Comments
 (0)