[ 
https://issues.apache.org/jira/browse/ARTEMIS-3757?focusedWorklogId=752766&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-752766
 ]

ASF GitHub Bot logged work on ARTEMIS-3757:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Apr/22 11:27
            Start Date: 05/Apr/22 11:27
    Worklog Time Spent: 10m 
      Work Description: gtully commented on code in PR #4011:
URL: https://github.com/apache/activemq-artemis/pull/4011#discussion_r842675550


##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java:
##########
@@ -708,6 +720,149 @@ public void testValuePostFixModifier() throws Throwable {
       Assert.assertEquals(25 * 1024, configuration.getGlobalMaxSize());
    }
 
+   @Test
+   public void testSystemPropValueReplaced() throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl();
+      Properties properties = new Properties();
+      final String homeFromDefault = "default-home";
+      final String homeFromEnv = System.getenv("HOME");
+      properties.put("name", "${HOME:" + homeFromDefault + "}");
+      configuration.parsePrefixedProperties(properties, null);
+      if (homeFromEnv != null) {
+         Assert.assertEquals(homeFromEnv, configuration.getName());
+      } else {
+         // if $HOME is not set for some platform
+         Assert.assertEquals(homeFromDefault, configuration.getName());
+      }
+   }
+
+   @Test
+   public void testSystemPropValueNoMatch() throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl();
+      Properties properties = new Properties();
+      properties.put("name", "vv-${SOME_RANDOM_VV}");
+      configuration.parsePrefixedProperties(properties, null);
+      Assert.assertEquals("vv-", configuration.getName());
+   }
+
+   @Test
+   public void testSystemPropValueNonExistWithDefault() throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl();
+      Properties properties = new Properties();
+      properties.put("name", "vv-${SOME_RANDOM_VV:y}");
+      configuration.parsePrefixedProperties(properties, null);
+      Assert.assertEquals("vv-y", configuration.getName());
+   }
+
+
+   @Test
+   public void testSystemPropKeyReplacement() throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl();
+      Properties properties = new Properties();
+
+      final String newKeyName = RandomUtil.randomString();

Review Comment:
   just b/c I don't have full control of the system properties in play





Issue Time Tracking
-------------------

    Worklog Id:     (was: 752766)
    Time Spent: 40m  (was: 0.5h)

> properties config - allow system and env var substitution
> ---------------------------------------------------------
>
>                 Key: ARTEMIS-3757
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3757
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>          Components: Configuration
>    Affects Versions: 2.21.0
>            Reporter: Gary Tully
>            Assignee: Gary Tully
>            Priority: Major
>             Fix For: 2.22.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> It would be useful if the key/value pairs from properties files supported 
> substitution of env vars, from system properties with fallback to the os.env. 
> There is support in the xml config for system props



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to