use of org.springframework.mock.env.MockEnvironment in project spring-framework by spring-projects.
the class TestPropertySourceUtilsTests method addInlinedPropertiesToEnvironmentWithMultipleKeyValuePairsInSingleInlinedProperty.
@Test
public void addInlinedPropertiesToEnvironmentWithMultipleKeyValuePairsInSingleInlinedProperty() {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Failed to load exactly one test environment property");
addInlinedPropertiesToEnvironment(new MockEnvironment(), asArray("a=b\nx=y"));
}
use of org.springframework.mock.env.MockEnvironment in project spring-framework by spring-projects.
the class TestPropertySourceUtilsTests method addPropertiesFilesToEnvironmentWithEnvironmentAndNullLocations.
@Test
public void addPropertiesFilesToEnvironmentWithEnvironmentAndNullLocations() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("must not be null");
addPropertiesFilesToEnvironment(new MockEnvironment(), mock(ResourceLoader.class), (String[]) null);
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class EndpointMBeanExportAutoConfigurationTests method testEndpointMBeanExporterWithProperties.
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException, InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class, EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(getObjectName("test-domain", "healthEndpoint", this.context).toString() + ",key1=value1,key2=value2"))).isNotNull();
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method deduceUseForwardHeadersJetty.
@Test
public void deduceUseForwardHeadersJetty() throws Exception {
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class LogFileMvcEndpointTests method before.
@Before
public void before() throws IOException {
this.logFile = this.temp.newFile();
FileCopyUtils.copy("--TEST--".getBytes(), this.logFile);
this.environment = new MockEnvironment();
this.mvc = new LogFileMvcEndpoint();
this.mvc.setEnvironment(this.environment);
}
Aggregations