@@ -82,7 +82,7 @@ public class ConfigFileApplicationListenerTests {
82
82
83
83
@ After
84
84
public void cleanup () {
85
- System .clearProperty ("my .property" );
85
+ System .clearProperty ("the .property" );
86
86
System .clearProperty ("spring.config.location" );
87
87
System .clearProperty ("spring.main.showBanner" );
88
88
}
@@ -93,7 +93,7 @@ public void loadCustomResource() throws Exception {
93
93
@ Override
94
94
public Resource getResource (final String location ) {
95
95
if (location .equals ("classpath:/custom.properties" )) {
96
- return new ByteArrayResource ("my .property: fromcustom" .getBytes (),
96
+ return new ByteArrayResource ("the .property: fromcustom" .getBytes (),
97
97
location ) {
98
98
@ Override
99
99
public String getFilename () {
@@ -111,15 +111,15 @@ public ClassLoader getClassLoader() {
111
111
});
112
112
this .initializer .setSearchNames ("custom" );
113
113
this .initializer .onApplicationEvent (this .event );
114
- String property = this .environment .getProperty ("my .property" );
114
+ String property = this .environment .getProperty ("the .property" );
115
115
assertThat (property , equalTo ("fromcustom" ));
116
116
}
117
117
118
118
@ Test
119
119
public void loadPropertiesFile () throws Exception {
120
120
this .initializer .setSearchNames ("testproperties" );
121
121
this .initializer .onApplicationEvent (this .event );
122
- String property = this .environment .getProperty ("my .property" );
122
+ String property = this .environment .getProperty ("the .property" );
123
123
assertThat (property , equalTo ("frompropertiesfile" ));
124
124
}
125
125
@@ -128,7 +128,7 @@ public void loadTwoPropertiesFile() throws Exception {
128
128
EnvironmentTestUtils .addEnvironment (this .environment , "spring.config.location:"
129
129
+ "classpath:application.properties,classpath:testproperties.properties" );
130
130
this .initializer .onApplicationEvent (this .event );
131
- String property = this .environment .getProperty ("my .property" );
131
+ String property = this .environment .getProperty ("the .property" );
132
132
assertThat (property , equalTo ("frompropertiesfile" ));
133
133
}
134
134
@@ -152,7 +152,7 @@ public void loadTwoPropertiesFilesWithProfilesAndSwitchOneOff() throws Exception
152
152
assertEquals ("myprofile" ,
153
153
StringUtils .arrayToCommaDelimitedString (this .environment
154
154
.getActiveProfiles ()));
155
- String property = this .environment .getProperty ("my .property" );
155
+ String property = this .environment .getProperty ("the .property" );
156
156
// The value from the second file wins (no profile specific configuration is
157
157
// actually loaded)
158
158
assertThat (property , equalTo ("frompropertiesfile" ));
@@ -168,7 +168,7 @@ public void loadTwoPropertiesFilesWithProfilesAndSwitchOneOffFromSpecificLocatio
168
168
assertEquals ("myprofile" ,
169
169
StringUtils .arrayToCommaDelimitedString (this .environment
170
170
.getActiveProfiles ()));
171
- String property = this .environment .getProperty ("my .property" );
171
+ String property = this .environment .getProperty ("the .property" );
172
172
// The value from the second file wins (no profile specific configuration is
173
173
// actually loaded)
174
174
assertThat (property , equalTo ("frompropertiesfile" ));
@@ -180,7 +180,7 @@ public void localFileTakesPrecedenceOverClasspath() throws Exception {
180
180
assertThat (localFile .exists (), equalTo (false ));
181
181
try {
182
182
Properties properties = new Properties ();
183
- properties .put ("my .property" , "fromlocalfile" );
183
+ properties .put ("the .property" , "fromlocalfile" );
184
184
OutputStream out = new FileOutputStream (localFile );
185
185
try {
186
186
properties .store (out , "" );
@@ -189,7 +189,7 @@ public void localFileTakesPrecedenceOverClasspath() throws Exception {
189
189
out .close ();
190
190
}
191
191
this .initializer .onApplicationEvent (this .event );
192
- String property = this .environment .getProperty ("my .property" );
192
+ String property = this .environment .getProperty ("the .property" );
193
193
assertThat (property , equalTo ("fromlocalfile" ));
194
194
}
195
195
finally {
@@ -213,7 +213,7 @@ public void loadTwoOfThreePropertiesFile() throws Exception {
213
213
+ "classpath:testproperties.properties,"
214
214
+ "classpath:nonexistent.properties" );
215
215
this .initializer .onApplicationEvent (this .event );
216
- String property = this .environment .getProperty ("my .property" );
216
+ String property = this .environment .getProperty ("the .property" );
217
217
assertThat (property , equalTo ("frompropertiesfile" ));
218
218
}
219
219
@@ -228,7 +228,7 @@ public void randomValue() throws Exception {
228
228
public void loadTwoPropertiesFiles () throws Exception {
229
229
this .initializer .setSearchNames ("moreproperties,testproperties" );
230
230
this .initializer .onApplicationEvent (this .event );
231
- String property = this .environment .getProperty ("my .property" );
231
+ String property = this .environment .getProperty ("the .property" );
232
232
// The search order has highest precedence last (like merging a map)
233
233
assertThat (property , equalTo ("frompropertiesfile" ));
234
234
}
@@ -246,19 +246,19 @@ public void loadYamlFile() throws Exception {
246
246
@ Test
247
247
public void commandLineWins () throws Exception {
248
248
this .environment .getPropertySources ().addFirst (
249
- new SimpleCommandLinePropertySource ("--my .property=fromcommandline" ));
249
+ new SimpleCommandLinePropertySource ("--the .property=fromcommandline" ));
250
250
this .initializer .setSearchNames ("testproperties" );
251
251
this .initializer .onApplicationEvent (this .event );
252
- String property = this .environment .getProperty ("my .property" );
252
+ String property = this .environment .getProperty ("the .property" );
253
253
assertThat (property , equalTo ("fromcommandline" ));
254
254
}
255
255
256
256
@ Test
257
257
public void systemPropertyWins () throws Exception {
258
- System .setProperty ("my .property" , "fromsystem" );
258
+ System .setProperty ("the .property" , "fromsystem" );
259
259
this .initializer .setSearchNames ("testproperties" );
260
260
this .initializer .onApplicationEvent (this .event );
261
- String property = this .environment .getProperty ("my .property" );
261
+ String property = this .environment .getProperty ("the .property" );
262
262
assertThat (property , equalTo ("fromsystem" ));
263
263
}
264
264
@@ -285,7 +285,7 @@ public void defaultPropertyAsFallbackDuringFileParsing() throws Exception {
285
285
.singletonMap ("spring.config.name" ,
286
286
(Object ) "testproperties" )));
287
287
this .initializer .onApplicationEvent (this .event );
288
- String property = this .environment .getProperty ("my .property" );
288
+ String property = this .environment .getProperty ("the .property" );
289
289
assertThat (property , equalTo ("frompropertiesfile" ));
290
290
}
291
291
@@ -318,7 +318,7 @@ public void twoProfilesFromProperties() throws Exception {
318
318
public void loadPropertiesThenProfilePropertiesActivatedInFirst () throws Exception {
319
319
this .initializer .setSearchNames ("enableprofile" );
320
320
this .initializer .onApplicationEvent (this .event );
321
- String property = this .environment .getProperty ("my .property" );
321
+ String property = this .environment .getProperty ("the .property" );
322
322
// The "myprofile" profile is activated in enableprofile.properties so its value
323
323
// should show up here
324
324
assertThat (property , equalTo ("fromprofilepropertiesfile" ));
@@ -334,7 +334,7 @@ public void loadPropertiesThenProfilePropertiesWithOverride() throws Exception {
334
334
String property = this .environment .getProperty ("other.property" );
335
335
// The "other" profile is activated before any processing starts
336
336
assertThat (property , equalTo ("fromotherpropertiesfile" ));
337
- property = this .environment .getProperty ("my .property" );
337
+ property = this .environment .getProperty ("the .property" );
338
338
// The "myprofile" profile is activated in enableprofile.properties and "other"
339
339
// was not activated by setting spring.profiles.active so "myprofile" should still
340
340
// be activated
@@ -428,7 +428,7 @@ public void specificResource() throws Exception {
428
428
EnvironmentTestUtils .addEnvironment (this .environment , "spring.config.location:"
429
429
+ location );
430
430
this .initializer .onApplicationEvent (this .event );
431
- String property = this .environment .getProperty ("my .property" );
431
+ String property = this .environment .getProperty ("the .property" );
432
432
assertThat (property , equalTo ("fromspecificlocation" ));
433
433
assertThat (this .environment , containsPropertySource ("applicationConfig: "
434
434
+ "[classpath:specificlocation.properties]" ));
@@ -463,7 +463,7 @@ public void propertySourceAnnotation() throws Exception {
463
463
SpringApplication application = new SpringApplication (WithPropertySource .class );
464
464
application .setWebEnvironment (false );
465
465
ConfigurableApplicationContext context = application .run ();
466
- String property = context .getEnvironment ().getProperty ("my .property" );
466
+ String property = context .getEnvironment ().getProperty ("the .property" );
467
467
assertThat (property , equalTo ("fromspecificlocation" ));
468
468
assertThat (context .getEnvironment (),
469
469
containsPropertySource ("class path resource "
@@ -480,7 +480,7 @@ public void propertySourceAnnotationWithPlaceholder() throws Exception {
480
480
application .setEnvironment (this .environment );
481
481
application .setWebEnvironment (false );
482
482
ConfigurableApplicationContext context = application .run ();
483
- String property = context .getEnvironment ().getProperty ("my .property" );
483
+ String property = context .getEnvironment ().getProperty ("the .property" );
484
484
assertThat (property , equalTo ("fromspecificlocation" ));
485
485
assertThat (context .getEnvironment (),
486
486
containsPropertySource ("class path resource "
@@ -494,7 +494,7 @@ public void propertySourceAnnotationWithName() throws Exception {
494
494
WithPropertySourceAndName .class );
495
495
application .setWebEnvironment (false );
496
496
ConfigurableApplicationContext context = application .run ();
497
- String property = context .getEnvironment ().getProperty ("my .property" );
497
+ String property = context .getEnvironment ().getProperty ("the .property" );
498
498
assertThat (property , equalTo ("fromspecificlocation" ));
499
499
assertThat (context .getEnvironment (), containsPropertySource ("foo" ));
500
500
context .close ();
@@ -507,7 +507,7 @@ public void propertySourceAnnotationInProfile() throws Exception {
507
507
application .setWebEnvironment (false );
508
508
ConfigurableApplicationContext context = application
509
509
.run ("--spring.profiles.active=myprofile" );
510
- String property = context .getEnvironment ().getProperty ("my .property" );
510
+ String property = context .getEnvironment ().getProperty ("the .property" );
511
511
assertThat (property , equalTo ("frompropertiesfile" ));
512
512
assertThat (context .getEnvironment (),
513
513
containsPropertySource ("class path resource "
@@ -536,7 +536,7 @@ public void propertySourceAnnotationMultipleLocations() throws Exception {
536
536
WithPropertySourceMultipleLocations .class );
537
537
application .setWebEnvironment (false );
538
538
ConfigurableApplicationContext context = application .run ();
539
- String property = context .getEnvironment ().getProperty ("my .property" );
539
+ String property = context .getEnvironment ().getProperty ("the .property" );
540
540
assertThat (property , equalTo ("frommorepropertiesfile" ));
541
541
assertThat (context .getEnvironment (),
542
542
containsPropertySource ("class path resource "
@@ -550,7 +550,7 @@ public void propertySourceAnnotationMultipleLocationsAndName() throws Exception
550
550
WithPropertySourceMultipleLocationsAndName .class );
551
551
application .setWebEnvironment (false );
552
552
ConfigurableApplicationContext context = application .run ();
553
- String property = context .getEnvironment ().getProperty ("my .property" );
553
+ String property = context .getEnvironment ().getProperty ("the .property" );
554
554
assertThat (property , equalTo ("frommorepropertiesfile" ));
555
555
assertThat (context .getEnvironment (), containsPropertySource ("foo" ));
556
556
context .close ();
0 commit comments