|
68 | 68 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
69 | 69 | import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
70 | 70 | import static org.assertj.core.api.Assertions.assertThatNoException; |
71 | | -import static uk.org.webcompere.systemstubs.SystemStubs.withEnvironmentVariable; |
72 | | -import static uk.org.webcompere.systemstubs.SystemStubs.withEnvironmentVariables; |
73 | 71 |
|
74 | 72 | /** |
75 | 73 | * Integration tests for {@link ConfigDataEnvironmentPostProcessor}. |
@@ -628,50 +626,56 @@ void runWhenImportWithProfileVariantOrdersPropertySourcesCorrectly() { |
628 | 626 |
|
629 | 627 | @Test |
630 | 628 | void runWhenImportYamlFromEnvironmentVariable() throws Exception { |
631 | | - ConfigurableApplicationContext context = withEnvironmentVariable("MY_CONFIG_YAML", """ |
632 | | - my: |
633 | | - value: from-env-first-doc |
634 | | - --- |
635 | | - my: |
636 | | - value: from-env-second-doc |
637 | | - """).execute(() -> this.application |
638 | | - .run("--spring.config.location=classpath:application-import-yaml-from-environment.properties")); |
| 629 | + ConfigurableApplicationContext context = uk.org.webcompere.systemstubs.SystemStubs |
| 630 | + .withEnvironmentVariable("MY_CONFIG_YAML", """ |
| 631 | + my: |
| 632 | + value: from-env-first-doc |
| 633 | + --- |
| 634 | + my: |
| 635 | + value: from-env-second-doc |
| 636 | + """) |
| 637 | + .execute(() -> this.application |
| 638 | + .run("--spring.config.location=classpath:application-import-yaml-from-environment.properties")); |
639 | 639 | assertThat(context.getEnvironment().getProperty("my.value")).isEqualTo("from-env-second-doc"); |
640 | 640 | } |
641 | 641 |
|
642 | 642 | @Test |
643 | 643 | void runWhenImportYamlFromEnvironmentVariableWithProfileVariant() throws Exception { |
644 | 644 | this.application.setAdditionalProfiles("dev"); |
645 | | - ConfigurableApplicationContext context = withEnvironmentVariables("MY_CONFIG_YAML", """ |
646 | | - my: |
647 | | - value: my_config_yaml |
648 | | - """, "MY_CONFIG_YAML_DEV", """ |
649 | | - my: |
650 | | - value: my_config_yaml_dev |
651 | | - """).execute(() -> this.application.run( |
652 | | - "--spring.config.location=classpath:application-import-yaml-from-environment-with-profile-variant.properties")); |
| 645 | + ConfigurableApplicationContext context = uk.org.webcompere.systemstubs.SystemStubs |
| 646 | + .withEnvironmentVariables("MY_CONFIG_YAML", """ |
| 647 | + my: |
| 648 | + value: my_config_yaml |
| 649 | + """, "MY_CONFIG_YAML_DEV", """ |
| 650 | + my: |
| 651 | + value: my_config_yaml_dev |
| 652 | + """) |
| 653 | + .execute(() -> this.application.run( |
| 654 | + "--spring.config.location=classpath:application-import-yaml-from-environment-with-profile-variant.properties")); |
653 | 655 | assertThat(context.getEnvironment().getProperty("my.value")).isEqualTo("my_config_yaml_dev"); |
654 | 656 | } |
655 | 657 |
|
656 | 658 | @Test |
657 | 659 | void runWhenImportBase64YamlFromEnvironmentVariable() throws Exception { |
658 | | - ConfigurableApplicationContext context = withEnvironmentVariable("MY_CONFIG_BASE64_YAML", |
659 | | - Base64.getEncoder().encodeToString(""" |
660 | | - my: |
661 | | - value: from-base64-yaml |
662 | | - """.getBytes(StandardCharsets.UTF_8))) |
| 660 | + ConfigurableApplicationContext context = uk.org.webcompere.systemstubs.SystemStubs |
| 661 | + .withEnvironmentVariable("MY_CONFIG_BASE64_YAML", Base64.getEncoder().encodeToString(""" |
| 662 | + my: |
| 663 | + value: from-base64-yaml |
| 664 | + """.getBytes(StandardCharsets.UTF_8))) |
663 | 665 | .execute(() -> this.application |
664 | 666 | .run("--spring.config.location=classpath:application-import-base64-yaml-from-environment.properties")); |
665 | 667 | assertThat(context.getEnvironment().getProperty("my.value")).isEqualTo("from-base64-yaml"); |
666 | 668 | } |
667 | 669 |
|
668 | 670 | @Test |
669 | 671 | void runWhenImportPropertiesFromEnvironmentVariable() throws Exception { |
670 | | - ConfigurableApplicationContext context = withEnvironmentVariable("MY_CONFIG_PROPERTIES", """ |
671 | | - my.value1: from-properties-1 |
672 | | - my.value2: from-properties-2 |
673 | | - """).execute(() -> this.application |
674 | | - .run("--spring.config.location=classpath:application-import-properties-from-environment.properties")); |
| 672 | + ConfigurableApplicationContext context = uk.org.webcompere.systemstubs.SystemStubs |
| 673 | + .withEnvironmentVariable("MY_CONFIG_PROPERTIES", """ |
| 674 | + my.value1: from-properties-1 |
| 675 | + my.value2: from-properties-2 |
| 676 | + """) |
| 677 | + .execute(() -> this.application |
| 678 | + .run("--spring.config.location=classpath:application-import-properties-from-environment.properties")); |
675 | 679 | assertThat(context.getEnvironment().getProperty("my.value1")).isEqualTo("from-properties-1"); |
676 | 680 | assertThat(context.getEnvironment().getProperty("my.value2")).isEqualTo("from-properties-2"); |
677 | 681 | } |
|
0 commit comments