Search in sources :

Example 26 with MockPropertySource

use of cn.taketoday.mock.env.MockPropertySource in project today-framework by TAKETODAY.

the class UnboundElementsSourceFilterTests method filterWhenSourceIsNotSystemShouldReturnTrue.

@Test
void filterWhenSourceIsNotSystemShouldReturnTrue() {
    MockPropertySource propertySource = new MockPropertySource("test");
    given(this.source.getUnderlyingSource()).willReturn(propertySource);
    assertThat(this.filter.apply(this.source)).isTrue();
}
Also used : MockPropertySource(cn.taketoday.mock.env.MockPropertySource) Test(org.junit.jupiter.api.Test)

Example 27 with MockPropertySource

use of cn.taketoday.mock.env.MockPropertySource in project today-framework by TAKETODAY.

the class UnboundElementsSourceFilterTests method filterWhenSourceIsSystemEnvironmentPropertySourceShouldReturnFalse.

@Test
void filterWhenSourceIsSystemEnvironmentPropertySourceShouldReturnFalse() {
    MockPropertySource propertySource = new MockPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
    given(this.source.getUnderlyingSource()).willReturn(propertySource);
    assertThat(this.filter.apply(this.source)).isFalse();
}
Also used : MockPropertySource(cn.taketoday.mock.env.MockPropertySource) Test(org.junit.jupiter.api.Test)

Example 28 with MockPropertySource

use of cn.taketoday.mock.env.MockPropertySource in project today-framework by TAKETODAY.

the class ConfigurationPropertySourceTests method fromCreatesConfigurationPropertySourcesPropertySource.

@Test
void fromCreatesConfigurationPropertySourcesPropertySource() {
    MockPropertySource source = new MockPropertySource();
    source.setProperty("spring", "boot");
    ConfigurationPropertySource adapted = ConfigurationPropertySource.from(source);
    assertThat(adapted.getConfigurationProperty(ConfigurationPropertyName.of("spring")).getValue()).isEqualTo("boot");
}
Also used : MockPropertySource(cn.taketoday.mock.env.MockPropertySource) Test(org.junit.jupiter.api.Test)

Example 29 with MockPropertySource

use of cn.taketoday.mock.env.MockPropertySource in project today-framework by TAKETODAY.

the class InvalidConfigDataPropertyExceptionTests method createInvalidProfileSpecificPropertyContributor.

private ConfigDataEnvironmentContributor createInvalidProfileSpecificPropertyContributor(String name, ConfigData.Option... configDataOptions) {
    MockPropertySource propertySource = new MockPropertySource();
    propertySource.setProperty(name, "a");
    ConfigDataEnvironmentContributor contributor = new ConfigDataEnvironmentContributor(Kind.BOUND_IMPORT, null, null, true, propertySource, ConfigurationPropertySource.from(propertySource), null, ConfigData.Options.of(configDataOptions), null);
    return contributor;
}
Also used : MockPropertySource(cn.taketoday.mock.env.MockPropertySource)

Example 30 with MockPropertySource

use of cn.taketoday.mock.env.MockPropertySource in project today-framework by TAKETODAY.

the class InvalidConfigDataPropertyExceptionTests method throwOrWarnWhenHasNoInvalidPropertyDoesNothing.

@Test
void throwOrWarnWhenHasNoInvalidPropertyDoesNothing() {
    ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofExisting(new MockPropertySource());
    InvalidConfigDataPropertyException.throwIfPropertyFound(contributor);
}
Also used : MockPropertySource(cn.taketoday.mock.env.MockPropertySource) Test(org.junit.jupiter.api.Test)

Aggregations

MockPropertySource (cn.taketoday.mock.env.MockPropertySource)88 Test (org.junit.jupiter.api.Test)84 Binder (cn.taketoday.context.properties.bind.Binder)16 LinkedHashMap (java.util.LinkedHashMap)12 MockServletContext (cn.taketoday.mock.web.MockServletContext)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 PropertySource (cn.taketoday.core.env.PropertySource)4 MockServletConfig (cn.taketoday.mock.web.MockServletConfig)4 MapPropertySource (cn.taketoday.core.env.MapPropertySource)2 AddedPropertySource (cn.taketoday.framework.context.config.TestConfigDataEnvironmentUpdateListener.AddedPropertySource)2 AbstractRefreshableWebApplicationContext (cn.taketoday.web.context.support.AbstractRefreshableWebApplicationContext)2 AnnotationConfigWebApplicationContext (cn.taketoday.web.context.support.AnnotationConfigWebApplicationContext)2 GenericWebServletApplicationContext (cn.taketoday.web.context.support.GenericWebServletApplicationContext)2 StaticWebServletApplicationContext (cn.taketoday.web.context.support.StaticWebServletApplicationContext)2