From 6f2e133a0a32fe212e192e84b6468bf3c53165aa Mon Sep 17 00:00:00 2001 From: Jakub Kubrynski Date: Tue, 11 Feb 2014 15:44:20 +0100 Subject: [PATCH] Now custom SpringApplication class can be used when extending SpringApplicationContextLoader --- .../boot/test/SpringApplicationContextLoader.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java b/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java index 303e18a449..51073b09ce 100644 --- a/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java +++ b/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java @@ -58,7 +58,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader { public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { - SpringApplication application = new SpringApplication(); + SpringApplication application = getSpringApplication(); application.setSources(getSources(mergedConfig)); if (!ObjectUtils.isEmpty(mergedConfig.getActiveProfiles())) { application.setAdditionalProfiles(mergedConfig.getActiveProfiles()); @@ -77,6 +77,15 @@ public class SpringApplicationContextLoader extends AbstractContextLoader { return application.run(); } + /** + * Builds new {@link org.springframework.boot.SpringApplication} instance. You can override + * this method to add custom behaviour + * @return {@link org.springframework.boot.SpringApplication} instance + */ + protected SpringApplication getSpringApplication() { + return new SpringApplication(); + } + private Set getSources(MergedContextConfiguration mergedConfig) { Set sources = new LinkedHashSet(); sources.addAll(Arrays.asList(mergedConfig.getClasses()));