16
16
17
17
package org .springframework .core .env ;
18
18
19
+ import java .util .HashSet ;
19
20
import java .util .Map ;
21
+ import java .util .Set ;
20
22
21
23
import org .junit .jupiter .api .Nested ;
22
24
import org .junit .jupiter .api .Test ;
@@ -300,6 +302,12 @@ void getSystemProperties() {
300
302
assertThat (systemProperties .get (DISALLOWED_PROPERTY_NAME )).isEqualTo (DISALLOWED_PROPERTY_VALUE );
301
303
assertThat (systemProperties .get (STRING_PROPERTY_NAME )).isEqualTo (NON_STRING_PROPERTY_VALUE );
302
304
assertThat (systemProperties .get (NON_STRING_PROPERTY_NAME )).isEqualTo (STRING_PROPERTY_VALUE );
305
+
306
+ PropertiesPropertySource systemPropertySource = (PropertiesPropertySource )
307
+ environment .getPropertySources ().get (StandardEnvironment .SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME );
308
+ Set <String > expectedKeys = new HashSet <>(System .getProperties ().stringPropertyNames ());
309
+ expectedKeys .add (STRING_PROPERTY_NAME ); // filtered out by stringPropertyNames due to non-String value
310
+ assertThat (Set .of (systemPropertySource .getPropertyNames ())).isEqualTo (expectedKeys );
303
311
}
304
312
finally {
305
313
System .clearProperty (ALLOWED_PROPERTY_NAME );
@@ -316,6 +324,7 @@ void getSystemEnvironment() {
316
324
assertThat (System .getenv ()).isSameAs (systemEnvironment );
317
325
}
318
326
327
+
319
328
@ Nested
320
329
class GetActiveProfiles {
321
330
@@ -365,6 +374,7 @@ void fromSystemProperties_withMultipleProfiles_withWhitespace() {
365
374
}
366
375
}
367
376
377
+
368
378
@ Nested
369
379
class AcceptsProfilesTests {
370
380
@@ -447,9 +457,9 @@ void withProfileExpression() {
447
457
environment .addActiveProfile ("p2" );
448
458
assertThat (environment .acceptsProfiles (Profiles .of ("p1 & p2" ))).isTrue ();
449
459
}
450
-
451
460
}
452
461
462
+
453
463
@ Nested
454
464
class MatchesProfilesTests {
455
465
@@ -549,7 +559,6 @@ void withProfileExpressions() {
549
559
assertThat (environment .matchesProfiles ("p2 & (foo | p1)" )).isTrue ();
550
560
assertThat (environment .matchesProfiles ("foo" , "(p2 & p1)" )).isTrue ();
551
561
}
552
-
553
562
}
554
563
555
564
}
0 commit comments