@ -36,6 +36,7 @@ import org.junit.Rule;
@@ -36,6 +36,7 @@ import org.junit.Rule;
import org.junit.Test ;
import org.junit.rules.ExpectedException ;
import org.mockito.ArgumentCaptor ;
import reactor.core.publisher.Mono ;
import org.springframework.beans.BeansException ;
import org.springframework.beans.CachedIntrospectionResults ;
@ -44,6 +45,7 @@ import org.springframework.beans.factory.support.BeanNameGenerator;
@@ -44,6 +45,7 @@ import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.DefaultBeanNameGenerator ;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext ;
import org.springframework.boot.context.embedded.ReactiveWebApplicationContext ;
import org.springframework.boot.context.embedded.reactor.ReactorNettyReactiveWebServerFactory ;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory ;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent ;
import org.springframework.boot.context.event.ApplicationPreparedEvent ;
@ -77,6 +79,7 @@ import org.springframework.core.io.ClassPathResource;
@@ -77,6 +79,7 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.DefaultResourceLoader ;
import org.springframework.core.io.Resource ;
import org.springframework.core.io.ResourceLoader ;
import org.springframework.http.server.reactive.HttpHandler ;
import org.springframework.test.context.support.TestPropertySourceUtils ;
import org.springframework.util.ReflectionUtils ;
import org.springframework.util.StringUtils ;
@ -400,7 +403,7 @@ public class SpringApplicationTests {
@@ -400,7 +403,7 @@ public class SpringApplicationTests {
@Test
public void defaultApplicationContextForReactiveWeb ( ) throws Exception {
SpringApplication application = new SpringApplication ( ExampleWebConfig . class ) ;
SpringApplication application = new SpringApplication ( ExampleReactive WebConfig . class ) ;
application . setWebApplicationType ( WebApplicationType . REACTIVE ) ;
this . context = application . run ( ) ;
assertThat ( this . context ) . isInstanceOf ( ReactiveWebApplicationContext . class ) ;
@ -571,7 +574,7 @@ public class SpringApplicationTests {
@@ -571,7 +574,7 @@ public class SpringApplicationTests {
@Test
public void loadSources ( ) throws Exception {
Object [ ] sources = { ExampleConfig . class , "a" , TestCommandLineRunner . class } ;
Object [ ] sources = { ExampleConfig . class , "a" , TestCommandLineRunner . class } ;
TestSpringApplication application = new TestSpringApplication ( sources ) ;
application . setWebApplicationType ( WebApplicationType . NONE ) ;
application . setUseMockLoader ( true ) ;
@ -583,7 +586,7 @@ public class SpringApplicationTests {
@@ -583,7 +586,7 @@ public class SpringApplicationTests {
@Test
public void wildcardSources ( ) {
Object [ ] sources = {
"classpath:org/springframework/boot/sample-${sample.app.test.prop}.xml" } ;
"classpath:org/springframework/boot/sample-${sample.app.test.prop}.xml" } ;
TestSpringApplication application = new TestSpringApplication ( sources ) ;
application . setWebApplicationType ( WebApplicationType . NONE ) ;
this . context = application . run ( ) ;
@ -598,7 +601,7 @@ public class SpringApplicationTests {
@@ -598,7 +601,7 @@ public class SpringApplicationTests {
@Test
public void runComponents ( ) throws Exception {
this . context = SpringApplication . run (
new Object [ ] { ExampleWebConfig . class , Object . class } , new String [ 0 ] ) ;
new Object [ ] { ExampleWebConfig . class , Object . class } , new String [ 0 ] ) ;
assertThat ( this . context ) . isNotNull ( ) ;
}
@ -713,7 +716,7 @@ public class SpringApplicationTests {
@@ -713,7 +716,7 @@ public class SpringApplicationTests {
public void defaultCommandLineArgs ( ) throws Exception {
SpringApplication application = new SpringApplication ( ExampleConfig . class ) ;
application . setDefaultProperties ( StringUtils . splitArrayElementsIntoProperties (
new String [ ] { "baz=" , "bar=spam" } , "=" ) ) ;
new String [ ] { "baz=" , "bar=spam" } , "=" ) ) ;
application . setWebApplicationType ( WebApplicationType . NONE ) ;
this . context = application . run ( "--bar=foo" , "bucket" , "crap" ) ;
assertThat ( this . context ) . isInstanceOf ( AnnotationConfigApplicationContext . class ) ;
@ -864,7 +867,7 @@ public class SpringApplicationTests {
@@ -864,7 +867,7 @@ public class SpringApplicationTests {
assertThat ( this . context . getEnvironment ( ) . getProperty ( "foo" ) ) . isEqualTo ( "bar" ) ;
assertThat ( this . context . getEnvironment ( ) . getPropertySources ( ) . iterator ( ) . next ( )
. getName ( ) ) . isEqualTo (
TestPropertySourceUtils . INLINED_PROPERTIES_PROPERTY_SOURCE_NAME ) ;
TestPropertySourceUtils . INLINED_PROPERTIES_PROPERTY_SOURCE_NAME ) ;
}
@Test
@ -877,7 +880,7 @@ public class SpringApplicationTests {
@@ -877,7 +880,7 @@ public class SpringApplicationTests {
FailingConfig . class ) ;
application . setWebApplicationType ( WebApplicationType . NONE ) ;
application . run ( ) ;
} ;
}
} ;
thread . start ( ) ;
thread . join ( 6000 ) ;
@ -1028,6 +1031,22 @@ public class SpringApplicationTests {
@@ -1028,6 +1031,22 @@ public class SpringApplicationTests {
}
@Configuration
static class ExampleReactiveWebConfig {
@Bean
public ReactorNettyReactiveWebServerFactory webServerFactory ( ) {
return new ReactorNettyReactiveWebServerFactory ( 0 ) ;
}
@Bean
public HttpHandler httpHandler ( ) {
return ( serverHttpRequest , serverHttpResponse ) - > Mono . empty ( ) ;
}
}
@Configuration
static class FailingConfig {