|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.security.AccessControlException;
|
20 | 20 | import java.security.Permission;
|
| 21 | +import java.util.Arrays; |
| 22 | +import java.util.HashSet; |
21 | 23 | import java.util.Map;
|
| 24 | +import java.util.Set; |
22 | 25 |
|
23 | 26 | import org.junit.jupiter.api.Nested;
|
24 | 27 | import org.junit.jupiter.api.Test;
|
@@ -307,6 +310,12 @@ void getSystemProperties_withAndWithoutSecurityManager() {
|
307 | 310 | // non-string keys and values work fine... until the security manager is introduced below
|
308 | 311 | assertThat(systemProperties.get(STRING_PROPERTY_NAME)).isEqualTo(NON_STRING_PROPERTY_VALUE);
|
309 | 312 | assertThat(systemProperties.get(NON_STRING_PROPERTY_NAME)).isEqualTo(STRING_PROPERTY_VALUE);
|
| 313 | + |
| 314 | + PropertiesPropertySource systemPropertySource = (PropertiesPropertySource) |
| 315 | + environment.getPropertySources().get(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME); |
| 316 | + Set<String> expectedKeys = new HashSet<>(System.getProperties().stringPropertyNames()); |
| 317 | + expectedKeys.add(STRING_PROPERTY_NAME); // filtered out by stringPropertyNames due to non-String value |
| 318 | + assertThat(new HashSet<>(Arrays.asList(systemPropertySource.getPropertyNames()))).isEqualTo(expectedKeys); |
310 | 319 | }
|
311 | 320 |
|
312 | 321 | SecurityManager securityManager = new SecurityManager() {
|
@@ -407,6 +416,7 @@ public void checkPermission(Permission perm) {
|
407 | 416 | EnvironmentTestUtils.getModifiableSystemEnvironment().remove(DISALLOWED_PROPERTY_NAME);
|
408 | 417 | }
|
409 | 418 |
|
| 419 | + |
410 | 420 | @Nested
|
411 | 421 | class GetActiveProfiles {
|
412 | 422 |
|
@@ -456,6 +466,7 @@ void fromSystemProperties_withMultipleProfiles_withWhitespace() {
|
456 | 466 | }
|
457 | 467 | }
|
458 | 468 |
|
| 469 | + |
459 | 470 | @Nested
|
460 | 471 | class AcceptsProfilesTests {
|
461 | 472 |
|
@@ -538,9 +549,9 @@ void withProfileExpression() {
|
538 | 549 | environment.addActiveProfile("p2");
|
539 | 550 | assertThat(environment.acceptsProfiles(Profiles.of("p1 & p2"))).isTrue();
|
540 | 551 | }
|
541 |
| - |
542 | 552 | }
|
543 | 553 |
|
| 554 | + |
544 | 555 | @Nested
|
545 | 556 | class MatchesProfilesTests {
|
546 | 557 |
|
@@ -650,7 +661,6 @@ void withProfileExpressions() {
|
650 | 661 | assertThat(environment.matchesProfiles("p2 & (foo | p1)")).isTrue();
|
651 | 662 | assertThat(environment.matchesProfiles("foo", "(p2 & p1)")).isTrue();
|
652 | 663 | }
|
653 |
| - |
654 | 664 | }
|
655 | 665 |
|
656 | 666 | }
|
0 commit comments