use of org.springframework.mock.env.MockEnvironment in project coffeenet-starter by coffeenet.
the class CoffeeNetDiscoveryInstancePropertiesTest method applicationName.
@Test
public void applicationName() {
String brandNewApplicationName = "BrandNewApplicationName";
CoffeeNetConfigurationProperties coffeeNetConfigurationProperties = new CoffeeNetConfigurationProperties();
coffeeNetConfigurationProperties.setApplicationName(brandNewApplicationName);
CoffeeNetDiscoveryInstanceProperties sut = new CoffeeNetDiscoveryInstanceProperties(new InetUtils(new InetUtilsProperties()), new ServerProperties(), coffeeNetConfigurationProperties);
sut.setEnvironment(new MockEnvironment());
assertThat(sut.getAppname(), is(brandNewApplicationName));
assertThat(sut.getVirtualHostName(), is(brandNewApplicationName));
assertThat(sut.getSecureVirtualHostName(), is(brandNewApplicationName));
}
use of org.springframework.mock.env.MockEnvironment in project coffeenet-starter by coffeenet.
the class CoffeeNetDiscoveryInstancePropertiesTest method allowedAuthoritiesNotProvided.
@Test
public void allowedAuthoritiesNotProvided() {
CoffeeNetDiscoveryInstanceProperties sut = new CoffeeNetDiscoveryInstanceProperties(new InetUtils(new InetUtilsProperties()), new ServerProperties(), new CoffeeNetConfigurationProperties());
sut.getMetadataMap().put("allowedAuthorities", "alreadySetAndNoneFromCoffeeNet");
sut.setEnvironment(new MockEnvironment());
assertThat(sut.getMetadataMap().get("allowedAuthorities"), is("alreadySetAndNoneFromCoffeeNet"));
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot-admin by codecentric.
the class SpringBootAdminClientEnabledConditionTest method test_nonEmptyUrl_disabled.
@Test
public void test_nonEmptyUrl_disabled() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("spring.boot.admin.client.enabled", "false");
environment.setProperty("spring.boot.admin.url", "http://localhost:8080/management");
BDDMockito.given(conditionContext.getEnvironment()).willReturn(environment);
assertFalse(condition.getMatchOutcome(conditionContext, annotatedTypeMetadata).isMatch());
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot-admin by codecentric.
the class SpringBootAdminClientEnabledConditionTest method test_emptyUrl_enabled.
@Test
public void test_emptyUrl_enabled() {
MockEnvironment environment = new MockEnvironment();
BDDMockito.given(conditionContext.getEnvironment()).willReturn(environment);
assertFalse(condition.getMatchOutcome(conditionContext, annotatedTypeMetadata).isMatch());
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot-admin by codecentric.
the class DefaultApplicationFactoryTest method publishApplicationReadyEvent.
private void publishApplicationReadyEvent(DefaultApplicationFactory factory, Integer serverport, Integer managementport) {
MockEnvironment env = new MockEnvironment();
if (serverport != null) {
env.setProperty("local.server.port", serverport.toString());
}
if (managementport != null) {
env.setProperty("local.management.port", managementport.toString());
}
ConfigurableWebApplicationContext context = mock(ConfigurableWebApplicationContext.class);
when(context.getEnvironment()).thenReturn(env);
factory.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), new String[] {}, context));
}
Aggregations