gemmellr commented on code in PR #5553:
URL: https://github.com/apache/activemq-artemis/pull/5553#discussion_r1991245565


##########
artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.dto;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class XmlUtilTest {
+
+   @Test
+   public void testPropertySubstituion(@TempDir Path tempDir) throws Exception 
{
+      final String SYSTEM_PROP_NAME = "sysPropName";
+      final String SYSTEM_PROP_VALUE = "sysPropValue";
+      System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE);
+
+      // since System.getenv() returns an immutable Map we rely here on an 
environment variable that is likely to exist
+      final String ENV_VAR_NAME = "HOME";

Review Comment:
   Could just define a test specific env variable in the modules own surefire 
config to be used for the test. Can then assert it is the expected value and 
compare that known value to the parsing result. It could also more nicely be 
used for checking precedence handling works in the manner expected.
   
   E.g something like:
     
       <environmentVariables combine.children="append">
          <!-- Env variable for use with <TestName(s)> -->
          <TEST_ENV_VARIABLE>TestEnvVariableValue123</TEST_ENV_VARIABLE>
       </environmentVariables>



##########
artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.dto;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class XmlUtilTest {
+
+   @Test
+   public void testPropertySubstituion(@TempDir Path tempDir) throws Exception 
{
+      final String SYSTEM_PROP_NAME = "sysPropName";
+      final String SYSTEM_PROP_VALUE = "sysPropValue";
+      System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE);

Review Comment:
   This will be left set for later tests. Could use the 
CleanupSystemPropertiesExtension, or subclass ArtemisTestCase where it is used 
already, to clear things up. The latter also has helpers for getting e.g test 
class and method names trivially to name things.



##########
artemis-dto/src/main/java/org/apache/activemq/artemis/dto/XmlUtil.java:
##########
@@ -95,6 +95,7 @@ public static <T> T decode(Class<T> clazz,
       unmarshaller.setSchema(schema);
 
       Properties props = new Properties(System.getProperties());
+      props.putAll(System.getenv());

Review Comment:
   This would create an ordering effect with the opposite precedence than I 
would typically expect, both from other configuration bits I've come across 
elsewhere, and also the other XMLUtil from Artemis. Worth flipping?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to