This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 1c36194707 Avoid setting null config property overrides in test 
profiles
1c36194707 is described below

commit 1c36194707171b255823b3ba41d215b298ff32b6
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Tue Apr 1 08:55:19 2025 +0100

    Avoid setting null config property overrides in test profiles
---
 .../vault/it/AzureKeyVaultContextReloadTestProfile.java | 17 ++++++++++-------
 ...ureKeyVaultContextReloadWithIdentityTestProfile.java | 12 +++++++-----
 .../azure/key/vault/it/AzureKeyVaultTestProfile.java    | 12 ++++++++----
 .../component/azure/key/vault/it/AzureKeyVaultUtil.java |  8 ++++++++
 4 files changed, 33 insertions(+), 16 deletions(-)

diff --git 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadTestProfile.java
 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadTestProfile.java
index a5f5567186..f335cc3998 100644
--- 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadTestProfile.java
+++ 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadTestProfile.java
@@ -22,22 +22,25 @@ import java.util.UUID;
 
 import io.quarkus.test.junit.QuarkusTestProfile;
 
+import static 
org.apache.camel.quarkus.component.azure.key.vault.it.AzureKeyVaultUtil.setPropertyIfEnvVarPresent;
+
 public class AzureKeyVaultContextReloadTestProfile implements 
QuarkusTestProfile {
 
     @Override
     public Map<String, String> getConfigOverrides() {
         //properties have to be set via profile to not be used by different 
azure-* test in grouped module
         Map<String, String> props = new HashMap<>();
-        props.put("camel.vault.azure.tenantId", 
System.getenv("AZURE_TENANT_ID"));
-        props.put("camel.vault.azure.clientId", 
System.getenv("AZURE_CLIENT_ID"));
-        props.put("camel.vault.azure.clientSecret", 
System.getenv("AZURE_CLIENT_SECRET"));
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.tenantId", 
"AZURE_TENANT_ID");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.clientId", 
"AZURE_CLIENT_ID");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.clientSecret", 
"AZURE_CLIENT_SECRET");
+        setPropertyIfEnvVarPresent(props, 
"camel.vault.azure.eventhubConnectionString",
+                "AZURE_VAULT_EVENT_HUBS_CONNECTION_STRING");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.blobAccountName", 
"AZURE_STORAGE_ACCOUNT_NAME");
+        setPropertyIfEnvVarPresent(props, 
"camel.vault.azure.blobContainerName", 
"AZURE_VAULT_EVENT_HUBS_BLOB_CONTAINER_NAME");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.blobAccessKey", 
"AZURE_STORAGE_ACCOUNT_KEY");
         props.put("camel.vault.azure.refreshEnabled", "true");
         props.put("camel.vault.azure.refreshPeriod", "1000");
         props.put("camel.vault.azure.secrets", 
String.format("cq-secret-context-refresh-%s.*", UUID.randomUUID()));
-        props.put("camel.vault.azure.eventhubConnectionString", 
System.getenv("AZURE_VAULT_EVENT_HUBS_CONNECTION_STRING"));
-        props.put("camel.vault.azure.blobAccountName", 
System.getenv("AZURE_STORAGE_ACCOUNT_NAME"));
-        props.put("camel.vault.azure.blobContainerName", 
System.getenv("AZURE_VAULT_EVENT_HUBS_BLOB_CONTAINER_NAME"));
-        props.put("camel.vault.azure.blobAccessKey", 
System.getenv("AZURE_STORAGE_ACCOUNT_KEY"));
 
         return props;
     }
diff --git 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadWithIdentityTestProfile.java
 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadWithIdentityTestProfile.java
index 4f22b2547d..31cb7b1d18 100644
--- 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadWithIdentityTestProfile.java
+++ 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultContextReloadWithIdentityTestProfile.java
@@ -22,21 +22,23 @@ import java.util.UUID;
 
 import io.quarkus.test.junit.QuarkusTestProfile;
 
+import static 
org.apache.camel.quarkus.component.azure.key.vault.it.AzureKeyVaultUtil.setPropertyIfEnvVarPresent;
+
 public class AzureKeyVaultContextReloadWithIdentityTestProfile implements 
