Search in sources :

Example 1 with InetUtilsProperties

use of org.springframework.cloud.commons.util.InetUtilsProperties 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 InetUtilsProperties

use of org.springframework.cloud.commons.util.InetUtilsProperties 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 InetUtilsProperties

use of org.springframework.cloud.commons.util.InetUtilsProperties 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 InetUtilsProperties

use of org.springframework.cloud.commons.util.InetUtilsProperties 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 InetUtilsProperties

use of org.springframework.cloud.commons.util.InetUtilsProperties in project coffeenet-starter by coffeenet.

the class CoffeeNetDiscoveryInstancePropertiesTest method setServerPort.

@Test
public void setServerPort() {
    int port = 9999;
    ServerProperties serverProperties = new ServerProperties();
    serverProperties.setPort(port);
    CoffeeNetDiscoveryInstanceProperties sut = new CoffeeNetDiscoveryInstanceProperties(new InetUtils(new InetUtilsProperties()), serverProperties, new CoffeeNetConfigurationProperties());
    assertThat(sut.getNonSecurePort(), is(port));
}
Also used : InetUtilsProperties(org.springframework.cloud.commons.util.InetUtilsProperties) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) CoffeeNetConfigurationProperties(coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties) InetUtils(org.springframework.cloud.commons.util.InetUtils) Test(org.junit.Test)

Aggregations

CoffeeNetConfigurationProperties (coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties)6 Test (org.junit.Test)6 ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)6 InetUtils (org.springframework.cloud.commons.util.InetUtils)6 InetUtilsProperties (org.springframework.cloud.commons.util.InetUtilsProperties)6 MockEnvironment (org.springframework.mock.env.MockEnvironment)4