Polish
This commit is contained in:
parent
3e9c2b84b6
commit
7ff2cb5dc8
|
@ -17,9 +17,6 @@
|
||||||
package org.springframework.boot.actuate.autoconfigure.web.reactive;
|
package org.springframework.boot.actuate.autoconfigure.web.reactive;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.FatalBeanException;
|
import org.springframework.beans.FatalBeanException;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
|
@ -32,6 +29,7 @@ import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWeb
|
||||||
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link ManagementContextFactory} for reactive web applications.
|
* A {@link ManagementContextFactory} for reactive web applications.
|
||||||
|
@ -45,9 +43,9 @@ class ReactiveManagementContextFactory implements ManagementContextFactory {
|
||||||
ApplicationContext parent, Class<?>... configClasses) {
|
ApplicationContext parent, Class<?>... configClasses) {
|
||||||
AnnotationConfigReactiveWebServerApplicationContext child = new AnnotationConfigReactiveWebServerApplicationContext();
|
AnnotationConfigReactiveWebServerApplicationContext child = new AnnotationConfigReactiveWebServerApplicationContext();
|
||||||
child.setParent(parent);
|
child.setParent(parent);
|
||||||
List<Class<?>> combinedClasses = new ArrayList<>(Arrays.asList(configClasses));
|
Class<?>[] combinedClasses = ObjectUtils.addObjectToArray(configClasses,
|
||||||
combinedClasses.add(ReactiveWebServerAutoConfiguration.class);
|
ReactiveWebServerAutoConfiguration.class);
|
||||||
child.register(combinedClasses.toArray(new Class<?>[combinedClasses.size()]));
|
child.register(combinedClasses);
|
||||||
registerReactiveWebServerFactory(parent, child);
|
registerReactiveWebServerFactory(parent, child);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,18 @@ public class ReactiveManagementContextFactoryTests {
|
||||||
private AnnotationConfigReactiveWebServerApplicationContext parent = new AnnotationConfigReactiveWebServerApplicationContext();
|
private AnnotationConfigReactiveWebServerApplicationContext parent = new AnnotationConfigReactiveWebServerApplicationContext();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createManagementContextShouldCreateChildContextWithConfigClasses() throws Exception {
|
public void createManagementContextShouldCreateChildContextWithConfigClasses()
|
||||||
|
throws Exception {
|
||||||
this.parent.register(ParentConfiguration.class);
|
this.parent.register(ParentConfiguration.class);
|
||||||
this.parent.refresh();
|
this.parent.refresh();
|
||||||
AnnotationConfigReactiveWebServerApplicationContext childContext = (AnnotationConfigReactiveWebServerApplicationContext) this.factory.createManagementContext(this.parent,
|
AnnotationConfigReactiveWebServerApplicationContext childContext = (AnnotationConfigReactiveWebServerApplicationContext) this.factory
|
||||||
TestConfiguration1.class, TestConfiguration2.class);
|
.createManagementContext(this.parent, TestConfiguration1.class,
|
||||||
|
TestConfiguration2.class);
|
||||||
childContext.refresh();
|
childContext.refresh();
|
||||||
assertThat(childContext.getBean(TestConfiguration1.class)).isNotNull();
|
assertThat(childContext.getBean(TestConfiguration1.class)).isNotNull();
|
||||||
assertThat(childContext.getBean(TestConfiguration2.class)).isNotNull();
|
assertThat(childContext.getBean(TestConfiguration2.class)).isNotNull();
|
||||||
assertThat(childContext.getBean(ReactiveWebServerAutoConfiguration.class)).isNotNull();
|
assertThat(childContext.getBean(ReactiveWebServerAutoConfiguration.class))
|
||||||
|
.isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -410,8 +410,8 @@ public class SpringApplicationTests {
|
||||||
ExampleReactiveWebConfig.class);
|
ExampleReactiveWebConfig.class);
|
||||||
application.setWebApplicationType(WebApplicationType.REACTIVE);
|
application.setWebApplicationType(WebApplicationType.REACTIVE);
|
||||||
this.context = application.run();
|
this.context = application.run();
|
||||||
assertThat(this.context).isInstanceOf(
|
assertThat(this.context)
|
||||||
AnnotationConfigReactiveWebServerApplicationContext.class);
|
.isInstanceOf(AnnotationConfigReactiveWebServerApplicationContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue