diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java index 2c11c5414..1266b00f7 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java @@ -37,6 +37,7 @@ import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException; import org.springframework.cloud.kubernetes.commons.config.RetryProperties; import org.springframework.core.env.PropertySource; @@ -62,7 +63,7 @@ class KubernetesClientConfigMapPropertySourceLocatorTests { .withNamespace("default") .withResourceVersion("1") .build()) - .addToData("application.properties", + .addToData(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n" + "logging.level.org.springframework.cloud.kubernetes=TRACE") .build()); diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceTests.java index e5eb152a6..911f705df 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceTests.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test; import org.springframework.cloud.kubernetes.commons.config.ConfigUtils; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource; import org.springframework.cloud.kubernetes.commons.config.NormalizedSource; import org.springframework.mock.env.MockEnvironment; @@ -59,7 +60,7 @@ class KubernetesClientConfigMapPropertySourceTests { .withNamespace("default") .withResourceVersion("1") .build()) - .addToData("application.properties", + .addToData(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n" + "logging.level.org.springframework.cloud.kubernetes=TRACE") .build()); @@ -70,7 +71,7 @@ class KubernetesClientConfigMapPropertySourceTests { .withNamespace("default") .withResourceVersion("1") .build()) - .addToData("application.yaml", "dummy:\n property:\n string2: \"a\"\n int2: 1\n bool2: true\n") + .addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string2: \"a\"\n int2: 1\n bool2: true\n") .build()); private static WireMockServer wireMockServer; diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload/KubernetesClientEventBasedConfigMapChangeDetectorTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload/KubernetesClientEventBasedConfigMapChangeDetectorTests.java index 5a86dbdbf..04a75cb12 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload/KubernetesClientEventBasedConfigMapChangeDetectorTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload/KubernetesClientEventBasedConfigMapChangeDetectorTests.java @@ -51,6 +51,7 @@ import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapPropertySource; import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapPropertySourceLocator; import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties; import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy; import org.springframework.mock.env.MockPropertySource; @@ -99,10 +100,10 @@ void watch() { Gson gson = builder.create(); Map data = new HashMap<>(); - data.put("application.properties", "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n" + data.put(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n" + "logging.level.org.springframework.cloud.kubernetes=TRACE"); Map updateData = new HashMap<>(); - updateData.put("application.properties", "spring.cloud.kubernetes.configuration.watcher.refreshDelay=1\n" + updateData.put(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=1\n" + "logging.level.org.springframework.cloud.kubernetes=TRACE"); V1ConfigMap applicationConfig = new V1ConfigMap().kind("ConfigMap") .metadata(new V1ObjectMeta().namespace("default").name("bar1")) @@ -132,7 +133,7 @@ void watch() { .withBody(new JSON().serialize(new Watch.Response<>(EventType.ADDED.name(), new V1ConfigMap().kind("ConfigMap") .metadata(new V1ObjectMeta().namespace("default").name("bar3")) - .putDataItem("application.properties", "debug=true"))))) + .putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true"))))) .willSetStateTo("delete")); stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch") @@ -142,7 +143,7 @@ void watch() { .withBody(new JSON().serialize(new Watch.Response<>(EventType.DELETED.name(), new V1ConfigMap().kind("ConfigMap") .metadata(new V1ObjectMeta().namespace("default").name("bar1")) - .putDataItem("application.properties", "debug=true"))))) + .putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true"))))) .willSetStateTo("done")); stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch") diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java index 53fd0afb3..0a51d7475 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java @@ -179,10 +179,10 @@ void testWithPrefixSortedName() { void testMerge() { StrippedSourceContainer configMapOne = new StrippedSourceContainer(Map.of(), "configmap-one", - Map.of("application.yaml", "propA: A\npropB: B")); + Map.of(Constants.APPLICATION_YAML, "propA: A\npropB: B")); StrippedSourceContainer configMapOneK8s = new StrippedSourceContainer(Map.of(), "configmap-one-kubernetes", - Map.of("application.yaml", "propA: AA\npropC: C")); + Map.of(Constants.APPLICATION_YAML, "propA: AA\npropC: C")); LinkedHashSet sourceNames = Stream.of("configmap-one", "configmap-one-kubernetes") .collect(Collectors.toCollection(LinkedHashSet::new)); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorOrderedPropertiesTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorOrderedPropertiesTests.java index f902fa15b..df3c02892 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorOrderedPropertiesTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorOrderedPropertiesTests.java @@ -53,7 +53,7 @@ void testSingleNonFileProperty() { @Test void testSingleFileProperty() { Map map = new LinkedHashMap<>(); - map.put("application.properties", "my-key=from-app"); + map.put(Constants.APPLICATION_PROPERTIES, "my-key=from-app"); MockEnvironment mockEnvironment = new MockEnvironment(); Map result = SourceDataEntriesProcessor.processAllEntries(map, mockEnvironment); @@ -78,7 +78,7 @@ void testSingleFileProperty() { void testThree() { Map map = new LinkedHashMap<>(); - map.put("application.properties", """ + map.put(Constants.APPLICATION_PROPERTIES, """ firstKey=firstFromProperties secondKey=secondFromProperties"""); map.put("firstKey", "abc"); @@ -114,7 +114,7 @@ void testThree() { void testFour() { Map map = new LinkedHashMap<>(); - map.put("application.properties", """ + map.put(Constants.APPLICATION_PROPERTIES, """ firstKey=firstFromProperties secondKey=secondFromProperties thirdKey=thirdFromProperties"""); @@ -158,7 +158,7 @@ void testFour() { void testFive() { Map map = new LinkedHashMap<>(); - map.put("application.properties", """ + map.put(Constants.APPLICATION_PROPERTIES, """ firstKey=firstFromProperties secondKey=secondFromProperties thirdKey=thirdFromProperties"""); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorSortedTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorSortedTests.java index 769f079dc..f212fde06 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorSortedTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorSortedTests.java @@ -66,13 +66,13 @@ void testTwoNonFileProperties() { void testSingleFileProperty() { Map k8sSource = new LinkedHashMap<>(); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); MockEnvironment mockEnvironment = new MockEnvironment(); List> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment); Assertions.assertEquals(result.size(), 1); - Assertions.assertEquals(result.get(0).getKey(), "application.properties"); + Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES); Assertions.assertEquals(result.get(0).getValue(), "key=value"); } @@ -80,14 +80,14 @@ void testSingleFileProperty() { void testApplicationAndSimpleProperty() { Map k8sSource = new LinkedHashMap<>(); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); k8sSource.put("simple", "other_value"); MockEnvironment mockEnvironment = new MockEnvironment(); List> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment); Assertions.assertEquals(result.size(), 2); - Assertions.assertEquals(result.get(0).getKey(), "application.properties"); + Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES); Assertions.assertEquals(result.get(0).getValue(), "key=value"); Assertions.assertEquals(result.get(1).getKey(), "simple"); @@ -99,13 +99,13 @@ void testSimplePropertyAndApplication() { Map k8sSource = new LinkedHashMap<>(); k8sSource.put("simple", "other_value"); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); MockEnvironment mockEnvironment = new MockEnvironment(); List> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment); Assertions.assertEquals(result.size(), 2); - Assertions.assertEquals(result.get(0).getKey(), "application.properties"); + Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES); Assertions.assertEquals(result.get(0).getValue(), "key=value"); Assertions.assertEquals(result.get(1).getKey(), "simple"); @@ -117,7 +117,7 @@ void testSimplePropertyAndTwoApplications() { Map k8sSource = new LinkedHashMap<>(); k8sSource.put("simple", "other_value"); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); k8sSource.put("application-dev.properties", "key-dev=value-dev"); MockEnvironment mockEnvironment = new MockEnvironment(); @@ -125,7 +125,7 @@ void testSimplePropertyAndTwoApplications() { List> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment); Assertions.assertEquals(result.size(), 3); - Assertions.assertEquals(result.get(0).getKey(), "application.properties"); + Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES); Assertions.assertEquals(result.get(0).getValue(), "key=value"); Assertions.assertEquals(result.get(1).getKey(), "application-dev.properties"); @@ -140,7 +140,7 @@ void testSimplePropertyAndTwoApplicationsDoNotIncludeDefaultProfile() { Map k8sSource = new LinkedHashMap<>(); k8sSource.put("simple", "other_value"); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); k8sSource.put("application-dev.properties", "key-dev=value-dev"); MockEnvironment mockEnvironment = new MockEnvironment(); @@ -159,7 +159,7 @@ void testComplex() { Map k8sSource = new LinkedHashMap<>(); k8sSource.put("simple", "other_value"); k8sSource.put("second-simple", "second_other_value"); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); k8sSource.put("application-dev.properties", "key-dev=value-dev"); k8sSource.put("application-k8s.properties", "key-k8s=value-k8s"); k8sSource.put("ignored.properties", "key-ignored=value-ignored"); @@ -169,7 +169,7 @@ void testComplex() { List> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment); Assertions.assertEquals(result.size(), 4); - Assertions.assertEquals(result.get(0).getKey(), "application.properties"); + Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES); Assertions.assertEquals(result.get(0).getValue(), "key=value"); Assertions.assertEquals(result.get(1).getKey(), "application-k8s.properties"); @@ -188,7 +188,7 @@ void testComplexWithNonDefaultApplicationName() { Map k8sSource = new LinkedHashMap<>(); k8sSource.put("simple", "other_value"); k8sSource.put("second-simple", "second_other_value"); - k8sSource.put("application.properties", "key=value"); + k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value"); k8sSource.put("application-dev.properties", "key-dev=value-dev"); k8sSource.put("application-k8s.properties", "key-k8s=value-k8s"); k8sSource.put("ignored.properties", "key-ignored=value-ignored"); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorTests.java index 98647e09a..e4748d6a6 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorTests.java @@ -106,7 +106,7 @@ void twoEntriesOneIsYamlButNotTaken() { void twoEntriesBothTaken() { Map.Entry one = Map.entry("one", "1"); - Map.Entry application = Map.entry("application.yaml", "color: \n blue"); + Map.Entry application = Map.entry(Constants.APPLICATION_YAML, "color: \n blue"); Map map = Map.ofEntries(one, application); Map result = SourceDataEntriesProcessor.processAllEntries(map, new MockEnvironment()); @@ -127,7 +127,7 @@ void twoEntriesBothTaken() { void threeEntriesAllTaken() { Map.Entry one = Map.entry("one", "1"); - Map.Entry application = Map.entry("application.properties", "color=blue"); + Map.Entry application = Map.entry(Constants.APPLICATION_PROPERTIES, "color=blue"); Map.Entry applicationDev = Map.entry("application-dev.properties", "fit=sport"); Map map = Map.ofEntries(one, application, applicationDev); diff --git a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java index c5820f91f..5a7ab6415 100644 --- a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java +++ b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java @@ -38,6 +38,7 @@ import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapsCache; import org.springframework.cloud.kubernetes.client.config.KubernetesClientSecretsPropertySource; import org.springframework.cloud.kubernetes.commons.config.ConfigUtils; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource; import org.springframework.cloud.kubernetes.commons.config.NamedSecretNormalizedSource; import org.springframework.cloud.kubernetes.commons.config.NormalizedSource; @@ -74,15 +75,15 @@ class KubernetesEnvironmentRepositoryTests { private static final V1ConfigMapList CONFIGMAP_DEFAULT_LIST = new V1ConfigMapList() .addItemsItem(new V1ConfigMapBuilder() .withMetadata(new V1ObjectMetaBuilder().withName("application").withNamespace(DEFAULT_NAMESPACE).build()) - .addToData("application.yaml", VALUE) + .addToData(Constants.APPLICATION_YAML, VALUE) .build()) .addItemsItem(new V1ConfigMapBuilder() .withMetadata(new V1ObjectMetaBuilder().withName("stores").withNamespace(DEFAULT_NAMESPACE).build()) - .addToData("application.yaml", VALUE) + .addToData(Constants.APPLICATION_YAML, VALUE) .build()) .addItemsItem(new V1ConfigMapBuilder() .withMetadata(new V1ObjectMetaBuilder().withName("stores-dev").withNamespace(DEFAULT_NAMESPACE).build()) - .addToData("application.yaml", + .addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string1: \"a\"\n string2: \"b\"\n int2: 2\n bool2: false\n") .build()); @@ -90,7 +91,7 @@ class KubernetesEnvironmentRepositoryTests { .addItemsItem(new V1ConfigMapBuilder() .withMetadata( new V1ObjectMetaBuilder().withName("stores").withNamespace("dev").withResourceVersion("1").build()) - .addToData("application.yaml", "dummy:\n property:\n string2: \"dev\"\n int2: 1\n bool2: true\n") + .addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string2: \"dev\"\n int2: 1\n bool2: true\n") .build()); private static final V1SecretList SECRET_LIST = new V1SecretListBuilder() diff --git a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesPropertySourceSupplierTests.java b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesPropertySourceSupplierTests.java index 01e0e5d51..3b2e7a5e0 100644 --- a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesPropertySourceSupplierTests.java +++ b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesPropertySourceSupplierTests.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test; import org.springframework.cloud.config.environment.Environment; +import org.springframework.cloud.kubernetes.commons.config.Constants; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; @@ -180,7 +181,7 @@ private static V1ConfigMap buildConfigMap(String name, String namespace) { return new V1ConfigMapBuilder() .withMetadata( new V1ObjectMetaBuilder().withName(name).withNamespace(namespace).withResourceVersion("1").build()) - .addToData("application.yaml", "dummy:\n property:\n string: \"" + name + "\"\n") + .addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string: \"" + name + "\"\n") .build(); } diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsTest.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsTest.java index a2f29e1bd..b478432e9 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsTest.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsTest.java @@ -31,6 +31,8 @@ import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.cloud.kubernetes.commons.config.Constants.APPLICATION_PROPERTIES; +import static org.springframework.cloud.kubernetes.commons.config.Constants.APPLICATION_YAML; /** * @author Charles Moulliard @@ -84,7 +86,7 @@ void testConfigMapFromSingleApplicationProperties() { ConfigMap configMap = new ConfigMapBuilder().withNewMetadata() .withName(configMapName) .endMetadata() - .addToData("application.properties", ConfigMapTestUtil.readResourceFile("application.properties")) + .addToData(APPLICATION_PROPERTIES, ConfigMapTestUtil.readResourceFile(APPLICATION_PROPERTIES)) .build(); mockClient.configMaps().inNamespace("test").resource(configMap).create(); @@ -104,7 +106,7 @@ void testConfigMapFromSingleApplicationYaml() { ConfigMap configMap = new ConfigMapBuilder().withNewMetadata() .withName(configMapName) .endMetadata() - .addToData("application.yaml", ConfigMapTestUtil.readResourceFile("application.yaml")) + .addToData(APPLICATION_YAML, ConfigMapTestUtil.readResourceFile(APPLICATION_YAML)) .build(); mockClient.configMaps().inNamespace("test").resource(configMap).create(); @@ -144,7 +146,7 @@ void testConfigMapFromSingleInvalidPropertiesContent() { ConfigMap configMap = new ConfigMapBuilder().withNewMetadata() .withName(configMapName) .endMetadata() - .addToData("application.properties", "somevalue") + .addToData(APPLICATION_PROPERTIES, "somevalue") .build(); mockClient.configMaps().inNamespace("test").resource(configMap).create(); @@ -162,7 +164,7 @@ void testConfigMapFromSingleInvalidYamlContent() { ConfigMap configMap = new ConfigMapBuilder().withNewMetadata() .withName(configMapName) .endMetadata() - .addToData("application.yaml", "somevalue") + .addToData(APPLICATION_YAML, "somevalue") .build(); mockClient.configMaps().inNamespace("test").resource(configMap).create(); @@ -180,7 +182,7 @@ void testConfigMapFromMultipleApplicationProperties() { ConfigMap configMap = new ConfigMapBuilder().withNewMetadata() .withName(configMapName) .endMetadata() - .addToData("application.properties", ConfigMapTestUtil.readResourceFile("application.properties")) + .addToData(APPLICATION_PROPERTIES, ConfigMapTestUtil.readResourceFile(APPLICATION_PROPERTIES)) .addToData("adhoc.properties", ConfigMapTestUtil.readResourceFile("adhoc.properties")) .build(); diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java index ddacddc4e..843a2e82a 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java @@ -36,6 +36,8 @@ import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties; import org.springframework.mock.env.MockEnvironment; +import static org.springframework.cloud.kubernetes.commons.config.Constants.APPLICATION_YAML; + /** * @author wind57 */ @@ -91,7 +93,7 @@ void testSecretDataByLabelsSecretFoundWithPropertyFile() { .inNamespace("spring-k8s") .resource(new SecretBuilder() .withMetadata(new ObjectMetaBuilder().withName("my-secret").withLabels(Map.of("color", "pink")).build()) - .addToData(Map.of("application.yaml", Base64.getEncoder().encodeToString("key1: value1".getBytes()))) + .addToData(Map.of(APPLICATION_YAML, Base64.getEncoder().encodeToString("key1: value1".getBytes()))) .build()) .create(); @@ -324,7 +326,7 @@ void testConfigMapDataByNameFoundWithPropertyFile() { client.configMaps() .inNamespace("spring-k8s") .resource(new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map").build()) - .addToData(Map.of("application.yaml", "key1: value1")) + .addToData(Map.of(APPLICATION_YAML, "key1: value1")) .build()) .create(); diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_active_profile_no_profile/ConfigMapsWithProfilesNoActiveProfile.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_active_profile_no_profile/ConfigMapsWithProfilesNoActiveProfile.java index 94c6d75d4..ce6b2d2ff 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_active_profile_no_profile/ConfigMapsWithProfilesNoActiveProfile.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_active_profile_no_profile/ConfigMapsWithProfilesNoActiveProfile.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.fabric8.config.TestApplication; import org.springframework.test.web.reactive.server.WebTestClient; @@ -54,7 +55,7 @@ static void setUpBeforeClass(KubernetesClient mockClient) { System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap data = new HashMap<>(); - data.put("application.yml", readResourceFile("application-with-profiles.yaml")); + data.put(Constants.APPLICATION_YML, readResourceFile("application-with-profiles.yaml")); mockClient.configMaps() .inNamespace("test") .resource(new ConfigMapBuilder().withNewMetadata() diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profile_expression/ConfigMapsWithProfileExpression.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profile_expression/ConfigMapsWithProfileExpression.java index bd992af5a..5a8bdeaa8 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profile_expression/ConfigMapsWithProfileExpression.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profile_expression/ConfigMapsWithProfileExpression.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil; import org.springframework.cloud.kubernetes.fabric8.config.TestApplication; import org.springframework.test.context.ActiveProfiles; @@ -55,7 +56,7 @@ static void setUpBeforeClass(KubernetesClient mockClient) { System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap data = new HashMap<>(); - data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml")); + data.put(Constants.APPLICATION_YML, ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml")); mockClient.configMaps() .inNamespace("test") .resource(new ConfigMapBuilder().withNewMetadata() diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profiles/ConfigMapsWithProfiles.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profiles/ConfigMapsWithProfiles.java index 1648daee7..5b563db83 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profiles/ConfigMapsWithProfiles.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_map_with_profiles/ConfigMapsWithProfiles.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil; import org.springframework.cloud.kubernetes.fabric8.config.TestApplication; import org.springframework.test.context.ActiveProfiles; @@ -58,7 +59,7 @@ static void setUpBeforeClass(KubernetesClient mockClient) { System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap data = new HashMap<>(); - data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml")); + data.put(Constants.APPLICATION_YML, ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml")); mockClient.configMaps() .inNamespace("test") .resource(new ConfigMapBuilder().withNewMetadata() diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_with_active_profiles/ConfigMapsWithActiveProfilesName.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_with_active_profiles/ConfigMapsWithActiveProfilesName.java index a34afb839..dd168b3cb 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_with_active_profiles/ConfigMapsWithActiveProfilesName.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_with_active_profiles/ConfigMapsWithActiveProfilesName.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.fabric8.config.TestApplication; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.reactive.server.WebTestClient; @@ -59,7 +60,7 @@ public static void setUpBeforeClass(KubernetesClient mockClient) { System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap data = new HashMap<>(); - data.put("application.yml", readResourceFile("application-with-profiles.yaml")); + data.put(Constants.APPLICATION_YML, readResourceFile("application-with-profiles.yaml")); mockClient.configMaps() .inNamespace("test") .resource(new ConfigMapBuilder().withNewMetadata() @@ -70,7 +71,7 @@ public static void setUpBeforeClass(KubernetesClient mockClient) { .create(); HashMap dataWithName = new HashMap<>(); - dataWithName.put("application.yml", readResourceFile("application-with-active-profiles-name.yaml")); + dataWithName.put(Constants.APPLICATION_YML, readResourceFile("application-with-active-profiles-name.yaml")); mockClient.configMaps() .inNamespace("test") .resource(new ConfigMapBuilder().withNewMetadata() diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_without_profiles/ConfigMapsWithoutProfiles.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_without_profiles/ConfigMapsWithoutProfiles.java index c0c55e4a4..31047057a 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_without_profiles/ConfigMapsWithoutProfiles.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_without_profiles/ConfigMapsWithoutProfiles.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil; import org.springframework.cloud.kubernetes.fabric8.config.TestApplication; import org.springframework.test.context.ActiveProfiles; @@ -52,7 +53,7 @@ static void setUpBeforeClass(KubernetesClient mockClient) { System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); HashMap data = new HashMap<>(); - data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-without-profiles.yaml")); + data.put(Constants.APPLICATION_YML, ConfigMapTestUtil.readResourceFile("application-without-profiles.yaml")); mockClient.configMaps() .inNamespace("test") .resource(new ConfigMapBuilder().withNewMetadata() diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigMapsFromFilePaths.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigMapsFromFilePaths.java index 4e9a61727..aa00cfb70 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigMapsFromFilePaths.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigMapsFromFilePaths.java @@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil; import org.springframework.cloud.kubernetes.fabric8.config.TestApplication; import org.springframework.test.web.reactive.server.WebTestClient; @@ -45,20 +46,18 @@ abstract class ConfigMapsFromFilePaths { protected static final String FILES_SUB_PATH = "another-directory"; - protected static final String FIRST_FILE_NAME = "application.properties"; - protected static final String SECOND_FILE_NAME = "extra.properties"; protected static final String UNUSED_FILE_NAME = "unused.properties"; - protected static final String FIRST_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + FIRST_FILE_NAME; + protected static final String FIRST_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + Constants.APPLICATION_PROPERTIES; protected static final String SECOND_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + SECOND_FILE_NAME; protected static final String UNUSED_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + UNUSED_FILE_NAME; protected static final String FIRST_FILE_NAME_DUPLICATED_FULL_PATH = FILES_ROOT_PATH + "/" + FILES_SUB_PATH + "/" - + FIRST_FILE_NAME; + + Constants.APPLICATION_PROPERTIES; @Autowired private WebTestClient webClient; diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java index 43dd539a9..0b6c39796 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Assertions; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util; import org.springframework.http.HttpMethod; @@ -71,7 +72,7 @@ static void testPollingReloadConfigMapWithBootstrap(KubernetesClient client, Uti // our polling will detect that and restart the app InputStream configMapStream = util.inputStream("configmap.yaml"); ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed")); client.configMaps().inNamespace("default").resource(configMap).createOrReplace(); await().timeout(Duration.ofSeconds(360)) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java index 3dc15e2cb..c0f5fc5d3 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Assertions; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util; import org.springframework.http.HttpMethod; @@ -75,7 +76,7 @@ static void testConfigMapMountPollingReload(KubernetesClient client, Util util, // our polling will detect that and restart the app InputStream configMapStream = util.inputStream("configmap.yaml"); ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed")); client.configMaps().inNamespace("default").resource(configMap).createOrReplace(); await().timeout(Duration.ofSeconds(360)) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/SecretsEventsReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/SecretsEventsReloadDelegate.java index 1bf56ab5a..281608211 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/SecretsEventsReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/SecretsEventsReloadDelegate.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient; @@ -68,7 +69,7 @@ static void testSecretReload(KubernetesClient client, K3sContainer container, St .withNamespace("default") .withName("event-reload") .build()) - .withData(Map.of("application.properties", + .withData(Map.of(Constants.APPLICATION_PROPERTIES, Base64.getEncoder().encodeToString("from.secret.properties.key=secret-initial".getBytes()))) .build(); client.secrets().inNamespace("default").resource(secret).createOrReplace(); @@ -89,7 +90,7 @@ static void testSecretReload(KubernetesClient client, K3sContainer container, St // change data secret = new SecretBuilder() .withMetadata(new ObjectMetaBuilder().withNamespace("default").withName("event-reload").build()) - .withData(Map.of("application.properties", + .withData(Map.of(Constants.APPLICATION_PROPERTIES, Base64.getEncoder().encodeToString("from.secret.properties.key=secret-initial-changed".getBytes()))) .build(); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/BootstrapEnabledPollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/BootstrapEnabledPollingReloadConfigMapMountDelegate.java index cd78af12e..358ae43f8 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/BootstrapEnabledPollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/BootstrapEnabledPollingReloadConfigMapMountDelegate.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Assertions; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; import org.springframework.http.HttpMethod; @@ -80,7 +81,7 @@ static void testBootstrapEnabledPollingReloadConfigMapMount(String deploymentNam // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed")); new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", NAMESPACE, configMap, null, null, null, null); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java index 7b97a6211..3092e9253 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Assertions; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; import org.springframework.http.HttpMethod; @@ -82,7 +83,7 @@ static void testPollingReloadConfigMapMount(String deploymentName, K3sContainer // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed")); new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null, null); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/DataChangesInSecretsReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/DataChangesInSecretsReloadDelegate.java index 709ae77c7..ba0ab2fa2 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/DataChangesInSecretsReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/DataChangesInSecretsReloadDelegate.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient; @@ -71,7 +72,7 @@ static void testDataChangesInSecretsReload(K3sContainer k3sContainer, String dep .withNamespace(NAMESPACE) .withName("event-reload") .build()) - .withData(Map.of("application.properties", "from.properties.key=initial".getBytes())) + .withData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=initial".getBytes())) .build(); replaceSecret(secret, "event-reload"); @@ -96,7 +97,7 @@ static void testDataChangesInSecretsReload(K3sContainer k3sContainer, String dep .withNamespace(NAMESPACE) .withName("event-reload") .build()) - .withData(Map.of("application.properties", "from.properties.key=change-initial".getBytes())) + .withData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=change-initial".getBytes())) .build(); replaceSecret(secret, "event-reload"); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/K8sClientSecretsReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/K8sClientSecretsReloadIT.java index c5685af0b..db09ca3bb 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/K8sClientSecretsReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/secret/K8sClientSecretsReloadIT.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.testcontainers.k3s.K3sContainer; +import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.Phase; import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; @@ -121,7 +122,7 @@ void testSecretEventReload() throws Exception { V1Secret v1Secret = (V1Secret) util.yaml("secret.yaml"); Map secretData = v1Secret.getData(); - secretData.replace("application.properties", "from.properties.key: after-change".getBytes()); + secretData.replace(Constants.APPLICATION_PROPERTIES, "from.properties.key: after-change".getBytes()); v1Secret.setData(secretData); coreV1Api.replaceNamespacedSecret("event-reload", NAMESPACE, v1Secret, null, null, null, null);