Nullability refinements

See gh-26462
This commit is contained in:
Juergen Hoeller
2021-02-16 08:51:42 +01:00
parent ed9ec58caa
commit 9417975f66
2 changed files with 11 additions and 10 deletions

View File

@@ -24,6 +24,8 @@ import java.util.Set;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -34,8 +36,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class CustomEnvironmentTests {
// -- tests relating to customizing reserved default profiles ----------------------
@Test
void control() {
Environment env = new AbstractEnvironment() { };
@@ -111,11 +111,12 @@ class CustomEnvironmentTests {
public void withNoProfileProperties() {
ConfigurableEnvironment env = new AbstractEnvironment() {
@Override
@Nullable
protected String doGetActiveProfilesProperty() {
return null;
}
@Override
@Nullable
protected String doGetDefaultProfilesProperty() {
return null;
}
@@ -140,23 +141,23 @@ class CustomEnvironmentTests {
@Test
void withCustomPropertyResolver() {
class CustomPropertySourcesPropertyResolver extends PropertySourcesPropertyResolver {
public CustomPropertySourcesPropertyResolver(
PropertySources propertySources) {
public CustomPropertySourcesPropertyResolver(PropertySources propertySources) {
super(propertySources);
}
@Override
@Nullable
public String getProperty(String key) {
return super.getProperty(key)+"-test";
}
}
ConfigurableEnvironment env = new AbstractEnvironment() {
@Override
protected ConfigurablePropertyResolver createPropertyResolver(
MutablePropertySources propertySources) {
protected ConfigurablePropertyResolver createPropertyResolver(MutablePropertySources propertySources) {
return new CustomPropertySourcesPropertyResolver(propertySources);
}
};
Map<String, Object> values = new LinkedHashMap<>();
values.put("spring", "framework");
PropertySource<?> propertySource = new MapPropertySource("test", values);
@@ -168,6 +169,4 @@ class CustomEnvironmentTests {
return Profiles.of(AbstractEnvironment.RESERVED_DEFAULT_PROFILE_NAME);
}
// -- tests relating to customizing property sources -------------------------------
}