QuarkusTestProfile {
 
     @Override
     public Map<String, String> getConfigOverrides() {
         //properties have to be set via profile to not be used by different 
azure-* test in grouped module
         Map<String, String> props = new HashMap<>();
+        setPropertyIfEnvVarPresent(props, 
"camel.vault.azure.eventhubConnectionString",
+                "AZURE_VAULT_EVENT_HUBS_CONNECTION_STRING");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.blobAccountName", 
"AZURE_STORAGE_ACCOUNT_NAME");
+        setPropertyIfEnvVarPresent(props, 
"camel.vault.azure.blobContainerName", 
"AZURE_VAULT_EVENT_HUBS_BLOB_CONTAINER_NAME");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.blobAccessKey", 
"AZURE_STORAGE_ACCOUNT_KEY");
         props.put("camel.vault.azure.refreshEnabled", "true");
         props.put("camel.vault.azure.refreshPeriod", "1000");
         props.put("camel.vault.azure.secrets", 
String.format("cq-secret-context-refresh-identity-%s.*", UUID.randomUUID()));
-        props.put("camel.vault.azure.eventhubConnectionString", 
System.getenv("AZURE_VAULT_EVENT_HUBS_CONNECTION_STRING"));
-        props.put("camel.vault.azure.blobAccountName", 
System.getenv("AZURE_STORAGE_ACCOUNT_NAME"));
-        props.put("camel.vault.azure.blobContainerName", 
System.getenv("AZURE_VAULT_EVENT_HUBS_BLOB_CONTAINER_NAME"));
-        props.put("camel.vault.azure.blobAccessKey", 
System.getenv("AZURE_STORAGE_ACCOUNT_KEY"));
         props.put("camel.vault.azure.azureIdentityEnabled", "true");
-
         return props;
     }
 }
diff --git 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultTestProfile.java
 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultTestProfile.java
index d1b5899d02..0aa94112c0 100644
--- 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultTestProfile.java
+++ 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultTestProfile.java
@@ -16,17 +16,21 @@
  */
 package org.apache.camel.quarkus.component.azure.key.vault.it;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import io.quarkus.test.junit.QuarkusTestProfile;
 
+import static 
org.apache.camel.quarkus.component.azure.key.vault.it.AzureKeyVaultUtil.setPropertyIfEnvVarPresent;
+
 public class AzureKeyVaultTestProfile implements QuarkusTestProfile {
     @Override
     public Map<String, String> getConfigOverrides() {
         //properties have to be set via profile to not be used by different 
azure-* test in grouped module
-        return Map.of(
-                "camel.vault.azure.tenantId", System.getenv("AZURE_TENANT_ID"),
-                "camel.vault.azure.clientId", System.getenv("AZURE_CLIENT_ID"),
-                "camel.vault.azure.clientSecret", 
System.getenv("AZURE_CLIENT_SECRET"));
+        Map<String, String> props = new HashMap<>();
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.tenantId", 
"AZURE_TENANT_ID");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.clientId", 
"AZURE_CLIENT_ID");
+        setPropertyIfEnvVarPresent(props, "camel.vault.azure.clientSecret", 
"AZURE_CLIENT_ID");
+        return props;
     }
 }
diff --git 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultUtil.java
 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultUtil.java
index 18b9f4825b..99b5a95f21 100644
--- 
a/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultUtil.java
+++ 
b/integration-test-groups/azure/azure-key-vault/src/test/java/org/apache/camel/quarkus/component/azure/key/vault/it/AzureKeyVaultUtil.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.quarkus.component.azure.key.vault.it;
 
+import java.util.Map;
+
 import com.azure.core.credential.TokenCredential;
 import com.azure.core.exception.HttpResponseException;
 import com.azure.core.exception.ResourceNotFoundException;
@@ -113,4 +115,10 @@ public class AzureKeyVaultUtil {
             }
         }
     }
+
+    public static void setPropertyIfEnvVarPresent(Map<String, String> 
properties, String key, String envVarName) {
+        if (System.getenv(envVarName) != null) {
+            properties.put(key, System.getenv(envVarName));
+        }
+    }
 }

Reply via email to