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 73bdbad  ARTEMIS-2310 support system prop sub in xincludes
     new 0043d9c  This closes #2640
73bdbad is described below

commit 73bdbad8b44b1da772e870168138f42256970379
Author: Justin Bertram <[email protected]>
AuthorDate: Wed Apr 24 14:17:50 2019 -0500

    ARTEMIS-2310 support system prop sub in xincludes
    
    Historically the broker has read the XML configuration file as a String,
    substituted system properties, and then parsed that String into an XML
    document. However, this method won't substitute system properties in the
    files which are imported via xinclude. In order to substitue system
    properties in xincluded files the substitution needs to be performed
    after the file is parsed into an XML document. This commit implements
    that change and refactors the XMLUtil class a bit to eliminate redundant
    code, obsolete comments, etc.
---
 .../org/apache/activemq/artemis/utils/XMLUtil.java | 54 ++++++++++++-----
 .../apache/activemq/artemis/util/XMLUtilTest.java  |  2 +-
 .../jms/server/impl/JMSServerManagerImpl.java      | 11 +---
 .../artemis/rest/MessageServiceManager.java        |  2 +-
 .../artemis/core/config/FileDeploymentManager.java | 31 ++++------
 .../core/config/impl/LegacyJMSConfiguration.java   |  7 +--
 .../deployers/impl/FileConfigurationParser.java    | 18 ++----
 .../persistence/impl/journal/DescribeJournal.java  | 69 ++++++++--------------
 .../core/config/impl/FileConfigurationTest.java    | 20 +++++++
 .../resources/ConfigurationTest-full-config.xml    | 14 ++---
 ...onfigurationTest-xinclude-config-acceptors.xml} | 12 ++--
 ...ConfigurationTest-xinclude-config-addresses.xml | 10 ++--
 ...ationTest-xinclude-config-security-settings.xml |  2 +-
 .../ConfigurationTest-xinclude-config.xml          |  7 +--
 .../config/impl/ConfigurationValidationTest.java   |  7 +++
 15 files changed, 133 insertions(+), 133 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 49d290c..c45b62d 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
@@ -23,6 +23,7 @@ import javax.xml.transform.dom.DOMSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringReader;
@@ -51,12 +52,18 @@ public final class XMLUtil {
       // Utility class
    }
 
+   public static Element streamToElement(InputStream inputStream) throws 
Exception {
+      try (Reader reader = new InputStreamReader(inputStream)) {
+         return XMLUtil.readerToElement(reader);
+      }
+   }
+
    public static Element stringToElement(final String s) throws Exception {
       return XMLUtil.readerToElement(new StringReader(s));
    }
 
    public static Element urlToElement(final URL url) throws Exception {
-      return XMLUtil.readerToElement(new InputStreamReader(url.openStream()));
+      return XMLUtil.streamToElement(url.openStream());
    }
 
    public static String readerToString(final Reader r) throws Exception {
@@ -70,24 +77,11 @@ public final class XMLUtil {
    }
 
    public static Element readerToElement(final Reader r) throws Exception {
-      // Read into string
-      StringBuffer buff = new StringBuffer();
-      int c;
-      while ((c = r.read()) != -1) {
-         buff.append((char) c);
-      }
-
-      // Quick hardcoded replace, FIXME this is a kludge - use regexp to match 
properly
-      String s = buff.toString();
-
-      StringReader sreader = new StringReader(s);
-
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6529766
       factory.setNamespaceAware(true);
       factory.setXIncludeAware(true);
       DocumentBuilder parser = factory.newDocumentBuilder();
-      Document doc = parser.parse(new InputSource(sreader));
+      Document doc = replaceSystemPropsInXml(parser.parse(new InputSource(r)));
       return doc.getDocumentElement();
    }
 
@@ -257,7 +251,8 @@ public final class XMLUtil {
       }
       return s;
    }
