use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class HealthMvcEndpointTests method init.
@Before
public void init() {
this.endpoint = mock(HealthEndpoint.class);
given(this.endpoint.isEnabled()).willReturn(true);
this.mvc = new HealthMvcEndpoint(this.endpoint);
this.environment = new MockEnvironment();
this.mvc.setEnvironment(this.environment);
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class JmxAutoConfigurationTests method testEnabledMBeanExport.
@Test
public void testEnabledMBeanExport() {
MockEnvironment env = new MockEnvironment();
env.setProperty("spring.jmx.enabled", "true");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(JmxAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(MBeanExporter.class)).isNotNull();
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class JmxAutoConfigurationTests method testDisabledMBeanExport.
@Test(expected = NoSuchBeanDefinitionException.class)
public void testDisabledMBeanExport() {
MockEnvironment env = new MockEnvironment();
env.setProperty("spring.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class);
this.context.refresh();
this.context.getBean(MBeanExporter.class);
}
use of org.springframework.mock.env.MockEnvironment in project coffeenet-starter by coffeenet.
the class CoffeeNetDiscoveryInstancePropertiesTest method allowedAuthorities.
@Test
public void allowedAuthorities() {
String allowedAuthorities = "COFFEENET-ADMIN,COFFEENET-USER";
CoffeeNetConfigurationProperties coffeeNetConfigurationProperties = new CoffeeNetConfigurationProperties();
coffeeNetConfigurationProperties.setAllowedAuthorities(allowedAuthorities);
CoffeeNetDiscoveryInstanceProperties sut = new CoffeeNetDiscoveryInstanceProperties(new InetUtils(new InetUtilsProperties()), new ServerProperties(), coffeeNetConfigurationProperties);
sut.setEnvironment(new MockEnvironment());
assertThat(sut.getMetadataMap().get("allowedAuthorities"), is(allowedAuthorities));
}
use of org.springframework.mock.env.MockEnvironment in project coffeenet-starter by coffeenet.
the class CoffeeNetDiscoveryInstancePropertiesTest method applicationNameIsUnknown.
@Test
public void applicationNameIsUnknown() {
CoffeeNetConfigurationProperties coffeeNetConfigurationProperties = new CoffeeNetConfigurationProperties();
coffeeNetConfigurationProperties.setApplicationName("");
CoffeeNetDiscoveryInstanceProperties sut = new CoffeeNetDiscoveryInstanceProperties(new InetUtils(new InetUtilsProperties()), new ServerProperties(), coffeeNetConfigurationProperties);
sut.setEnvironment(new MockEnvironment());
String unknownApplicationName = "unknown";
assertThat(sut.getAppname(), is(unknownApplicationName));
assertThat(sut.getVirtualHostName(), is(unknownApplicationName));
assertThat(sut.getSecureVirtualHostName(), is(unknownApplicationName));
}
Aggregations