use of cn.taketoday.mock.env.MockPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataEnvironmentContributorTests method isActiveWhenPropertiesIsNotActiveReturnsFalse.
@Test
void isActiveWhenPropertiesIsNotActiveReturnsFalse() {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("context.config.activate.on-cloud-platform", "heroku");
ConfigData configData = new ConfigData(Collections.singleton(propertySource));
ConfigDataEnvironmentContributor contributor = createBoundContributor(null, configData, 0);
assertThat(contributor.isActive(this.activationContext)).isFalse();
}
use of cn.taketoday.mock.env.MockPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataEnvironmentContributorTests method isActiveWhenPropertiesIsActiveReturnsTrue.
@Test
void isActiveWhenPropertiesIsActiveReturnsTrue() {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("context.config.activate.on-cloud-platform", "kubernetes");
ConfigData configData = new ConfigData(Collections.singleton(propertySource));
ConfigDataEnvironmentContributor contributor = createBoundContributor(null, configData, 0);
assertThat(contributor.isActive(this.activationContext)).isTrue();
}
use of cn.taketoday.mock.env.MockPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataEnvironmentContributorTests method bindCreatesImportedContributor.
@Test
void bindCreatesImportedContributor() {
TestResource resource = new TestResource("test");
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("context.config.import", "test");
ConfigData configData = new ConfigData(Collections.singleton(propertySource));
ConfigDataEnvironmentContributor contributor = createBoundContributor(resource, configData, 0);
assertThat(contributor.getKind()).isEqualTo(Kind.BOUND_IMPORT);
assertThat(contributor.getResource()).isSameAs(resource);
assertThat(contributor.getImports()).containsExactly(TEST_LOCATION);
assertThat(contributor.isActive(this.activationContext)).isTrue();
assertThat(contributor.getPropertySource()).isEqualTo(propertySource);
assertThat(contributor.getConfigurationPropertySource()).isNotNull();
assertThat(contributor.getChildren(ImportPhase.BEFORE_PROFILE_ACTIVATION)).isEmpty();
}
use of cn.taketoday.mock.env.MockPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataEnvironmentContributorTests method getConfigurationPropertySourceReturnsAdaptedPropertySource.
@Test
void getConfigurationPropertySourceReturnsAdaptedPropertySource() {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("spring", "boot");
ConfigData configData = new ConfigData(Collections.singleton(propertySource));
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofUnboundImport(null, null, false, configData, 0);
assertThat(contributor.getConfigurationPropertySource().getConfigurationProperty(ConfigurationPropertyName.of("spring")).getValue()).isEqualTo("boot");
}
use of cn.taketoday.mock.env.MockPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataEnvironmentContributorTests method getImportsIgnoresEmptyElements.
@Test
void getImportsIgnoresEmptyElements() {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("context.config.import", "spring,,boot,");
ConfigData configData = new ConfigData(Collections.singleton(propertySource));
ConfigDataEnvironmentContributor contributor = createBoundContributor(null, configData, 0);
assertThat(contributor.getImports()).containsExactly(ConfigDataLocation.valueOf("spring"), ConfigDataLocation.valueOf("boot"));
}
Aggregations