List of usage examples for org.springframework.boot.web.context ServerPortInfoApplicationContextInitializer ServerPortInfoApplicationContextInitializer
ServerPortInfoApplicationContextInitializer
From source file:org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfigurationTests.java
@Test public void portPropertiesOnSamePort() throws Exception { this.applicationContext.register(RootConfig.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class); new ServerPortInfoApplicationContextInitializer().initialize(this.applicationContext); this.applicationContext.refresh(); Integer localServerPort = this.applicationContext.getEnvironment().getProperty("local.server.port", Integer.class); Integer localManagementPort = this.applicationContext.getEnvironment().getProperty("local.management.port", Integer.class); assertThat(localServerPort).isNotNull(); assertThat(localManagementPort).isNotNull(); assertThat(localServerPort).isEqualTo(localManagementPort); }
From source file:org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfigurationTests.java
@Test public void portPropertiesOnDifferentPort() throws Exception { EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=" + ports.get().management); new ServerPortInfoApplicationContextInitializer().initialize(this.applicationContext); this.applicationContext.register(RootConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); this.applicationContext.refresh(); Integer localServerPort = this.applicationContext.getEnvironment().getProperty("local.server.port", Integer.class); Integer localManagementPort = this.applicationContext.getEnvironment().getProperty("local.management.port", Integer.class); assertThat(localServerPort).isNotNull(); assertThat(localManagementPort).isNotNull(); assertThat(localServerPort).isNotEqualTo(localManagementPort); }