Search in sources :

Example 1 with ServerProperties

use of org.springframework.boot.autoconfigure.web.ServerProperties 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));
}
Also used : InetUtilsProperties(org.springframework.cloud.commons.util.InetUtilsProperties) MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) CoffeeNetConfigurationProperties(coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties) InetUtils(org.springframework.cloud.commons.util.InetUtils) Test(org.junit.Test)

Example 2 with ServerProperties

use of org.springframework.boot.autoconfigure.web.ServerProperties 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));
}
Also used : InetUtilsProperties(org.springframework.cloud.commons.util.InetUtilsProperties) MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) CoffeeNetConfigurationProperties(coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties) InetUtils(org.springframework.cloud.commons.util.InetUtils) Test(org.junit.Test)

Example 3 with ServerProperties

use of org.springframework.boot.autoconfigure.web.ServerProperties 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));
}
Also used : InetUtilsProperties(org.springframework.cloud.commons.util.InetUtilsProperties) MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) CoffeeNetConfigurationProperties(coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties) InetUtils(org.springframework.cloud.commons.util.InetUtils) Test(org.junit.Test)

Example 4 with ServerProperties

use of org.springframework.boot.autoconfigure.web.ServerProperties 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"));
}
Also used : InetUtilsProperties(org.springframework.cloud.commons.util.InetUtilsProperties) MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) CoffeeNetConfigurationProperties(coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties) InetUtils(org.springframework.cloud.commons.util.InetUtils) Test(org.junit.Test)

Example 5 with ServerProperties

use of org.springframework.boot.autoconfigure.web.ServerProperties in project free-framework by a601942905git.

the class Application method onApplicationEvent.

@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    port = event.getEmbeddedServletContainer().getPort();
    ServerProperties serverProperties = (ServerProperties) ApplicationContextUtils.getBean(ServerProperties.class);
    applicationName = serverProperties.getDisplayName();
}
Also used : ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties)

Aggregations

ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)27 Test (org.junit.Test)13 MockEnvironment (org.springframework.mock.env.MockEnvironment)9 CoffeeNetConfigurationProperties (coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties)6 InetUtils (org.springframework.cloud.commons.util.InetUtils)6 InetUtilsProperties (org.springframework.cloud.commons.util.InetUtilsProperties)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 PropertyMapper (org.springframework.boot.context.properties.PropertyMapper)3 DataSize (org.springframework.util.unit.DataSize)3 Test (org.junit.jupiter.api.Test)2 UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Duration (java.time.Duration)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Lifecycle (org.apache.catalina.Lifecycle)1 AccessLogValve (org.apache.catalina.valves.AccessLogValve)1 ErrorReportValve (org.apache.catalina.valves.ErrorReportValve)1 RemoteIpValve (org.apache.catalina.valves.RemoteIpValve)1 AbstractProtocol (org.apache.coyote.AbstractProtocol)1