diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java index af199cc05fb..b8dab150007 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java @@ -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())); } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java index 91154a68ba0..c4b09057ff4 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java @@ -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); }