3939import org .springframework .boot .test .system .OutputCaptureExtension ;
4040import org .springframework .cloud .kubernetes .commons .KubernetesNamespaceProvider ;
4141import org .springframework .cloud .kubernetes .commons .config .ConfigMapConfigProperties ;
42+ import org .springframework .cloud .kubernetes .commons .config .Constants ;
4243import org .springframework .cloud .kubernetes .commons .config .RetryProperties ;
43- import org .springframework .cloud .kubernetes .commons .config .SourceData ;
4444import org .springframework .core .env .CompositePropertySource ;
4545import org .springframework .core .env .MapPropertySource ;
4646import org .springframework .core .env .PropertySource ;
@@ -125,7 +125,8 @@ void namedSingleConfigMapFails() {
125125 .findAny ()
126126 .orElseThrow ();
127127
128- assertThat (mapPropertySource .getName ()).isEqualTo (SourceData .EMPTY_SOURCE_NAME_ON_ERROR );
128+ assertThat (mapPropertySource .getName ()).isEqualTo ("configmap..spring-k8s" );
129+ assertThat (propertySource .getProperty (Constants .ERROR_PROPERTY )).isEqualTo ("true" );
129130
130131 }
131132
@@ -168,7 +169,8 @@ void namedTwoConfigMapsOneFails(CapturedOutput output) {
168169 List <String > names = propertySource .getPropertySources ().stream ().map (PropertySource ::getName ).toList ();
169170
170171 // two sources are present, one being empty
171- assertThat (names ).containsExactly ("configmap.two.default" , SourceData .EMPTY_SOURCE_NAME_ON_ERROR );
172+ assertThat (names ).containsExactly ("configmap.two.default" , "configmap..default" );
173+ assertThat (propertySource .getProperty (Constants .ERROR_PROPERTY )).isEqualTo ("true" );
172174 assertThat (output .getOut ())
173175 .doesNotContain ("sourceName : two was requested, but not found in namespace : default" );
174176
@@ -212,7 +214,8 @@ void namedTwoConfigMapsBothFail(CapturedOutput output) {
212214 CompositePropertySource propertySource = (CompositePropertySource ) locator .locate (new MockEnvironment ());
213215 List <String > names = propertySource .getPropertySources ().stream ().map (PropertySource ::getName ).toList ();
214216
215- assertThat (names ).containsExactly (SourceData .EMPTY_SOURCE_NAME_ON_ERROR );
217+ assertThat (names ).containsExactly ("configmap..default" );
218+ assertThat (propertySource .getProperty (Constants .ERROR_PROPERTY )).isEqualTo ("true" );
216219 assertThat (output .getOut ())
217220 .doesNotContain ("sourceName : one was requested, but not found in namespace : default" );
218221 assertThat (output .getOut ())
@@ -255,7 +258,8 @@ void labeledSingleConfigMapFails(CapturedOutput output) {
255258 CompositePropertySource propertySource = (CompositePropertySource ) locator .locate (new MockEnvironment ());
256259 List <String > sourceNames = propertySource .getPropertySources ().stream ().map (PropertySource ::getName ).toList ();
257260
258- assertThat (sourceNames ).containsExactly (SourceData .EMPTY_SOURCE_NAME_ON_ERROR );
261+ assertThat (sourceNames ).containsExactly ("configmap..spring-k8s" );
262+ assertThat (propertySource .getProperty (Constants .ERROR_PROPERTY )).isEqualTo ("true" );
259263 assertThat (output ).contains ("failure in reading labeled sources" );
260264 assertThat (output ).contains ("failure in reading named sources" );
261265 }
@@ -268,8 +272,6 @@ void labeledSingleConfigMapFails(CapturedOutput output) {
268272 */
269273 @ Test
270274 void labeledTwoConfigMapsOneFails (CapturedOutput output ) {
271- String configMapNameOne = "one" ;
272- String configMapNameTwo = "two" ;
273275
274276 Map <String , String > configMapOneLabels = Map .of ("one" , "1" );
275277 Map <String , String > configMapTwoLabels = Map .of ("two" , "2" );
@@ -310,7 +312,8 @@ void labeledTwoConfigMapsOneFails(CapturedOutput output) {
310312 List <String > names = propertySource .getPropertySources ().stream ().map (PropertySource ::getName ).toList ();
311313
312314 // two sources are present, one being empty
313- assertThat (names ).containsExactly ("configmap.two.default" , SourceData .EMPTY_SOURCE_NAME_ON_ERROR );
315+ assertThat (names ).containsExactly ("configmap.two.default" , "configmap..default" );
316+ assertThat (propertySource .getProperty (Constants .ERROR_PROPERTY )).isEqualTo ("true" );
314317
315318 assertThat (output ).contains ("failure in reading labeled sources" );
316319 assertThat (output ).contains ("failure in reading named sources" );
@@ -364,7 +367,8 @@ void labeledTwoConfigMapsBothFail(CapturedOutput output) {
364367 List <String > names = propertySource .getPropertySources ().stream ().map (PropertySource ::getName ).toList ();
365368
366369 // all 3 sources ('application' named source, and two labeled sources)
367- assertThat (names ).containsExactly (SourceData .EMPTY_SOURCE_NAME_ON_ERROR );
370+ assertThat (names ).containsExactly ("configmap..default" );
371+ assertThat (propertySource .getProperty (Constants .ERROR_PROPERTY )).isEqualTo ("true" );
368372
369373 assertThat (output ).contains ("failure in reading labeled sources" );
370374 assertThat (output ).contains ("failure in reading named sources" );
0 commit comments