Search in sources :

Example 96 with StandardEnvironment

use of cn.taketoday.core.env.StandardEnvironment in project today-framework by TAKETODAY.

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(cn.taketoday.core.env.ConfigurableEnvironment) BeanDefinition(cn.taketoday.beans.factory.config.BeanDefinition) ScannedGenericBeanDefinition(cn.taketoday.context.annotation.ScannedGenericBeanDefinition) StandardEnvironment(cn.taketoday.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Aggregations

StandardEnvironment (cn.taketoday.core.env.StandardEnvironment)96 Test (org.junit.jupiter.api.Test)88 ConfigurableEnvironment (cn.taketoday.core.env.ConfigurableEnvironment)46 MapPropertySource (cn.taketoday.core.env.MapPropertySource)24 PropertySources (cn.taketoday.core.env.PropertySources)18 StandardBeanFactory (cn.taketoday.beans.factory.support.StandardBeanFactory)8 MockConfigurationPropertySource (cn.taketoday.context.properties.source.MockConfigurationPropertySource)8 Environment (cn.taketoday.core.env.Environment)6 SystemEnvironmentPropertySource (cn.taketoday.core.env.SystemEnvironmentPropertySource)6 StandardServletEnvironment (cn.taketoday.web.context.support.StandardServletEnvironment)6 LinkedHashMap (java.util.LinkedHashMap)6 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)4 ConfigurableApplicationContext (cn.taketoday.context.ConfigurableApplicationContext)4 ClassPathScanningCandidateComponentProvider (cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider)4 MockEnvironment (cn.taketoday.context.support.MockEnvironment)4 AbstractEnvironment (cn.taketoday.core.env.AbstractEnvironment)4 CommandLinePropertySource (cn.taketoday.core.env.CommandLinePropertySource)4 CompositePropertySource (cn.taketoday.core.env.CompositePropertySource)4 MockPropertySource (cn.taketoday.core.env.MockPropertySource)4 PropertyResolver (cn.taketoday.core.env.PropertyResolver)4