[activemq-artemis] branch master updated: ARTEMIS-2516 support sys props in xinclude href

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[activemq-artemis] branch master updated: ARTEMIS-2516 support sys props in xinclude href

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

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 9e9c077  ARTEMIS-2516 support sys props in xinclude href
     new 27672a4  This closes #2862
9e9c077 is described below

commit 9e9c0778b1b99b3e3ab5cd7f4aeed0418b2298ba
Author: Justin Bertram <[hidden email]>
AuthorDate: Thu Oct 10 09:04:05 2019 -0500

    ARTEMIS-2516 support sys props in xinclude href
---
 .../org/apache/activemq/artemis/utils/XMLUtil.java  |  2 +-
 .../config/impl/FileXIncludeConfigurationTest.java  | 21 +++++++++++++++++++++
 .../resources/ConfigurationTest-xinclude-config.xml |  8 ++++----
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
index c45b62d..ce75f33 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
@@ -81,7 +81,7 @@ public final class XMLUtil {
       factory.setNamespaceAware(true);
       factory.setXIncludeAware(true);
       DocumentBuilder parser = factory.newDocumentBuilder();
-      Document doc = replaceSystemPropsInXml(parser.parse(new InputSource(r)));
+      Document doc = replaceSystemPropsInXml(parser.parse(new InputSource(new StringReader(replaceSystemPropsInString(readerToString(r))))));
       return doc.getDocumentElement();
    }
 
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java
index dd7e88a..acd0256 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java
@@ -16,8 +16,29 @@
  */
 package org.apache.activemq.artemis.core.config.impl;
 
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
 public class FileXIncludeConfigurationTest extends FileConfigurationTest {
 
+   @BeforeClass
+   public static void setupProperties() {
+      System.setProperty("xincludePath", "./src/test/resources");
+      System.setProperty("a2Prop", "a2");
+      System.setProperty("falseProp", "false");
+      System.setProperty("trueProp", "true");
+      System.setProperty("ninetyTwoProp", "92");
+   }
+
+   @AfterClass
+   public static void clearProperties() {
+      System.clearProperty("xincludePath");
+      System.clearProperty("a2Prop");
+      System.clearProperty("falseProp");
+      System.clearProperty("trueProp");
+      System.clearProperty("ninetyTwoProp");
+   }
+
    @Override
    protected String getConfigurationName() {
       return  "ConfigurationTest-xinclude-config.xml";
diff --git a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml
index 23ab14f..5d218bb 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml
@@ -78,7 +78,7 @@
          <connector name="connector2">vm://5</connector>
       </connectors>
 
-      <xi:include href="./src/test/resources/ConfigurationTest-xinclude-config-acceptors.xml"/>
+      <xi:include href="${xincludePath}/ConfigurationTest-xinclude-config-acceptors.xml"/>
 
       <broadcast-groups>
          <broadcast-group name="bg1">
@@ -284,9 +284,9 @@
       <network-check-ping-command>ping-four</network-check-ping-command>
       <network-check-ping6-command>ping-six</network-check-ping6-command>
 
-      <xi:include href="./src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml"/>
+      <xi:include href="${xincludePath}/ConfigurationTest-xinclude-config-security-settings.xml"/>
 
-      <xi:include href="./src/test/resources/ConfigurationTest-xinclude-config-address-settings.xml"/>
+      <xi:include href="${xincludePath}/ConfigurationTest-xinclude-config-address-settings.xml"/>
 
       <resource-limit-settings>
          <resource-limit-setting match="myUser">
@@ -300,6 +300,6 @@
          </connector-service>
       </connector-services>
 
-      <xi:include href="./src/test/resources/ConfigurationTest-xinclude-config-addresses.xml"/>
+      <xi:include href="${xincludePath}/ConfigurationTest-xinclude-config-addresses.xml"/>
    </core>
 </configuration>