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.
This commit is contained in:
Justin Bertram 2019-04-24 14:17:50 -05:00 committed by Clebert Suconic
parent 31348621cd
commit 73bdbad8b4
15 changed files with 148 additions and 124 deletions

View File

@ -23,6 +23,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator; import javax.xml.validation.Validator;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
@ -51,12 +52,18 @@ public final class XMLUtil {
// Utility class // 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 { public static Element stringToElement(final String s) throws Exception {
return XMLUtil.readerToElement(new StringReader(s)); return XMLUtil.readerToElement(new StringReader(s));
} }
public static Element urlToElement(final URL url) throws Exception { 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 { 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 { 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(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6529766
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
factory.setXIncludeAware(true); factory.setXIncludeAware(true);
DocumentBuilder parser = factory.newDocumentBuilder(); DocumentBuilder parser = factory.newDocumentBuilder();
Document doc = parser.parse(new InputSource(sreader)); Document doc = replaceSystemPropsInXml(parser.parse(new InputSource(r)));
return doc.getDocumentElement(); return doc.getDocumentElement();
} }
@ -257,7 +251,8 @@ public final class XMLUtil {
} }
return s; return s;
} }
public static String replaceSystemProps(String xml) {
public static String replaceSystemPropsInString(String xml) {
while (xml.contains("${")) { while (xml.contains("${")) {
int start = xml.indexOf("${"); int start = xml.indexOf("${");
int end = xml.indexOf("}") + 1; int end = xml.indexOf("}") + 1;
@ -280,6 +275,33 @@ public final class XMLUtil {
return xml; 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) { public static long parseLong(final Node elem) {
String value = elem.getTextContent().trim(); String value = elem.getTextContent().trim();

View File

@ -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>"; 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("sysprop1", "test1");
System.setProperty("sysprop2", "content4"); System.setProperty("sysprop2", "content4");
String replaced = XMLUtil.replaceSystemProps(before); String replaced = XMLUtil.replaceSystemPropsInString(before);
Assert.assertEquals(after, replaced); Assert.assertEquals(after, replaced);
} }

View File

@ -17,9 +17,6 @@
package org.apache.activemq.artemis.jms.server.impl; package org.apache.activemq.artemis.jms.server.impl;
import javax.naming.NamingException; import javax.naming.NamingException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -1632,13 +1629,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
public void reload(URL url) throws Exception { public void reload(URL url) throws Exception {
ActiveMQServerLogger.LOGGER.reloadingConfiguration("jms"); ActiveMQServerLogger.LOGGER.reloadingConfiguration("jms");
InputStream input = url.openStream(); Element e = XMLUtil.urlToElement(url);
String xml;
try (Reader reader = new InputStreamReader(input)) {
xml = XMLUtil.readerToString(reader);
}
xml = XMLUtil.replaceSystemProps(xml);
Element e = XMLUtil.stringToElement(xml);
if (config instanceof FileJMSConfiguration) { if (config instanceof FileJMSConfiguration) {
NodeList children = e.getElementsByTagName("jms"); NodeList children = e.getElementsByTagName("jms");

View File

@ -124,7 +124,7 @@ public class MessageServiceManager {
JAXBContext jaxb = JAXBContext.newInstance(MessageServiceConfiguration.class); JAXBContext jaxb = JAXBContext.newInstance(MessageServiceConfiguration.class);
try (Reader reader = new InputStreamReader(url.openStream())) { try (Reader reader = new InputStreamReader(url.openStream())) {
String xml = XMLUtil.readerToString(reader); String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml); xml = XMLUtil.replaceSystemPropsInString(xml);
configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml)); configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
} }
} }

View File

@ -17,8 +17,6 @@
package org.apache.activemq.artemis.core.config; package org.apache.activemq.artemis.core.config;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -68,23 +66,18 @@ public class FileDeploymentManager {
// The URL is outside of the classloader. Trying a pure url now // The URL is outside of the classloader. Trying a pure url now
url = new URL(configurationUrl); 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 Element e = XMLUtil.urlToElement(url);
for (Deployable deployable : deployables.values()) {
String root = deployable.getRootElement(); //iterate around all the deployables
NodeList children = e.getElementsByTagName(root); for (Deployable deployable : deployables.values()) {
//if the root element exists then parse it String root = deployable.getRootElement();
if (root != null && children.getLength() > 0) { NodeList children = e.getElementsByTagName(root);
Node item = children.item(0); //if the root element exists then parse it
XMLUtil.validate(item, deployable.getSchema()); if (root != null && children.getLength() > 0) {
deployable.parse((Element) item, url); Node item = children.item(0);
} XMLUtil.validate(item, deployable.getSchema());
deployable.parse((Element) item, url);
} }
} }
} }

View File

@ -18,8 +18,6 @@ package org.apache.activemq.artemis.core.config.impl;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL; import java.net.URL;
import java.util.Map; import java.util.Map;
@ -102,10 +100,7 @@ public class LegacyJMSConfiguration implements Deployable {
public void parseConfiguration(final InputStream input) throws Exception { public void parseConfiguration(final InputStream input) throws Exception {
Reader reader = new InputStreamReader(input); Element e = XMLUtil.streamToElement(input);
String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
Element e = XMLUtil.stringToElement(xml);
// only parse elements from <jms> // only parse elements from <jms>
NodeList children = e.getElementsByTagName(CONFIGURATION_SCHEMA_ROOT_ELEMENT); NodeList children = e.getElementsByTagName(CONFIGURATION_SCHEMA_ROOT_ELEMENT);
if (children.getLength() > 0) { if (children.getLength() > 0) {

View File

@ -16,9 +16,12 @@
*/ */
package org.apache.activemq.artemis.core.deployers.impl; 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.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.ArrayList;
@ -93,12 +96,6 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; 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. * 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 { public Configuration parseMainConfig(final InputStream input) throws Exception {
Reader reader = new InputStreamReader(input); Element e = XMLUtil.streamToElement(input);
String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
Element e = XMLUtil.stringToElement(xml);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd")); Schema schema = schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd"));
Validator validator = schema.newValidator(); Validator validator = schema.newValidator();

View File

@ -16,42 +16,15 @@
*/ */
package org.apache.activemq.artemis.core.persistence.impl.journal; package org.apache.activemq.artemis.core.persistence.impl.journal;
import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ACKNOWLEDGE_CURSOR; import javax.transaction.xa.Xid;
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 java.io.File; import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.Reader;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.transaction.xa.Xid;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
import org.apache.activemq.artemis.api.core.Message; 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.Node;
import org.w3c.dom.NodeList; 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. * Outputs a String description of the Journals contents.
* <p> * <p>
@ -113,15 +109,10 @@ public final class DescribeJournal {
if (instanceFolder != null) { if (instanceFolder != null) {
configuration = new FileConfiguration(); configuration = new FileConfiguration();
File configFile = new File(instanceFolder + "/etc/broker.xml"); File configFile = new File(instanceFolder + "/etc/broker.xml");
URL url;
Reader reader = null;
try { try {
url = configFile.toURI().toURL(); URL url = configFile.toURI().toURL();
reader = new InputStreamReader(url.openStream()); Element e = XMLUtil.urlToElement(url);
String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
Element e = XMLUtil.stringToElement(xml);
String root = ((FileConfiguration) configuration).getRootElement(); String root = ((FileConfiguration) configuration).getRootElement();
NodeList children = e.getElementsByTagName(root); NodeList children = e.getElementsByTagName(root);
@ -132,14 +123,6 @@ public final class DescribeJournal {
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("failed to load broker.xml", e); logger.error("failed to load broker.xml", e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
} }
} else { } else {
configuration = new ConfigurationImpl(); configuration = new ConfigurationImpl();

View File

@ -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.impl.LegacyLDAPSecuritySettingPlugin;
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin; import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy; import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class FileConfigurationTest extends ConfigurationImplTest { 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() { protected String getConfigurationName() {
return "ConfigurationTest-full-config.xml"; return "ConfigurationTest-full-config.xml";
} }

View File

@ -84,7 +84,7 @@
tcp://0.0.0.0:61616? tcp://0.0.0.0:61616?
tcpNoDelay=456; tcpNoDelay=456;
connectionTtl=44; connectionTtl=44;
connectionsAllowed=92 connectionsAllowed=${ninetyTwoProp}
</acceptor> </acceptor>
<acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor> <acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
</acceptors> </acceptors>
@ -364,7 +364,7 @@
<security-setting match="a1"> <security-setting match="a1">
<permission type="createNonDurableQueue" roles="a1.1"/> <permission type="createNonDurableQueue" roles="a1.1"/>
</security-setting> </security-setting>
<security-setting match="a2"> <security-setting match="${a2Prop}">
<permission type="deleteNonDurableQueue" roles="a2.1"/> <permission type="deleteNonDurableQueue" roles="a2.1"/>
</security-setting> </security-setting>
</security-settings> </security-settings>
@ -438,11 +438,11 @@
<address name="addr1"> <address name="addr1">
<anycast> <anycast>
<queue name="q1"> <queue name="q1">
<durable>false</durable> <durable>${falseProp}</durable>
<filter string="color='blue'"/> <filter string="color='blue'"/>
</queue> </queue>
<queue name="q2" max-consumers="-1" purge-on-no-consumers="false"> <queue name="q2" max-consumers="-1" purge-on-no-consumers="${falseProp}">
<durable>true</durable> <durable>${trueProp}</durable>
<filter string="color='green'"/> <filter string="color='green'"/>
</queue> </queue>
</anycast> </anycast>
@ -452,8 +452,8 @@
<queue name="q3" max-consumers="10" > <queue name="q3" max-consumers="10" >
<filter string="color='red'"/> <filter string="color='red'"/>
</queue> </queue>
<queue name="q4" purge-on-no-consumers="true"> <queue name="q4" purge-on-no-consumers="${trueProp}">
<durable>true</durable> <durable>${trueProp}</durable>
</queue> </queue>
</multicast> </multicast>
</address> </address>

View File

@ -0,0 +1,20 @@
<!--
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.
-->
<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>

View File

@ -18,11 +18,11 @@
<address name="addr1"> <address name="addr1">
<anycast> <anycast>
<queue name="q1"> <queue name="q1">
<durable>false</durable> <durable>${falseProp}</durable>
<filter string="color='blue'"/> <filter string="color='blue'"/>
</queue> </queue>
<queue name="q2" max-consumers="-1" purge-on-no-consumers="false"> <queue name="q2" max-consumers="-1" purge-on-no-consumers="${falseProp}">
<durable>true</durable> <durable>${trueProp}</durable>
<filter string="color='green'"/> <filter string="color='green'"/>
</queue> </queue>
</anycast> </anycast>
@ -32,8 +32,8 @@
<queue name="q3" max-consumers="10" > <queue name="q3" max-consumers="10" >
<filter string="color='red'"/> <filter string="color='red'"/>
</queue> </queue>
<queue name="q4" purge-on-no-consumers="true"> <queue name="q4" purge-on-no-consumers="${trueProp}">
<durable>true</durable> <durable>${trueProp}</durable>
</queue> </queue>
</multicast> </multicast>
</address> </address>

View File

@ -18,7 +18,7 @@
<security-setting match="a1"> <security-setting match="a1">
<permission type="createNonDurableQueue" roles="a1.1"/> <permission type="createNonDurableQueue" roles="a1.1"/>
</security-setting> </security-setting>
<security-setting match="a2"> <security-setting match="${a2Prop}">
<permission type="deleteNonDurableQueue" roles="a2.1"/> <permission type="deleteNonDurableQueue" roles="a2.1"/>
</security-setting> </security-setting>
</security-settings> </security-settings>

View File

@ -76,10 +76,9 @@
<connector name="connector1">tcp://localhost1:5678?localAddress=mylocal;localPort=99</connector> <connector name="connector1">tcp://localhost1:5678?localAddress=mylocal;localPort=99</connector>
<connector name="connector2">vm://5</connector> <connector name="connector2">vm://5</connector>
</connectors> </connectors>
<acceptors>
<acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=92</acceptor> <xi:include href="./src/test/resources/ConfigurationTest-xinclude-config-acceptors.xml"/>
<acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
</acceptors>
<broadcast-groups> <broadcast-groups>
<broadcast-group name="bg1"> <broadcast-group name="bg1">
<local-bind-port>10999</local-bind-port> <local-bind-port>10999</local-bind-port>

View File

@ -26,6 +26,13 @@ import org.w3c.dom.Element;
public class ConfigurationValidationTest extends ActiveMQTestBase { public class ConfigurationValidationTest extends ActiveMQTestBase {
static {
System.setProperty("a2Prop", "a2");
System.setProperty("falseProp", "false");
System.setProperty("trueProp", "true");
System.setProperty("ninetyTwoProp", "92");
}
// Constants ----------------------------------------------------- // Constants -----------------------------------------------------
// Attributes ---------------------------------------------------- // Attributes ----------------------------------------------------