|
18 | 18 |
|
19 | 19 | package com.tencent.cloud.polaris.config.adapter;
|
20 | 20 |
|
| 21 | +import java.lang.reflect.Field; |
21 | 22 | import java.util.Arrays;
|
22 | 23 | import java.util.HashMap;
|
23 | 24 | import java.util.LinkedList;
|
@@ -68,6 +69,7 @@ public void setUp() {
|
68 | 69 |
|
69 | 70 | @Test
|
70 | 71 | public void testLoadApplicationPropertiesFile() {
|
| 72 | + clearCompositePropertySourceCache(); |
71 | 73 | PolarisConfigFileLocator locator = new PolarisConfigFileLocator(polarisConfigProperties, polarisContextProperties,
|
72 | 74 | configFileService, environment);
|
73 | 75 |
|
@@ -105,6 +107,7 @@ public void testLoadApplicationPropertiesFile() {
|
105 | 107 |
|
106 | 108 | @Test
|
107 | 109 | public void testActiveProfileFilesPriorityBiggerThanDefault() {
|
| 110 | + clearCompositePropertySourceCache(); |
108 | 111 | PolarisConfigFileLocator locator = new PolarisConfigFileLocator(polarisConfigProperties, polarisContextProperties,
|
109 | 112 | configFileService, environment);
|
110 | 113 |
|
@@ -154,6 +157,7 @@ public void testActiveProfileFilesPriorityBiggerThanDefault() {
|
154 | 157 |
|
155 | 158 | @Test
|
156 | 159 | public void testGetCustomFiles() {
|
| 160 | + clearCompositePropertySourceCache(); |
157 | 161 | PolarisConfigFileLocator locator = new PolarisConfigFileLocator(polarisConfigProperties, polarisContextProperties,
|
158 | 162 | configFileService, environment);
|
159 | 163 |
|
@@ -208,6 +212,7 @@ public void testGetCustomFiles() {
|
208 | 212 |
|
209 | 213 | @Test
|
210 | 214 | public void testGetCustomGroupFiles() {
|
| 215 | + clearCompositePropertySourceCache(); |
211 | 216 | PolarisConfigFileLocator locator = new PolarisConfigFileLocator(polarisConfigProperties, polarisContextProperties,
|
212 | 217 | configFileService, environment);
|
213 | 218 |
|
@@ -260,4 +265,15 @@ public void testGetCustomGroupFiles() {
|
260 | 265 | assertThat(propertySource.getProperty("k2")).isEqualTo("v2");
|
261 | 266 | assertThat(propertySource.getProperty("k3")).isEqualTo("v3");
|
262 | 267 | }
|
| 268 | + |
| 269 | + private void clearCompositePropertySourceCache() { |
| 270 | + try { |
| 271 | + Class<?> clazz = PolarisConfigFileLocator.class; |
| 272 | + Field field = clazz.getDeclaredField("compositePropertySourceCache"); |
| 273 | + field.setAccessible(true); |
| 274 | + field.set(null, null); |
| 275 | + } catch (Exception e) { |
| 276 | + // ignore |
| 277 | + } |
| 278 | + } |
263 | 279 | }
|
0 commit comments