24
24
25
25
import org .junit .jupiter .api .Test ;
26
26
27
+ import org .springframework .lang .Nullable ;
28
+
27
29
import static org .assertj .core .api .Assertions .assertThat ;
28
30
29
31
/**
34
36
*/
35
37
class CustomEnvironmentTests {
36
38
37
- // -- tests relating to customizing reserved default profiles ----------------------
38
-
39
39
@ Test
40
40
void control () {
41
41
Environment env = new AbstractEnvironment () { };
@@ -111,11 +111,12 @@ protected Set<String> getReservedDefaultProfiles() {
111
111
public void withNoProfileProperties () {
112
112
ConfigurableEnvironment env = new AbstractEnvironment () {
113
113
@ Override
114
+ @ Nullable
114
115
protected String doGetActiveProfilesProperty () {
115
116
return null ;
116
117
}
117
-
118
118
@ Override
119
+ @ Nullable
119
120
protected String doGetDefaultProfilesProperty () {
120
121
return null ;
121
122
}
@@ -140,23 +141,23 @@ class CustomMutablePropertySources extends MutablePropertySources {}
140
141
@ Test
141
142
void withCustomPropertyResolver () {
142
143
class CustomPropertySourcesPropertyResolver extends PropertySourcesPropertyResolver {
143
- public CustomPropertySourcesPropertyResolver (
144
- PropertySources propertySources ) {
144
+ public CustomPropertySourcesPropertyResolver (PropertySources propertySources ) {
145
145
super (propertySources );
146
146
}
147
-
148
147
@ Override
148
+ @ Nullable
149
149
public String getProperty (String key ) {
150
150
return super .getProperty (key )+"-test" ;
151
151
}
152
152
}
153
+
153
154
ConfigurableEnvironment env = new AbstractEnvironment () {
154
155
@ Override
155
- protected ConfigurablePropertyResolver createPropertyResolver (
156
- MutablePropertySources propertySources ) {
156
+ protected ConfigurablePropertyResolver createPropertyResolver (MutablePropertySources propertySources ) {
157
157
return new CustomPropertySourcesPropertyResolver (propertySources );
158
158
}
159
159
};
160
+
160
161
Map <String , Object > values = new LinkedHashMap <>();
161
162
values .put ("spring" , "framework" );
162
163
PropertySource <?> propertySource = new MapPropertySource ("test" , values );
@@ -168,6 +169,4 @@ private Profiles defaultProfile() {
168
169
return Profiles .of (AbstractEnvironment .RESERVED_DEFAULT_PROFILE_NAME );
169
170
}
170
171
171
-
172
- // -- tests relating to customizing property sources -------------------------------
173
172
}
0 commit comments