Stop using Constants utility in PropertyPlaceholderConfigurer
See gh-30851
This commit is contained in:
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -27,8 +30,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition;
|
||||
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
|
||||
import static org.springframework.beans.factory.support.BeanDefinitionReaderUtils.registerWithGeneratedName;
|
||||
@@ -235,4 +240,23 @@ class PropertyPlaceholderConfigurerTests {
|
||||
System.clearProperty("my.name");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test effectively verifies that the internal 'constants' map is properly
|
||||
* configured for all SYSTEM_PROPERTIES_MODE_ constants defined in
|
||||
* {@link PropertyPlaceholderConfigurer}.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void setSystemPropertiesModeNameToAllSupportedValues() {
|
||||
streamSystemPropertiesModeConstants()
|
||||
.map(Field::getName)
|
||||
.forEach(name -> assertThatNoException().as(name).isThrownBy(() -> ppc.setSystemPropertiesModeName(name)));
|
||||
}
|
||||
|
||||
private static Stream<Field> streamSystemPropertiesModeConstants() {
|
||||
return Arrays.stream(PropertyPlaceholderConfigurer.class.getFields())
|
||||
.filter(ReflectionUtils::isPublicStaticFinal)
|
||||
.filter(field -> field.getName().startsWith("SYSTEM_PROPERTIES_MODE_"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user