1616
1717package org .springframework .core .env ;
1818
19+ import java .util .HashSet ;
1920import java .util .Map ;
21+ import java .util .Set ;
2022
2123import org .junit .jupiter .api .Nested ;
2224import org .junit .jupiter .api .Test ;
@@ -300,6 +302,12 @@ void getSystemProperties() {
300302 assertThat (systemProperties .get (DISALLOWED_PROPERTY_NAME )).isEqualTo (DISALLOWED_PROPERTY_VALUE );
301303 assertThat (systemProperties .get (STRING_PROPERTY_NAME )).isEqualTo (NON_STRING_PROPERTY_VALUE );
302304 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 );
303311 }
304312 finally {
305313 System .clearProperty (ALLOWED_PROPERTY_NAME );
@@ -316,6 +324,7 @@ void getSystemEnvironment() {
316324 assertThat (System .getenv ()).isSameAs (systemEnvironment );
317325 }
318326
327+
319328 @ Nested
320329 class GetActiveProfiles {
321330
@@ -365,6 +374,7 @@ void fromSystemProperties_withMultipleProfiles_withWhitespace() {
365374 }
366375 }
367376
377+
368378 @ Nested
369379 class AcceptsProfilesTests {
370380
@@ -447,9 +457,9 @@ void withProfileExpression() {
447457 environment .addActiveProfile ("p2" );
448458 assertThat (environment .acceptsProfiles (Profiles .of ("p1 & p2" ))).isTrue ();
449459 }
450-
451460 }
452461
462+
453463 @ Nested
454464 class MatchesProfilesTests {
455465
@@ -549,7 +559,6 @@ void withProfileExpressions() {
549559 assertThat (environment .matchesProfiles ("p2 & (foo | p1)" )).isTrue ();
550560 assertThat (environment .matchesProfiles ("foo" , "(p2 & p1)" )).isTrue ();
551561 }
552-
553562 }
554563
555564}
0 commit comments