3030import org .junit .jupiter .api .AfterEach ;
3131import org .junit .jupiter .api .Assertions ;
3232import org .junit .jupiter .api .BeforeAll ;
33+ import org .junit .jupiter .api .BeforeEach ;
3334import org .junit .jupiter .api .Test ;
3435
3536import org .springframework .cloud .config .environment .Environment ;
3637import org .springframework .cloud .kubernetes .client .config .KubernetesClientConfigContext ;
3738import org .springframework .cloud .kubernetes .client .config .KubernetesClientConfigMapPropertySource ;
38- import org .springframework .cloud .kubernetes .client .config .KubernetesClientConfigMapsCache ;
3939import org .springframework .cloud .kubernetes .client .config .KubernetesClientSecretsPropertySource ;
40+ import org .springframework .cloud .kubernetes .client .config .KubernetesClientSourcesNamespaceBatched ;
4041import org .springframework .cloud .kubernetes .commons .config .ConfigUtils ;
4142import org .springframework .cloud .kubernetes .commons .config .Constants ;
4243import org .springframework .cloud .kubernetes .commons .config .NamedConfigMapNormalizedSource ;
@@ -128,13 +129,13 @@ public static void before() {
128129 NormalizedSource defaultSource = new NamedConfigMapNormalizedSource (applicationName , "default" , false ,
129130 true );
130131 KubernetesClientConfigContext defaultContext = new KubernetesClientConfigContext (coreApi , defaultSource ,
131- "default" , springEnv );
132+ "default" , springEnv , true , true );
132133 propertySources .add (new KubernetesClientConfigMapPropertySource (defaultContext ));
133134
134135 if ("stores" .equals (applicationName ) && "dev" .equals (namespace )) {
135136 NormalizedSource devSource = new NamedConfigMapNormalizedSource (applicationName , "dev" , false , true );
136137 KubernetesClientConfigContext devContext = new KubernetesClientConfigContext (coreApi , devSource , "dev" ,
137- springEnv );
138+ springEnv , true , true );
138139 propertySources .add (new KubernetesClientConfigMapPropertySource (devContext ));
139140 }
140141 return propertySources ;
@@ -144,20 +145,27 @@ public static void before() {
144145
145146 NormalizedSource source = new NamedSecretNormalizedSource (applicationName , "default" , false , true );
146147 KubernetesClientConfigContext context = new KubernetesClientConfigContext (coreApi , source , "default" ,
147- springEnv );
148+ springEnv , true , true );
148149
149150 propertySources .add (new KubernetesClientSecretsPropertySource (context ));
150151 return propertySources ;
151152 });
152153 }
153154
154155 @ AfterEach
155- public void after () {
156- new KubernetesClientConfigMapsCache ().discardAll ();
156+ void afterEach () {
157+ new KubernetesClientSourcesNamespaceBatched ().discardConfigMaps ();
158+ new KubernetesClientSourcesNamespaceBatched ().discardSecrets ();
159+ }
160+
161+ @ BeforeEach
162+ void beforeEach () {
163+ new KubernetesClientSourcesNamespaceBatched ().discardConfigMaps ();
164+ new KubernetesClientSourcesNamespaceBatched ().discardSecrets ();
157165 }
158166
159167 @ Test
160- public void testApplicationCase () throws ApiException {
168+ void testApplicationCase () throws ApiException {
161169 CoreV1Api coreApi = mock (CoreV1Api .class );
162170 when (coreApi .listNamespacedConfigMap (eq ("default" ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ),
163171 eq (null ), eq (null ), eq (null ), eq (null ), eq (null )))
@@ -191,7 +199,7 @@ public void testApplicationCase() throws ApiException {
191199 }
192200
193201 @ Test
194- public void testStoresCase () throws ApiException {
202+ void testStoresCase () throws ApiException {
195203 CoreV1Api coreApi = mock (CoreV1Api .class );
196204 when (coreApi .listNamespacedConfigMap (eq ("default" ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ),
197205 eq (null ), eq (null ), eq (null ), eq (null ), eq (null )))
@@ -238,7 +246,7 @@ public void testStoresCase() throws ApiException {
238246 }
239247
240248 @ Test
241- public void testStoresProfileCase () throws ApiException {
249+ void testStoresProfileCase () throws ApiException {
242250 CoreV1Api coreApi = mock (CoreV1Api .class );
243251 when (coreApi .listNamespacedConfigMap (eq ("default" ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ),
244252 eq (null ), eq (null ), eq (null ), eq (null ), eq (null )))
@@ -302,7 +310,7 @@ else if (propertySource.getName().equals("secret.stores.default")) {
302310 }
303311
304312 @ Test
305- public void testApplicationPropertiesAnSecretsOverride () throws ApiException {
313+ void testApplicationPropertiesAnSecretsOverride () throws ApiException {
306314 CoreV1Api coreApi = mock (CoreV1Api .class );
307315 when (coreApi .listNamespacedConfigMap (eq ("default" ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ),
308316 eq (null ), eq (null ), eq (null ), eq (null ), eq (null )))
@@ -343,7 +351,7 @@ public void testApplicationPropertiesAnSecretsOverride() throws ApiException {
343351 }
344352
345353 @ Test
346- public void testSingleConfigMapMultipleSources () throws ApiException {
354+ void testSingleConfigMapMultipleSources () throws ApiException {
347355 CoreV1Api coreApi = mock (CoreV1Api .class );
348356 when (coreApi .listNamespacedConfigMap (eq ("default" ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ), eq (null ),
349357 eq (null ), eq (null ), eq (null ), eq (null ), eq (null )))
@@ -357,7 +365,7 @@ public void testSingleConfigMapMultipleSources() throws ApiException {
357365 NormalizedSource devSource = new NamedConfigMapNormalizedSource (name , namespace , false ,
358366 ConfigUtils .Prefix .DEFAULT , true , true );
359367 KubernetesClientConfigContext devContext = new KubernetesClientConfigContext (coreApi , devSource , "default" ,
360- environment );
368+ environment , true , true );
361369 propertySources .add (new KubernetesClientConfigMapPropertySource (devContext ));
362370 return propertySources ;
363371 });
0 commit comments