|
22 | 22 | import org.junit.Test;
|
23 | 23 |
|
24 | 24 | import org.springframework.context.annotation.Configuration;
|
25 |
| -import org.springframework.core.env.Environment; |
26 |
| -import org.springframework.test.context.ActiveProfiles; |
27 | 25 | import org.springframework.test.context.ContextConfiguration;
|
28 | 26 | import org.springframework.test.context.MergedContextConfiguration;
|
29 | 27 | import org.springframework.test.context.TestContext;
|
@@ -91,40 +89,13 @@ public void environmentPropertiesNewLineInValue() {
|
91 | 89 | assertKey(config, "variables", "foo=FOO\n bar=BAR");
|
92 | 90 | }
|
93 | 91 |
|
94 |
| - @Test |
95 |
| - public void noActiveProfiles() { |
96 |
| - Environment environment = getApplicationEnvironment(SimpleConfig.class); |
97 |
| - assertThat(environment.getActiveProfiles()).isEmpty(); |
98 |
| - } |
99 |
| - |
100 |
| - @Test |
101 |
| - public void multipleActiveProfiles() { |
102 |
| - Environment environment = getApplicationEnvironment(MultipleActiveProfiles.class); |
103 |
| - assertThat(environment.getActiveProfiles()).containsExactly("profile1", "profile2"); |
104 |
| - } |
105 |
| - |
106 |
| - @Test |
107 |
| - public void activeProfileWithComma() { |
108 |
| - Environment environment = getApplicationEnvironment(ActiveProfileWithComma.class); |
109 |
| - assertThat(environment.getActiveProfiles()).containsExactly("profile1,2"); |
110 |
| - } |
111 |
| - |
112 | 92 | private Map<String, Object> getEnvironmentProperties(Class<?> testClass) {
|
113 |
| - TestContext context = getTestContext(testClass); |
| 93 | + TestContext context = new ExposedTestContextManager(testClass).getExposedTestContext(); |
114 | 94 | MergedContextConfiguration config = (MergedContextConfiguration) ReflectionTestUtils.getField(context,
|
115 | 95 | "mergedContextConfiguration");
|
116 | 96 | return TestPropertySourceUtils.convertInlinedPropertiesToMap(config.getPropertySourceProperties());
|
117 | 97 | }
|
118 | 98 |
|
119 |
| - private Environment getApplicationEnvironment(Class<?> testClass) { |
120 |
| - TestContext context = getTestContext(testClass); |
121 |
| - return context.getApplicationContext().getEnvironment(); |
122 |
| - } |
123 |
| - |
124 |
| - private TestContext getTestContext(Class<?> testClass) { |
125 |
| - return new ExposedTestContextManager(testClass).getExposedTestContext(); |
126 |
| - } |
127 |
| - |
128 | 99 | private void assertKey(Map<String, Object> actual, String key, Object value) {
|
129 | 100 | assertThat(actual.containsKey(key)).as("Key '" + key + "' not found").isTrue();
|
130 | 101 | assertThat(actual.get(key)).isEqualTo(value);
|
@@ -172,20 +143,6 @@ static class NewLineInValue {
|
172 | 143 |
|
173 | 144 | }
|
174 | 145 |
|
175 |
| - @SpringBootTest |
176 |
| - @ActiveProfiles({ "profile1", "profile2" }) |
177 |
| - @ContextConfiguration(classes = Config.class) |
178 |
| - static class MultipleActiveProfiles { |
179 |
| - |
180 |
| - } |
181 |
| - |
182 |
| - @SpringBootTest |
183 |
| - @ActiveProfiles({ "profile1,2" }) |
184 |
| - @ContextConfiguration(classes = Config.class) |
185 |
| - static class ActiveProfileWithComma { |
186 |
| - |
187 |
| - } |
188 |
| - |
189 | 146 | @Configuration
|
190 | 147 | static class Config {
|
191 | 148 |
|
|
0 commit comments