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