Java 类org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration 实例源码

项目:spring-cloud-stream    文件:AggregationTest.java   
@Test
@SuppressWarnings("unchecked")
public void testParentArgsAndSources() {
    List<String> argsToVerify = new ArrayList<>();
    argsToVerify.add("--foo1=bar1");
    argsToVerify.add("--foo2=bar2");
    argsToVerify.add("--foo3=bar3");
    argsToVerify.add("--server.port=0");
    AggregateApplicationBuilder aggregateApplicationBuilder = new AggregateApplicationBuilder(
            MockBinderRegistryConfiguration.class, "--foo1=bar1");
    final ConfigurableApplicationContext context = aggregateApplicationBuilder
            .parent(DummyConfig.class, "--foo2=bar2")
            .from(TestSource.class)
            .namespace("foo").to(TestProcessor.class).namespace("bar")
            .run("--foo3=bar3", "--server.port=0");
    DirectFieldAccessor aggregateApplicationBuilderAccessor = new DirectFieldAccessor(aggregateApplicationBuilder);
    final List<String> parentArgs = (List<String>) aggregateApplicationBuilderAccessor.getPropertyValue(
            "parentArgs");
    assertThat(parentArgs).containsExactlyInAnyOrder(argsToVerify.toArray(new String[argsToVerify.size()]));
    List<Object> sources = (List<Object>) aggregateApplicationBuilderAccessor.getPropertyValue("parentSources");
    assertThat(sources).containsExactlyInAnyOrder(AggregateApplicationBuilder.ParentConfiguration.class,
            MockBinderRegistryConfiguration.class, DummyConfig.class,
            ServletWebServerFactoryAutoConfiguration.class);
    context.close();
}
项目:spring-cloud-config    文件:EnvironmentMonitorAutoConfigurationTests.java   
@Test
public void test() {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(
            EnvironmentMonitorAutoConfiguration.class,
            ServletWebServerFactoryAutoConfiguration.class, ServerProperties.class,
            PropertyPlaceholderAutoConfiguration.class).properties("server.port=-1")
                    .run();
    PropertyPathEndpoint endpoint = context.getBean(PropertyPathEndpoint.class);
    assertEquals(4,
            ((Collection<?>) ReflectionTestUtils.getField(
                    ReflectionTestUtils.getField(endpoint, "extractor"),
                    "extractors")).size());
    context.close();
}
项目:spring-cloud-config    文件:EnvironmentMonitorAutoConfigurationTests.java   
@Test
public void testCanAddCustomPropertyPathNotificationExtractor() {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(
            CustomPropertyPathNotificationExtractorConfig.class,
            EnvironmentMonitorAutoConfiguration.class,
            ServletWebServerFactoryAutoConfiguration.class, ServerProperties.class,
            PropertyPlaceholderAutoConfiguration.class).properties("server.port=-1")
                    .run();
    PropertyPathEndpoint endpoint = context.getBean(PropertyPathEndpoint.class);
    assertEquals(5,
            ((Collection<?>) ReflectionTestUtils.getField(
                    ReflectionTestUtils.getField(endpoint, "extractor"),
                    "extractors")).size());
    context.close();
}