-   public static String replaceSystemProps(String xml) {
+
+   public static String replaceSystemPropsInString(String xml) {
       while (xml.contains("${")) {
          int start = xml.indexOf("${");
          int end = xml.indexOf("}") + 1;
@@ -280,6 +275,33 @@ public final class XMLUtil {
       return xml;
    }
 
+   public static Document replaceSystemPropsInXml(Document doc) {
+      NodeList nodeList = doc.getElementsByTagName("*");
+      for (int i = 0, len = nodeList.getLength(); i < len; i++) {
+         Node node = nodeList.item(i);
+         if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+            if (node.hasAttributes()) {
+               NamedNodeMap attributes = node.getAttributes();
+               for (int j = 0; j < attributes.getLength(); j++) {
+                  Node attribute = attributes.item(j);
+                  
attribute.setTextContent(XMLUtil.replaceSystemPropsInString(attribute.getTextContent()));
+               }
+            }
+            if (node.hasChildNodes()) {
+               NodeList children = node.getChildNodes();
+               for (int j = 0; j < children.getLength(); j++) {
+                  String value = children.item(j).getNodeValue();
+                  if (value != null) {
+                     
children.item(j).setNodeValue(XMLUtil.replaceSystemPropsInString(value));
+                  }
+               }
+            }
+         }
+      }
+
+      return doc;
+   }
+
    public static long parseLong(final Node elem) {
       String value = elem.getTextContent().trim();
 
diff --git 
a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java
 
b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java
index c7dcdaf..6a19622 100644
--- 
a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java
+++ 
b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/XMLUtilTest.java
@@ -214,7 +214,7 @@ public class XMLUtilTest extends SilentTestCase {
       String after = "<configuration>\n" + "   <test 
name=\"test1\">content1</test>\n" + "   <test name=\"test2\">content2</test>\n" 
+ "   <test name=\"test3\">content3</test>\n" + "   <test 
name=\"test4\">content4</test>\n" + "   <test name=\"test5\">content5</test>\n" 
+ "   <test name=\"test6\">content6</test>\n" + "</configuration>";
       System.setProperty("sysprop1", "test1");
       System.setProperty("sysprop2", "content4");
-      String replaced = XMLUtil.replaceSystemProps(before);
+      String replaced = XMLUtil.replaceSystemPropsInString(before);
       Assert.assertEquals(after, replaced);
    }
 
diff --git 
a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
 
b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
index 2beb9fe..a05ed27 100644
--- 
a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
+++ 
b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
@@ -17,9 +17,6 @@
 package org.apache.activemq.artemis.jms.server.impl;
 
 import javax.naming.NamingException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
 import java.net.InetAddress;
 import java.net.URL;
 import java.net.UnknownHostException;
@@ -1632,13 +1629,7 @@ public class JMSServerManagerImpl implements 
JMSServerManager, ActivateCallback
       public void reload(URL url) throws Exception {
          ActiveMQServerLogger.LOGGER.reloadingConfiguration("jms");
 
-         InputStream input = url.openStream();
-         String xml;
-         try (Reader reader = new InputStreamReader(input)) {
-            xml = XMLUtil.readerToString(reader);
-         }
-         xml = XMLUtil.replaceSystemProps(xml);
-         Element e = XMLUtil.stringToElement(xml);
+         Element e = XMLUtil.urlToElement(url);
 
          if (config instanceof FileJMSConfiguration) {
             NodeList children = e.getElementsByTagName("jms");
diff --git 
a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java
 
b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java
index 4fd8c9c..f6e6a09 100644
--- 
a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java
+++ 
b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java
@@ -124,7 +124,7 @@ public class MessageServiceManager {
             JAXBContext jaxb = 
JAXBContext.newInstance(MessageServiceConfiguration.class);
             try (Reader reader = new InputStreamReader(url.openStream())) {
                String xml = XMLUtil.readerToString(reader);
-               xml = XMLUtil.replaceSystemProps(xml);
+               xml = XMLUtil.replaceSystemPropsInString(xml);
                configuration = (MessageServiceConfiguration) 
jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
             }
          }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/FileDeploymentManager.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/FileDeploymentManager.java
index 3607e75..861047d 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/FileDeploymentManager.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/FileDeploymentManager.java
@@ -17,8 +17,6 @@
 package org.apache.activemq.artemis.core.config;
 
 import javax.management.MBeanServer;
-import java.io.InputStreamReader;
-import java.io.Reader;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -68,23 +66,18 @@ public class FileDeploymentManager {
          // The URL is outside of the classloader. Trying a pure url now
          url = new URL(configurationUrl);
       }
-      // create a reader
-      try (Reader reader = new InputStreamReader(url.openStream())) {
-         String xml = XMLUtil.readerToString(reader);
-         //replace any system props
-         xml = XMLUtil.replaceSystemProps(xml);
-         Element e = XMLUtil.stringToElement(xml);
-
-         //iterate around all the deployables
-         for (Deployable deployable : deployables.values()) {
-            String root = deployable.getRootElement();
-            NodeList children = e.getElementsByTagName(root);
-            //if the root element exists then parse it
-            if (root != null && children.getLength() > 0) {
-               Node item = children.item(0);
-               XMLUtil.validate(item, deployable.getSchema());
-               deployable.parse((Element) item, url);
-            }
+
+      Element e = XMLUtil.urlToElement(url);
+
+      //iterate around all the deployables
+      for (Deployable deployable : deployables.values()) {
+         String root = deployable.getRootElement();
+         NodeList children = e.getElementsByTagName(root);
+         //if the root element exists then parse it
+         if (root != null && children.getLength() > 0) {
+            Node item = children.item(0);
+            XMLUtil.validate(item, deployable.getSchema());
+            deployable.parse((Element) item, url);
          }
       }
    }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java
index dc50917..0a9b6e5 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java
@@ -18,8 +18,6 @@ package org.apache.activemq.artemis.core.config.impl;
 
 import javax.management.MBeanServer;
 import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
 import java.net.URL;
 import java.util.Map;
 
@@ -102,10 +100,7 @@ public class LegacyJMSConfiguration implements Deployable {
 
 
    public void parseConfiguration(final InputStream input) throws Exception {
-      Reader reader = new InputStreamReader(input);
-      String xml = XMLUtil.readerToString(reader);
-      xml = XMLUtil.replaceSystemProps(xml);
-      Element e = XMLUtil.stringToElement(xml);
+      Element e = XMLUtil.streamToElement(input);
       // only parse elements from <jms>
       NodeList children = 
e.getElementsByTagName(CONFIGURATION_SCHEMA_ROOT_ELEMENT);
       if (children.getLength() > 0) {
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index 30a3ab0..637e3ac 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -16,9 +16,12 @@
  */
 package org.apache.activemq.artemis.core.deployers.impl;
 
+import javax.xml.XMLConstants;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
 import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -93,12 +96,6 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import javax.xml.XMLConstants;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
 /**
  * Parses an XML document according to the {@literal 
artemis-configuration.xsd} schema.
  */
@@ -286,10 +283,7 @@ public final class FileConfigurationParser extends 
XMLConfigurationUtil {
    }
 
    public Configuration parseMainConfig(final InputStream input) throws 
Exception {
-      Reader reader = new InputStreamReader(input);
-      String xml = XMLUtil.readerToString(reader);
-      xml = XMLUtil.replaceSystemProps(xml);
-      Element e = XMLUtil.stringToElement(xml);
+      Element e = XMLUtil.streamToElement(input);
       SchemaFactory schemaFactory = 
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
       Schema schema = 
schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd"));
       Validator validator = schema.newValidator();
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
index d21d38a..0723d70 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
@@ -16,42 +16,15 @@
  */
 package org.apache.activemq.artemis.core.persistence.impl.journal;
 
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ACKNOWLEDGE_CURSOR;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ACKNOWLEDGE_REF;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADDRESS_BINDING_RECORD;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADDRESS_SETTING_RECORD;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE_PENDING;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_MESSAGE;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_MESSAGE_PROTOCOL;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_REF;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.DUPLICATE_ID;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.HEURISTIC_COMPLETION;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ID_COUNTER_RECORD;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_COMPLETE;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_COUNTER_INC;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_COUNTER_VALUE;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_PENDING_COUNTER;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_TRANSACTION;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.QUEUE_BINDING_RECORD;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.QUEUE_STATUS_RECORD;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.SECURITY_RECORD;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.SET_SCHEDULED_DELIVERY_TIME;
-import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.UPDATE_DELIVERY_COUNT;
-
+import javax.transaction.xa.Xid;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
 import java.io.PrintStream;
-import java.io.Reader;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import javax.transaction.xa.Xid;
-
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.Message;
@@ -95,6 +68,29 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ACKNOWLEDGE_CURSOR;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ACKNOWLEDGE_REF;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADDRESS_BINDING_RECORD;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADDRESS_SETTING_RECORD;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE_PENDING;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_MESSAGE;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_MESSAGE_PROTOCOL;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_REF;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.DUPLICATE_ID;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.HEURISTIC_COMPLETION;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ID_COUNTER_RECORD;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_COMPLETE;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_COUNTER_INC;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_COUNTER_VALUE;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_CURSOR_PENDING_COUNTER;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.PAGE_TRANSACTION;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.QUEUE_BINDING_RECORD;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.QUEUE_STATUS_RECORD;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.SECURITY_RECORD;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.SET_SCHEDULED_DELIVERY_TIME;
+import static 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.UPDATE_DELIVERY_COUNT;
+
 /**
  * Outputs a String description of the Journals contents.
  * <p>
@@ -113,15 +109,10 @@ public final class DescribeJournal {
       if (instanceFolder != null) {
          configuration = new FileConfiguration();
          File configFile = new File(instanceFolder + "/etc/broker.xml");
-         URL url;
-         Reader reader = null;
 
          try {
-            url = configFile.toURI().toURL();
-            reader = new InputStreamReader(url.openStream());
-            String xml = XMLUtil.readerToString(reader);
-            xml = XMLUtil.replaceSystemProps(xml);
-            Element e = XMLUtil.stringToElement(xml);
+            URL url = configFile.toURI().toURL();
+            Element e = XMLUtil.urlToElement(url);
 
             String root = ((FileConfiguration) configuration).getRootElement();
             NodeList children = e.getElementsByTagName(root);
@@ -132,14 +123,6 @@ public final class DescribeJournal {
             }
          } catch (Exception e) {
             logger.error("failed to load broker.xml", e);
-         } finally {
-            if (reader != null) {
-               try {
-                  reader.close();
-               } catch (IOException e) {
-                  // ignore
-               }
-            }
          }
       } else {
          configuration = new ConfigurationImpl();
diff --git 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index 79ea2d4..3ca145d 100644
--- 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -59,11 +59,31 @@ import 
org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancing
 import 
org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin;
 import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
 import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
+import org.junit.AfterClass;
 import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class FileConfigurationTest extends ConfigurationImplTest {
 
+   @BeforeClass
+   public static void setupProperties() {
+      System.setProperty("a2Prop", "a2");
+      System.setProperty("falseProp", "false");
+      System.setProperty("trueProp", "true");
+      System.setProperty("ninetyTwoProp", "92");
+   }
+
+   @AfterClass
+   public static void clearProperties() {
+      System.clearProperty("a2Prop");
+      System.clearProperty("falseProp");
+      System.clearProperty("trueProp");
+      System.clearProperty("ninetyTwoProp");
+   }
+
+
    protected String getConfigurationName() {
       return "ConfigurationTest-full-config.xml";
    }
diff --git 
a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml 
b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index 930e70b..d27e7f4 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -84,7 +84,7 @@
             tcp://0.0.0.0:61616?
             tcpNoDelay=456;
             connectionTtl=44;
-            connectionsAllowed=92
+            connectionsAllowed=${ninetyTwoProp}
          </acceptor>
          <acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
       </acceptors>
@@ -364,7 +364,7 @@
          <security-setting match="a1">
             <permission type="createNonDurableQueue" roles="a1.1"/>
          </security-setting>
-         <security-setting match="a2">
+         <security-setting match="${a2Prop}">
             <permission type="deleteNonDurableQueue" roles="a2.1"/>
          </security-setting>
       </security-settings>
@@ -438,11 +438,11 @@
          <address name="addr1">
             <anycast>
                <queue name="q1">
-                  <durable>false</durable>
+                  <durable>${falseProp}</durable>
                   <filter string="color='blue'"/>
                </queue>
-               <queue name="q2" max-consumers="-1" 
purge-on-no-consumers="false">
-                  <durable>true</durable>
+               <queue name="q2" max-consumers="-1" 
purge-on-no-consumers="${falseProp}">
+                  <durable>${trueProp}</durable>
                   <filter string="color='green'"/>
                </queue>
             </anycast>
@@ -452,8 +452,8 @@
                <queue name="q3" max-consumers="10" >
                   <filter string="color='red'"/>
                </queue>
-               <queue name="q4" purge-on-no-consumers="true">
-                  <durable>true</durable>
+               <queue name="q4" purge-on-no-consumers="${trueProp}">
+                  <durable>${trueProp}</durable>
                </queue>
             </multicast>
          </address>
diff --git 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-acceptors.xml
similarity index 72%
copy from 
artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
copy to 
artemis-server/src/test/resources/ConfigurationTest-xinclude-config-acceptors.xml
index e22784c..9ebad57 100644
--- 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
+++ 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-acceptors.xml
@@ -14,11 +14,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<security-settings xmlns="urn:activemq:core">
-   <security-setting match="a1">
-      <permission type="createNonDurableQueue" roles="a1.1"/>
-   </security-setting>
-   <security-setting match="a2">
-      <permission type="deleteNonDurableQueue" roles="a2.1"/>
-   </security-setting>
-</security-settings>
\ No newline at end of file
+<acceptors xmlns="urn:activemq:core">
+   
<acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=${ninetyTwoProp}</acceptor>
+   <acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
+</acceptors>
\ No newline at end of file
diff --git 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml
 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml
index 377b048..530695e 100644
--- 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml
+++ 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml
@@ -18,11 +18,11 @@
    <address name="addr1">
       <anycast>
          <queue name="q1">
-            <durable>false</durable>
+            <durable>${falseProp}</durable>
             <filter string="color='blue'"/>
          </queue>
-         <queue name="q2" max-consumers="-1" purge-on-no-consumers="false">
-            <durable>true</durable>
+         <queue name="q2" max-consumers="-1" 
purge-on-no-consumers="${falseProp}">
+            <durable>${trueProp}</durable>
             <filter string="color='green'"/>
          </queue>
       </anycast>
@@ -32,8 +32,8 @@
          <queue name="q3" max-consumers="10" >
             <filter string="color='red'"/>
          </queue>
-         <queue name="q4" purge-on-no-consumers="true">
-            <durable>true</durable>
+         <queue name="q4" purge-on-no-consumers="${trueProp}">
+            <durable>${trueProp}</durable>
          </queue>
       </multicast>
    </address>
diff --git 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
index e22784c..38076ab 100644
--- 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
+++ 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml
@@ -18,7 +18,7 @@
    <security-setting match="a1">
       <permission type="createNonDurableQueue" roles="a1.1"/>
    </security-setting>
-   <security-setting match="a2">
+   <security-setting match="${a2Prop}">
       <permission type="deleteNonDurableQueue" roles="a2.1"/>
    </security-setting>
 </security-settings>
\ No newline at end of file
diff --git 
a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml 
b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml
index c99b4eb..bd647d6 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml
@@ -76,10 +76,9 @@
          <connector 
name="connector1">tcp://localhost1:5678?localAddress=mylocal;localPort=99</connector>
          <connector name="connector2">vm://5</connector>
       </connectors>
-      <acceptors>
-         
<acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=92</acceptor>
-         <acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
-      </acceptors>
+
+      <xi:include 
href="./src/test/resources/ConfigurationTest-xinclude-config-acceptors.xml"/>
+
       <broadcast-groups>
          <broadcast-group name="bg1">
             <local-bind-port>10999</local-bind-port>
diff --git 
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java
 
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java
index c6b7c16..e7420ba 100644
--- 
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java
+++ 
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java
@@ -26,6 +26,13 @@ import org.w3c.dom.Element;
 
 public class ConfigurationValidationTest extends ActiveMQTestBase {
 
+   static {
+      System.setProperty("a2Prop", "a2");
+      System.setProperty("falseProp", "false");
+      System.setProperty("trueProp", "true");
+      System.setProperty("ninetyTwoProp", "92");
+   }
+
    // Constants -----------------------------------------------------
 
    // Attributes ----------------------------------------------------

Reply via email to