Commit 3d99a5dd authored by Dave Syer's avatar Dave Syer

Add test for inaccessible configuration class

See gh-948
parent f1f36cd0
...@@ -110,6 +110,13 @@ public class SpringApplicationTests { ...@@ -110,6 +110,13 @@ public class SpringApplicationTests {
new SpringApplication().run(); 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 @Test
public void disableBanner() throws Exception { public void disableBanner() throws Exception {
SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
...@@ -269,7 +276,7 @@ public class SpringApplicationTests { ...@@ -269,7 +276,7 @@ public class SpringApplicationTests {
} }
@Test @Test
public void proprtiesFileEnhancesEnvironment() throws Exception { public void propertiesFileEnhancesEnvironment() throws Exception {
SpringApplication application = new SpringApplication(ExampleConfig.class); SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebEnvironment(false); application.setWebEnvironment(false);
ConfigurableEnvironment environment = new StandardEnvironment(); ConfigurableEnvironment environment = new StandardEnvironment();
...@@ -468,6 +475,14 @@ public class SpringApplicationTests { ...@@ -468,6 +475,14 @@ public class SpringApplicationTests {
return false; return false;
} }
@Configuration
protected static class InaccessibleConfiguration {
private InaccessibleConfiguration() {
}
}
public static class SpyApplicationContext extends AnnotationConfigApplicationContext { public static class SpyApplicationContext extends AnnotationConfigApplicationContext {
ConfigurableApplicationContext applicationContext = spy(new AnnotationConfigApplicationContext()); ConfigurableApplicationContext applicationContext = spy(new AnnotationConfigApplicationContext());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment