Search in sources :

Example 66 with StandardEnvironment

use of org.springframework.core.env.StandardEnvironment in project Gaffer by gchq.

the class SwaggerConfigTest method shouldPullTitleFromSystemProperty.

@Test
public void shouldPullTitleFromSystemProperty() {
    // Given
    final String title = "My Gaffer Graph";
    SwaggerConfig swaggerConfig = new SwaggerConfig();
    swaggerConfig.setEnvironment(new StandardEnvironment());
    System.setProperty(APP_TITLE, title);
    // When
    ApiInfo apiInfo = swaggerConfig.apiInfo();
    // Then
    assertEquals(title, apiInfo.getTitle());
}
Also used : ApiInfo(springfox.documentation.service.ApiInfo) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 67 with StandardEnvironment

use of org.springframework.core.env.StandardEnvironment in project java-chassis by ServiceComb.

the class TestConfigurationSpringInitializer method shoud_throw_exception_when_given_ignoreResolveFailure_false.

@Test(expected = RuntimeException.class)
public void shoud_throw_exception_when_given_ignoreResolveFailure_false() {
    StandardEnvironment environment = newStandardEnvironment();
    ConfigurationSpringInitializer configurationSpringInitializer = new ConfigurationSpringInitializer();
    configurationSpringInitializer.setEnvironment(environment);
}
Also used : StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.Test)

Example 68 with StandardEnvironment

use of org.springframework.core.env.StandardEnvironment in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method testWithInactiveProfile.

@Test
public void testWithInactiveProfile() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    ConfigurableEnvironment env = new StandardEnvironment();
    env.setActiveProfiles("other");
    provider.setEnvironment(env);
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_PROFILE_PACKAGE);
    assertThat(containsBeanClass(candidates, ProfileAnnotatedComponent.class)).isFalse();
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 69 with StandardEnvironment

use of org.springframework.core.env.StandardEnvironment in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method testWithActiveProfile.

@Test
public void testWithActiveProfile() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    ConfigurableEnvironment env = new StandardEnvironment();
    env.setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
    provider.setEnvironment(env);
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_PROFILE_PACKAGE);
    assertThat(containsBeanClass(candidates, ProfileAnnotatedComponent.class)).isTrue();
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 70 with StandardEnvironment

use of org.springframework.core.env.StandardEnvironment in project spring-framework by spring-projects.

the class ConfigurationClassPostProcessorTests method assertSupportForComposedAnnotationWithExclude.

private void assertSupportForComposedAnnotationWithExclude(RootBeanDefinition beanDefinition) {
    beanFactory.registerBeanDefinition("config", beanDefinition);
    ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
    pp.setEnvironment(new StandardEnvironment());
    pp.postProcessBeanFactory(beanFactory);
    assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> beanFactory.getBean(SimpleComponent.class));
}
Also used : SimpleComponent(org.springframework.context.annotation.componentscan.simple.SimpleComponent) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) StandardEnvironment(org.springframework.core.env.StandardEnvironment)

Aggregations

StandardEnvironment (org.springframework.core.env.StandardEnvironment)146 Test (org.junit.jupiter.api.Test)63 MapPropertySource (org.springframework.core.env.MapPropertySource)52 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)42 Test (org.junit.Test)39 HashMap (java.util.HashMap)37 URI (java.net.URI)23 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)23 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)21 MutablePropertySources (org.springframework.core.env.MutablePropertySources)18 ProtobufMessageSerDe (com.kixeye.chassis.transport.serde.converter.ProtobufMessageSerDe)15 RestTemplate (org.springframework.web.client.RestTemplate)15 ServiceError (com.kixeye.chassis.transport.dto.ServiceError)14 JsonJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.JsonJacksonMessageSerDe)14 XmlMessageSerDe (com.kixeye.chassis.transport.serde.converter.XmlMessageSerDe)14 YamlJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.YamlJacksonMessageSerDe)14 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)13 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)13 QueuingWebSocketListener (com.kixeye.chassis.transport.websocket.QueuingWebSocketListener)9 WebSocketMessageRegistry (com.kixeye.chassis.transport.websocket.WebSocketMessageRegistry)9