Polish "Validate excluded autoconfiguration classes"
- Apply code formatting - Move configuration of excepted exception to immediately before line that will throw the exception - Use String.format with %n to produce platform-specific new lines See gh-7407
This commit is contained in:
parent
a9ffdca6f2
commit
65d0c07fd6
|
|
@ -57,6 +57,7 @@ import org.springframework.util.ClassUtils;
|
|||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
* @author Madhura Bhave
|
||||
* @since 1.3.0
|
||||
* @see EnableAutoConfiguration
|
||||
*/
|
||||
|
|
@ -164,13 +165,14 @@ public class EnableAutoConfigurationImportSelector
|
|||
for (String exclusion : exclusions) {
|
||||
if (ClassUtils.isPresent(exclusion, getClass().getClassLoader())
|
||||
&& !configurations.contains(exclusion)) {
|
||||
message.append("\t- ").append(exclusion).append("\n");
|
||||
message.append("\t- ").append(exclusion).append(String.format("%n"));
|
||||
}
|
||||
}
|
||||
if (!message.toString().isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"The following classes could not be excluded because they are not auto-configuration classes:\n"
|
||||
+ message.toString());
|
||||
throw new IllegalStateException(String.format(
|
||||
"The following classes could not be excluded because they are"
|
||||
+ " not auto-configuration classes:%n%s",
|
||||
message.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import static org.mockito.BDDMockito.given;
|
|||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
public class EnableAutoConfigurationImportSelectorTests {
|
||||
|
||||
|
|
@ -173,30 +173,31 @@ public class EnableAutoConfigurationImportSelectorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationClassExclusionsShouldThrowException() throws Exception {
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
public void nonAutoConfigurationClassExclusionsShouldThrowException()
|
||||
throws Exception {
|
||||
configureExclusions(new String[] { TestConfiguration.class.getName() },
|
||||
new String[0], new String[0]);
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
this.importSelector.selectImports(this.annotationMetadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationClassNameExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
throws Exception {
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
configureExclusions(new String[0],
|
||||
new String[] { "org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelectorTests.TestConfiguration" },
|
||||
new String[] {
|
||||
"org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelectorTests.TestConfiguration" },
|
||||
new String[0]);
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
this.importSelector.selectImports(this.annotationMetadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationPropertyExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
public void nonAutoConfigurationPropertyExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
throws Exception {
|
||||
configureExclusions(new String[0], new String[0], new String[] {
|
||||
"org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelectorTests.TestConfiguration" });
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
configureExclusions(new String[0],
|
||||
new String[0],
|
||||
new String[] { "org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelectorTests.TestConfiguration" });
|
||||
this.importSelector.selectImports(this.annotationMetadata);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue