From 3d99a5dd9889feb7ef2affa53d95ad58403604d0 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 26 May 2014 06:40:50 +0100 Subject: [PATCH] Add test for inaccessible configuration class See gh-948 --- .../boot/SpringApplicationTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 91c7061768a..a76d771ca37 100644 --- a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -110,6 +110,13 @@ public class SpringApplicationTests { new SpringApplication().run(); } + @Test + public void sourcesMustBeAccessible() throws Exception { + this.thrown.expect(IllegalStateException.class); + this.thrown.expectMessage("Cannot load configuration"); + new SpringApplication(InaccessibleConfiguration.class).run(); + } + @Test public void disableBanner() throws Exception { SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); @@ -269,7 +276,7 @@ public class SpringApplicationTests { } @Test - public void proprtiesFileEnhancesEnvironment() throws Exception { + public void propertiesFileEnhancesEnvironment() throws Exception { SpringApplication application = new SpringApplication(ExampleConfig.class); application.setWebEnvironment(false); ConfigurableEnvironment environment = new StandardEnvironment(); @@ -468,6 +475,14 @@ public class SpringApplicationTests { return false; } + @Configuration + protected static class InaccessibleConfiguration { + + private InaccessibleConfiguration() { + } + + } + public static class SpyApplicationContext extends AnnotationConfigApplicationContext { ConfigurableApplicationContext applicationContext = spy(new AnnotationConfigApplicationContext());