use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class LocalHostUriTemplateHandlerTests method getRootUriShouldUseContextPath.
@Test
public void getRootUriShouldUseContextPath() throws Exception {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("server.servlet.context-path", "/foo");
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(environment);
assertThat(handler.getRootUri()).isEqualTo("http://localhost:8080/foo");
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class CloudPlatformTests method getActiveWhenHasVcapServicesShouldReturnCloudFoundry.
@Test
public void getActiveWhenHasVcapServicesShouldReturnCloudFoundry() throws Exception {
Environment environment = new MockEnvironment().withProperty("VCAP_SERVICES", "---");
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.CLOUD_FOUNDRY);
assertThat(platform.isActive(environment)).isTrue();
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class CloudPlatformTests method getActiveWhenHasDynoShouldReturnHeroku.
@Test
public void getActiveWhenHasDynoShouldReturnHeroku() throws Exception {
Environment environment = new MockEnvironment().withProperty("DYNO", "---");
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.HEROKU);
assertThat(platform.isActive(environment)).isTrue();
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class CloudPlatformTests method getActiveWhenHasVcapApplicationShouldReturnCloudFoundry.
@Test
public void getActiveWhenHasVcapApplicationShouldReturnCloudFoundry() throws Exception {
Environment environment = new MockEnvironment().withProperty("VCAP_APPLICATION", "---");
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.CLOUD_FOUNDRY);
assertThat(platform.isActive(environment)).isTrue();
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class ConfigurationPropertiesBindingPostProcessorTests method testSuccessfulValidationWithInterface.
@Test
public void testSuccessfulValidationWithInterface() {
MockEnvironment env = new MockEnvironment();
env.setProperty("test.foo", "bar");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(TestConfigurationWithValidationAndInterface.class);
this.context.refresh();
assertThat(this.context.getBean(ValidatedPropertiesImpl.class).getFoo()).isEqualTo("bar");
}
Aggregations