Search in sources :

Example 51 with MockEnvironment

use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizerTests method deduceUseForwardHeadersUndertow.

@Test
public void deduceUseForwardHeadersUndertow() throws Exception {
    this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
    UndertowServletWebServerFactory factory = spy(new UndertowServletWebServerFactory());
    this.customizer.customize(factory);
    verify(factory).setUseForwardHeaders(true);
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Test(org.junit.Test)

Example 52 with MockEnvironment

use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.

the class LocalHostUriTemplateHandlerTests method getRootUriUsesCustomScheme.

@Test
public void getRootUriUsesCustomScheme() {
    MockEnvironment environment = new MockEnvironment();
    LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(environment, "https");
    assertThat(handler.getRootUri()).isEqualTo("https://localhost:8080");
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) Test(org.junit.Test)

Example 53 with MockEnvironment

use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.

the class LocalHostUriTemplateHandlerTests method getRootUriShouldUseLocalServerPort.

@Test
public void getRootUriShouldUseLocalServerPort() throws Exception {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("local.server.port", "1234");
    LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(environment);
    assertThat(handler.getRootUri()).isEqualTo("http://localhost:1234");
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) Test(org.junit.Test)

Example 54 with MockEnvironment

use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.

the class LocalHostUriTemplateHandlerTests method createWhenSchemeIsNullShouldThrowException.

@Test
public void createWhenSchemeIsNullShouldThrowException() {
    this.thrown.expect(IllegalArgumentException.class);
    this.thrown.expectMessage("Scheme must not be null");
    new LocalHostUriTemplateHandler(new MockEnvironment(), null);
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) Test(org.junit.Test)

Example 55 with MockEnvironment

use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.

the class LocalHostUriTemplateHandlerTests method getRootUriWhenLocalServerPortMissingShouldUsePort8080.

@Test
public void getRootUriWhenLocalServerPortMissingShouldUsePort8080() throws Exception {
    MockEnvironment environment = new MockEnvironment();
    LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(environment);
    assertThat(handler.getRootUri()).isEqualTo("http://localhost:8080");
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) Test(org.junit.Test)

Aggregations

MockEnvironment (org.springframework.mock.env.MockEnvironment)65 Test (org.junit.Test)54 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)9 TestBean (org.springframework.tests.sample.beans.TestBean)7 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)6 Before (org.junit.Before)5 LoggingInitializationContext (org.springframework.boot.logging.LoggingInitializationContext)5 CoffeeNetConfigurationProperties (coffee.synyx.autoconfigure.CoffeeNetConfigurationProperties)4 URL (java.net.URL)4 ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)4 InetUtils (org.springframework.cloud.commons.util.InetUtils)4 InetUtilsProperties (org.springframework.cloud.commons.util.InetUtilsProperties)4 Environment (org.springframework.core.env.Environment)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 MutablePropertySources (org.springframework.core.env.MutablePropertySources)3 WebClient (com.gargoylesoftware.htmlunit.WebClient)2 WebConnection (com.gargoylesoftware.htmlunit.WebConnection)2