summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker/etc/config.xml142
-rw-r--r--qpid/java/broker/etc/persistent_config.xml121
-rw-r--r--qpid/java/broker/etc/transient_config.xml118
-rw-r--r--qpid/java/broker/etc/virtualhosts.xml161
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java116
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java653
-rw-r--r--qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml18
-rw-r--r--qpid/java/systests/etc/config-systests-acl-settings.xml136
-rw-r--r--qpid/java/systests/etc/config-systests-acl.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-derby-settings.xml40
-rw-r--r--qpid/java/systests/etc/config-systests-derby.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-firewall-2.xml28
-rw-r--r--qpid/java/systests/etc/config-systests-firewall-3.xml28
-rw-r--r--qpid/java/systests/etc/config-systests-firewall-settings.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-firewall.xml5
-rw-r--r--qpid/java/systests/etc/config-systests-settings.xml1
-rw-r--r--qpid/java/systests/etc/config-systests.xml2
-rw-r--r--qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml7
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml156
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-acl.xml29
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml54
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-derby.xml29
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml47
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml49
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-firewall.xml29
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests.xml28
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java19
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java28
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java47
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java100
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java139
-rw-r--r--qpid/java/test-profiles/log4j-test.xml4
33 files changed, 1500 insertions, 842 deletions
diff --git a/qpid/java/broker/etc/config.xml b/qpid/java/broker/etc/config.xml
index 8fb3a8cf5a..fd5d84a1e8 100644
--- a/qpid/java/broker/etc/config.xml
+++ b/qpid/java/broker/etc/config.xml
@@ -23,6 +23,7 @@
<prefix>${QPID_HOME}</prefix>
<work>${QPID_WORK}</work>
<conf>${prefix}/etc</conf>
+
<connector>
<!-- To enable SSL edit the keystorePath and keystorePassword
and set enabled to true.
@@ -92,145 +93,8 @@
</jmx>
</security>
- <virtualhosts>
-
- <default>test</default>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
-
- <housekeeping>
- <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
- </housekeeping>
-
- <exchanges>
- <exchange>
- <type>direct</type>
- <name>test.direct</name>
- <durable>true</durable>
- </exchange>
- <exchange>
- <type>topic</type>
- <name>test.topic</name>
- </exchange>
- </exchanges>
- <queues>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- <maximumMessageCount>50</maximumMessageCount>
- <!-- 50 messages -->
-
- <queue>
- <name>queue</name>
- </queue>
- <queue>
- <name>ping</name>
- </queue>
- <queue>
- <name>test-queue</name>
- <test-queue>
- <exchange>test.direct</exchange>
- <durable>true</durable>
- </test-queue>
- </queue>
- <queue>
- <name>test-ping</name>
- <test-ping>
- <exchange>test.direct</exchange>
- </test-ping>
- </queue>
-
- </queues>
- </localhost>
- </virtualhost>
-
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
-
- <queues>
- <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
- <maximumMessageCount>50</maximumMessageCount>
- <queue>
- <name>queue</name>
- <queue>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </queue>
- </queue>
- <queue>
- <name>ping</name>
- <ping>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </ping>
- </queue>
- </queues>
- </development>
- </virtualhost>
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
-
- <queues>
- <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
- <maximumMessageCount>50</maximumMessageCount>
- <queue>
- <name>queue</name>
- <queue>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </queue>
- </queue>
- <queue>
- <name>ping</name>
- <ping>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </ping>
- </queue>
- </queues>
- </test>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
diff --git a/qpid/java/broker/etc/persistent_config.xml b/qpid/java/broker/etc/persistent_config.xml
deleted file mode 100644
index 67ef28117d..0000000000
--- a/qpid/java/broker/etc/persistent_config.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- -
- - 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.
- -
-
- This is an example config using the BDBMessageStore available from
- the Red Hat Messaging project at etp.108.redhat.com and distributed under GPL.
- -->
-
-<broker>
- <prefix>${QPID_HOME}</prefix>
- <work>${QPID_WORK}</work>
- <conf>${prefix}/etc</conf>
- <connector>
- <transport>nio</transport>
- <port>5672</port>
- <sslport>8672</sslport>
- <socketReceiveBuffer>32768</socketReceiveBuffer>
- <socketSendBuffer>32768</socketSendBuffer>
- </connector>
- <management>
- <enabled>true</enabled>
- <jmxport>8999</jmxport>
- <ssl>
- <enabled>true</enabled>
- <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore -->
- <keyStorePath>${prefix}/../test_resources/ssl/keystore.jks</keyStorePath>
- <keyStorePassword>password</keyStorePassword>
- </ssl>
- </management>
- <advanced>
- <filterchain enableExecutorPool="true"/>
- <enablePooledAllocator>false</enablePooledAllocator>
- <enableDirectBuffers>false</enableDirectBuffers>
- <framesize>65535</framesize>
- <compressBufferOnQueue>false</compressBufferOnQueue>
- </advanced>
-
- <security>
- <principal-databases>
- <principal-database>
- <name>passwordfile</name>
- <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
- <attributes>
- <attribute>
- <name>passwordFile</name>
- <value>${conf}/passwd</value>
- </attribute>
- </attributes>
- </principal-database>
- </principal-databases>
-
- <access>
- <class>org.apache.qpid.server.security.access.plugins.AllowAll</class>
- </access>
- <jmx>
- <access>${conf}/jmxremote.access</access>
- <principal-database>passwordfile</principal-database>
- </jmx>
- </security>
-
- <virtualhosts>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdbstore/localhost-store</environment-path>
- </store>
- </localhost>
- </virtualhost>
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdbstore/development-store</environment-path>
- </store>
- </development>
- </virtualhost>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdbstore/test-store</environment-path>
- </store>
- </test>
- </virtualhost>
-
- </virtualhosts>
- <heartbeat>
- <delay>0</delay>
- <timeoutFactor>2.0</timeoutFactor>
- </heartbeat>
- <queue>
- <auto_register>true</auto_register>
- </queue>
-
- <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
-</broker>
-
-
diff --git a/qpid/java/broker/etc/transient_config.xml b/qpid/java/broker/etc/transient_config.xml
deleted file mode 100644
index a21afe7d21..0000000000
--- a/qpid/java/broker/etc/transient_config.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- -
- - 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.
- -
-
- This is an example config file that uses the MemoryMessageStore.
- As a result it is aimed at brokers sending transient messages.
-
- -->
-<broker>
- <prefix>${QPID_HOME}</prefix>
- <work>${QPID_WORK}</work>
- <conf>${prefix}/etc</conf>
- <connector>
- <transport>nio</transport>
- <port>5672</port>
- <sslport>8672</sslport>
- <socketReceiveBuffer>32768</socketReceiveBuffer>
- <socketSendBuffer>32768</socketSendBuffer>
- </connector>
- <management>
- <enabled>true</enabled>
- <jmxport>8999</jmxport>
- <ssl>
- <enabled>true</enabled>
- <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore -->
- <keyStorePath>${prefix}/../test_resources/ssl/keystore.jks</keyStorePath>
- <keyStorePassword>password</keyStorePassword>
- </ssl>
- </management>
- <advanced>
- <filterchain enableExecutorPool="true"/>
- <enablePooledAllocator>false</enablePooledAllocator>
- <enableDirectBuffers>false</enableDirectBuffers>
- <framesize>65535</framesize>
- <compressBufferOnQueue>false</compressBufferOnQueue>
- </advanced>
-
- <security>
- <principal-databases>
- <principal-database>
- <name>passwordfile</name>
- <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
- <attributes>
- <attribute>
- <name>passwordFile</name>
- <value>${conf}/passwd</value>
- </attribute>
- </attributes>
- </principal-database>
- </principal-databases>
-
- <access>
- <class>org.apache.qpid.server.security.access.plugins.AllowAll</class>
- </access>
- <jmx>
- <access>${conf}/jmxremote.access</access>
- <principal-database>passwordfile</principal-database>
- </jmx>
- </security>
-
- <virtualhosts>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </localhost>
- </virtualhost>
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </development>
- </virtualhost>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </test>
- </virtualhost>
-
- </virtualhosts>
- <heartbeat>
- <delay>0</delay>
- <timeoutFactor>2.0</timeoutFactor>
- </heartbeat>
- <queue>
- <auto_register>true</auto_register>
- </queue>
-
- <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
-</broker>
-
-
diff --git a/qpid/java/broker/etc/virtualhosts.xml b/qpid/java/broker/etc/virtualhosts.xml
new file mode 100644
index 0000000000..4bc6956e5a
--- /dev/null
+++ b/qpid/java/broker/etc/virtualhosts.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <default>test</default>
+ <virtualhost>
+ <name>localhost</name>
+ <localhost>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+
+ <housekeeping>
+ <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
+ </housekeeping>
+
+ <exchanges>
+ <exchange>
+ <type>direct</type>
+ <name>test.direct</name>
+ <durable>true</durable>
+ </exchange>
+ <exchange>
+ <type>topic</type>
+ <name>test.topic</name>
+ </exchange>
+ </exchanges>
+ <queues>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ <maximumMessageCount>50</maximumMessageCount>
+ <!-- 50 messages -->
+
+ <queue>
+ <name>queue</name>
+ </queue>
+ <queue>
+ <name>ping</name>
+ </queue>
+ <queue>
+ <name>test-queue</name>
+ <test-queue>
+ <exchange>test.direct</exchange>
+ <durable>true</durable>
+ </test-queue>
+ </queue>
+ <queue>
+ <name>test-ping</name>
+ <test-ping>
+ <exchange>test.direct</exchange>
+ </test-ping>
+ </queue>
+
+ </queues>
+ </localhost>
+ </virtualhost>
+
+
+ <virtualhost>
+ <name>development</name>
+ <development>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+
+ <queues>
+ <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
+ <maximumMessageCount>50</maximumMessageCount>
+ <queue>
+ <name>queue</name>
+ <queue>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </queue>
+ </queue>
+ <queue>
+ <name>ping</name>
+ <ping>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </ping>
+ </queue>
+ </queues>
+ </development>
+ </virtualhost>
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+
+ <queues>
+ <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
+ <maximumMessageCount>50</maximumMessageCount>
+ <queue>
+ <name>queue</name>
+ <queue>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </queue>
+ </queue>
+ <queue>
+ <name>ping</name>
+ <ping>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </ping>
+ </queue>
+ </queues>
+ </test>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
index 879eb7c9e6..edf88f9b5a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
@@ -21,18 +21,19 @@
package org.apache.qpid.server.configuration;
import java.io.File;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Locale;
-import java.util.Collections;
+import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.ConfigurationFactory;
+import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
@@ -52,18 +53,17 @@ public class ServerConfiguration implements SignalHandler
private Configuration _config;
// Default Configuration values
- //todo make these all public, to make validation of configuration easier.
public static final int DEFAULT_BUFFER_READ_LIMIT_SIZE = 262144;
public static final int DEFAULT_BUFFER_WRITE_LIMIT_SIZE = 262144;
public static final boolean DEFAULT_BROKER_CONNECTOR_PROTECTIO_ENABLED = false;
public static final String DEFAULT_STATUS_UPDATES = "on";
public static final String SECURITY_CONFIG_RELOADED = "SECURITY CONFIGURATION RELOADED";
- private static final int DEFAULT_FRAME_SIZE = 65536;
- private static final int DEFAULT_PORT = 5672;
- private static final int DEFAUL_SSL_PORT = 8672;
- private static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
- private static final int DEFAULT_JMXPORT = 8999;
+ public static final int DEFAULT_FRAME_SIZE = 65536;
+ public static final int DEFAULT_PORT = 5672;
+ public static final int DEFAULT_SSL_PORT = 8672;
+ public static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
+ public static final int DEFAULT_JMXPORT = 8999;
private static int _jmxPort = DEFAULT_JMXPORT;
@@ -71,6 +71,7 @@ public class ServerConfiguration implements SignalHandler
private SecurityConfiguration _securityConfiguration = null;
private File _configFile;
+ private File _vhostsFile;
private Logger _log = LoggerFactory.getLogger(this.getClass());
@@ -134,8 +135,6 @@ public class ServerConfiguration implements SignalHandler
{
setConfig(conf);
- substituteEnvironmentVariables();
-
_jmxPort = getConfig().getInt("management.jmxport", 8999);
_securityConfiguration = new SecurityConfiguration(conf.subset("security"));
@@ -143,61 +142,86 @@ public class ServerConfiguration implements SignalHandler
}
- private void setupVirtualHosts(Configuration conf) throws ConfigurationException
+ /*
+ * Modified to enforce virtualhosts configuration in external file or main file, but not
+ * both, as a fix for QPID-2360 and QPID-2361.
+ */
+ @SuppressWarnings("unchecked")
+ private void setupVirtualHosts(Configuration conf) throws ConfigurationException
{
- List vhosts = conf.getList("virtualhosts");
- Iterator i = vhosts.iterator();
- while (i.hasNext())
+ List<String> vhostFiles = conf.getList("virtualhosts");
+ Configuration vhostConfig = conf.subset("virtualhosts");
+
+ // Only one configuration mechanism allowed
+ if (!vhostFiles.isEmpty() && !vhostConfig.subset("virtualhost").isEmpty())
{
- Object thing = i.next();
- if (thing instanceof String)
- {
- //Open the Virtualhost.xml file and copy values in to main config
- XMLConfiguration vhostConfiguration = new XMLConfiguration((String) thing);
- Iterator keys = vhostConfiguration.getKeys();
- while (keys.hasNext())
- {
- String key = (String) keys.next();
- conf.setProperty("virtualhosts." + key, vhostConfiguration.getProperty(key));
- }
- }
+ throw new ConfigurationException("Only one of external or embedded virtualhosts configuration allowed.");
+ }
+
+ // We can only have one vhosts XML file included
+ if (vhostFiles.size() > 1)
+ {
+ throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
+ }
+
+ // Virtualhost configuration object
+ Configuration vhostConfiguration = new HierarchicalConfiguration();
+
+ // Load from embedded configuration if possible
+ if (!vhostConfig.subset("virtualhost").isEmpty())
+ {
+ vhostConfiguration = vhostConfig;
}
-
- List hosts = conf.getList("virtualhosts.virtualhost.name");
+ else
+ {
+ // Load from the external configuration if possible
+ for (String fileName : vhostFiles)
+ {
+ // Open the vhosts XML file and copy values from it to our config
+ _vhostsFile = new File(fileName);
+ vhostConfiguration = parseConfig(new File(fileName));
+ }
+ }
+
+ // Now extract the virtual host names from the configuration object
+ List hosts = vhostConfiguration.getList("virtualhost.name");
for (int j = 0; j < hosts.size(); j++)
{
String name = (String) hosts.get(j);
- // Add the keys of the virtual host to the main config then bail out
-
- VirtualHostConfiguration vhostConfig = new VirtualHostConfiguration(name, conf.subset("virtualhosts.virtualhost." + name));
- _virtualHosts.put(vhostConfig.getName(), vhostConfig);
+
+ // Add the virtual hosts to the server configuration
+ VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name, vhostConfiguration.subset("virtualhost." + name));
+ _virtualHosts.put(virtualhost.getName(), virtualhost);
}
-
}
- private void substituteEnvironmentVariables()
+ private static void substituteEnvironmentVariables(Configuration conf)
{
for (Entry<String, String> var : envVarMap.entrySet())
{
String val = System.getenv(var.getKey());
if (val != null)
{
- getConfig().setProperty(var.getValue(), val);
+ conf.setProperty(var.getValue(), val);
}
}
}
- private final static Configuration parseConfig(File file) throws ConfigurationException
+ private static Configuration parseConfig(File file) throws ConfigurationException
{
ConfigurationFactory factory = new ConfigurationFactory();
factory.setConfigurationFileName(file.getAbsolutePath());
Configuration conf = factory.getConfiguration();
- Iterator keys = conf.getKeys();
+
+ Iterator<?> keys = conf.getKeys();
if (!keys.hasNext())
{
keys = null;
conf = flatConfig(file);
}
+
+ substituteEnvironmentVariables(conf);
+
return conf;
}
@@ -311,13 +335,25 @@ public class ServerConfiguration implements SignalHandler
if (_configFile != null)
{
Configuration newConfig = parseConfig(_configFile);
+
_securityConfiguration = new SecurityConfiguration(newConfig.subset("security"));
-
+
+ // Reload virtualhosts from correct location
+ Configuration newVhosts;
+ if (_vhostsFile == null)
+ {
+ newVhosts = newConfig.subset("virtualhosts");
+ }
+ else
+ {
+ newVhosts = parseConfig(_vhostsFile);
+ }
+
VirtualHostRegistry vhostRegistry = ApplicationRegistry.getInstance().getVirtualHostRegistry();
for (String hostname : _virtualHosts.keySet())
{
VirtualHost vhost = vhostRegistry.getVirtualHost(hostname);
- SecurityConfiguration hostSecurityConfig = new SecurityConfiguration(newConfig.subset("virtualhosts.virtualhost."+hostname+".security"));
+ SecurityConfiguration hostSecurityConfig = new SecurityConfiguration(newVhosts.subset("virtualhost."+hostname+".security"));
vhost.getAccessManager().configureGlobalPlugins(_securityConfiguration);
vhost.getAccessManager().configureHostPlugins(hostSecurityConfig);
}
@@ -601,7 +637,7 @@ public class ServerConfiguration implements SignalHandler
public int getSSLPort()
{
- return getConfig().getInt("connector.ssl.port", DEFAUL_SSL_PORT);
+ return getConfig().getInt("connector.ssl.port", DEFAULT_SSL_PORT);
}
public String getKeystorePath()
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
index e478f0f1f3..934367890d 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
@@ -20,11 +20,20 @@
*/
package org.apache.qpid.server.configuration;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.List;
+import java.util.Locale;
+
import junit.framework.TestCase;
-import org.apache.commons.configuration.Configuration;
+
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
-
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.exchange.ExchangeType;
import org.apache.qpid.server.protocol.AMQProtocolEngine;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -33,24 +42,15 @@ import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.transport.TestNetworkDriver;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-
public class ServerConfigurationTest extends TestCase
{
-
private XMLConfiguration _config;
@Override
public void setUp()
{
//Highlight that this test will cause a new AR to be created
-// ApplicationRegistry.getInstance();
+ ApplicationRegistry.getInstance();
_config = new XMLConfiguration();
}
@@ -59,7 +59,7 @@ public class ServerConfigurationTest extends TestCase
public void tearDown() throws Exception
{
//Correctly Close the AR we created
-// ApplicationRegistry.remove();
+ ApplicationRegistry.remove();
}
public void testSetJMXManagementPort() throws ConfigurationException
@@ -756,10 +756,9 @@ public class ServerConfigurationTest extends TestCase
public void testFirewallConfiguration() throws Exception
{
- // Write out config
+ // Write out config
File mainFile = File.createTempFile(getClass().getName(), null);
mainFile.deleteOnExit();
- FileWriter out;
writeConfigFile(mainFile, false);
// Load config
@@ -903,6 +902,10 @@ public class ServerConfigurationTest extends TestCase
}
private void writeConfigFile(File mainFile, boolean allow) throws IOException {
+ writeConfigFile(mainFile, allow, true, null, "test");
+ }
+
+ private void writeConfigFile(File mainFile, boolean allow, boolean includeVhosts, File vhostsFile, String name) throws IOException {
FileWriter out = new FileWriter(mainFile);
out.write("<broker>\n");
out.write("\t<management><enabled>false</enabled></management>\n");
@@ -927,15 +930,101 @@ public class ServerConfigurationTest extends TestCase
out.write("\t\t\t<rule access=\""+ ((allow) ? "allow" : "deny") +"\" network=\"127.0.0.1\"/>");
out.write("\t\t</firewall>\n");
out.write("\t</security>\n");
+ if (includeVhosts)
+ {
+ out.write("\t<virtualhosts>\n");
+ out.write("\t\t<virtualhost>\n");
+ out.write(String.format("\t\t\t<name>%s</name>\n", name));
+ out.write(String.format("\t\t<%s> \n", name));
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write(String.format("\t\t\t\t\t<name>%s.topic</name>\n", name));
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write(String.format("\t\t</%s> \n", name));
+ out.write("\t\t</virtualhost>\n");
+ out.write("\t</virtualhosts>\n");
+ }
+ if (vhostsFile != null)
+ {
+ out.write("\t<virtualhosts>"+vhostsFile.getAbsolutePath()+"</virtualhosts>\n");
+ }
+ out.write("</broker>\n");
+ out.close();
+ }
+
+ private void writeTestFishConfigFile(File mainFile) throws IOException {
+ FileWriter out = new FileWriter(mainFile);
+ out.write("<broker>\n");
+ out.write("\t<management><enabled>false</enabled></management>\n");
+ out.write("\t<security>\n");
+ out.write("\t\t<principal-databases>\n");
+ out.write("\t\t\t<principal-database>\n");
+ out.write("\t\t\t\t<name>passwordfile</name>\n");
+ out.write("\t\t\t\t<class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>\n");
+ out.write("\t\t\t\t<attributes>\n");
+ out.write("\t\t\t\t\t<attribute>\n");
+ out.write("\t\t\t\t\t\t<name>passwordFile</name>\n");
+ out.write("\t\t\t\t\t\t<value>/dev/null</value>\n");
+ out.write("\t\t\t\t\t</attribute>\n");
+ out.write("\t\t\t\t</attributes>\n");
+ out.write("\t\t\t</principal-database>\n");
+ out.write("\t\t</principal-databases>\n");
+ out.write("\t\t<jmx>\n");
+ out.write("\t\t\t<access>/dev/null</access>\n");
+ out.write("\t\t\t<principal-database>passwordfile</principal-database>\n");
+ out.write("\t\t</jmx>\n");
+ out.write("\t\t<firewall>\n");
+ out.write("\t\t\t<rule access=\"allow\" network=\"127.0.0.1\"/>");
+ out.write("\t\t</firewall>\n");
+ out.write("\t</security>\n");
out.write("\t<virtualhosts>\n");
out.write("\t\t<virtualhost>\n");
out.write("\t\t\t<name>test</name>\n");
+ out.write("\t\t<test> \n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>test.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</test> \n");
+ out.write("\t\t</virtualhost>\n");
+ out.write("\t\t<virtualhost>\n");
+ out.write("\t\t\t<name>fish</name>\n");
+ out.write("\t\t<fish> \n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>fish.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>false</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</fish> \n");
out.write("\t\t</virtualhost>\n");
out.write("\t</virtualhosts>\n");
out.write("</broker>\n");
out.close();
}
+ private void writeFirewallVhostsFile(File vhostsFile, boolean allow) throws IOException
+ {
+ FileWriter out = new FileWriter(vhostsFile);
+ String ipAddr = "127.0.0.1"; // FIXME: get this from InetAddress.getLocalHost().getAddress() ?
+ out.write("<virtualhosts><virtualhost>");
+ out.write("<name>test</name>");
+ out.write("<test>");
+ out.write("<security><firewall>");
+ out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\""+ipAddr +"\"/>");
+ out.write("</firewall></security>");
+ out.write("</test>");
+ out.write("</virtualhost></virtualhosts>");
+ out.close();
+ }
+
public void testCombinedConfigurationFirewallReload() throws Exception
{
// Write out config
@@ -1041,42 +1130,538 @@ public class ServerConfigurationTest extends TestCase
}
}
- public void testnewParserOutputVsOldParserOutput() throws ConfigurationException
- {
- String configDir = System.getProperty("QPID_HOME")+"/etc";
+ private void writeVirtualHostsFile(File vhostsFile, String name) throws IOException {
+ FileWriter out = new FileWriter(vhostsFile);
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write(String.format("\t\t<name>%s</name>\n", name));
+ out.write(String.format("\t\t<%s>\n", name));
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>test.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write(String.format("\t\t</%s>\n", name));
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.close();
+ }
- XMLConfiguration oldConfig = new XMLConfiguration(configDir +"/config-systests-ServerConfigurationTest-Old.xml");
- Configuration newConfig = new ServerConfiguration(new File(configDir+"/config-systests-ServerConfigurationTest-New.xml")).getConfig();
+ private void writeMultiVirtualHostsFile(File vhostsFile) throws IOException {
+ FileWriter out = new FileWriter(vhostsFile);
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<name>topic</name>\n");
+ out.write("\t\t<topic>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>test.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</topic>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<name>fanout</name>\n");
+ out.write("\t\t<fanout>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>fanout</type>\n");
+ out.write("\t\t\t\t\t<name>test.fanout</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</fanout>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.close();
+ }
- Iterator xmlKeys = oldConfig.getKeys();
- while (xmlKeys.hasNext())
+ private void writeMultipleVhostsConfigFile(File mainFile, File[] vhostsFileArray) throws IOException {
+ FileWriter out = new FileWriter(mainFile);
+ out.write("<broker>\n");
+ out.write("\t<management><enabled>false</enabled></management>\n");
+ out.write("\t<security>\n");
+ out.write("\t\t<principal-databases>\n");
+ out.write("\t\t\t<principal-database>\n");
+ out.write("\t\t\t\t<name>passwordfile</name>\n");
+ out.write("\t\t\t\t<class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>\n");
+ out.write("\t\t\t\t<attributes>\n");
+ out.write("\t\t\t\t\t<attribute>\n");
+ out.write("\t\t\t\t\t\t<name>passwordFile</name>\n");
+ out.write("\t\t\t\t\t\t<value>/dev/null</value>\n");
+ out.write("\t\t\t\t\t</attribute>\n");
+ out.write("\t\t\t\t</attributes>\n");
+ out.write("\t\t\t</principal-database>\n");
+ out.write("\t\t</principal-databases>\n");
+ out.write("\t\t<jmx>\n");
+ out.write("\t\t\t<access>/dev/null</access>\n");
+ out.write("\t\t\t<principal-database>passwordfile</principal-database>\n");
+ out.write("\t\t</jmx>\n");
+ out.write("\t\t<firewall>\n");
+ out.write("\t\t\t<rule access=\"allow\" network=\"127.0.0.1\"/>");
+ out.write("\t\t</firewall>\n");
+ out.write("\t</security>\n");
+ for (File vhostsFile : vhostsFileArray)
{
- String key = (String) xmlKeys.next();
- assertEquals("Incorrect value for "+key, oldConfig.getProperty(key), newConfig.getProperty(key));
+ out.write("\t<virtualhosts>"+vhostsFile.getAbsolutePath()+"</virtualhosts>\n");
}
+ out.write("</broker>\n");
+ out.close();
}
+ private void writeCombinedConfigFile(File mainFile, File fileA, File fileB) throws Exception
+ {
+ FileWriter out = new FileWriter(mainFile);
+ out.write("<configuration><system/>");
+ out.write("<xml fileName=\"" + fileA.getAbsolutePath() + "\"/>");
+ out.write("<xml fileName=\"" + fileB.getAbsolutePath() + "\"/>");
+ out.write("</configuration>");
+ out.close();
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in the main
+ * configuration file only.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testInternalVirtualhostConfigFile() throws Exception
+ {
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeConfigFile(mainFile, false, true, null, "test");
- public void testNoVirtualhostXMLFile() throws Exception
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
+
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
+ Exchange exchange = virtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
+
+ assertEquals("Incorrect virtualhost count", 1, virtualHostRegistry.getVirtualHosts().size());
+ assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
+ assertEquals("Incorrect exchange type", "topic", exchange.getType().getName().toString());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file only.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testExternalVirtualhostXMLFile() throws Exception
{
- int REGISTRY=1;
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeConfigFile(mainFile, false, false, vhostsFile, null);
+ writeVirtualHostsFile(vhostsFile, "test");
+
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
- File configFile = new File(System.getProperty("QPID_HOME")+"/etc/config.xml");
- assertTrue(configFile.exists());
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
+ Exchange exchange = virtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
+ assertEquals("Incorrect virtualhost count", 1, virtualHostRegistry.getVirtualHosts().size());
+ assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
+ assertEquals("Incorrect exchange type", "topic", exchange.getType().getName().toString());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file only, with two vhosts that have different properties.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testExternalMultiVirtualhostXMLFile() throws Exception
+ {
+ // Write out vhosts
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts-multi");
+ vhostsFile.deleteOnExit();
+ writeMultiVirtualHostsFile(vhostsFile);
+
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeConfigFile(mainFile, false, false, vhostsFile, null);
+
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
+
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+
+ assertEquals("Incorrect virtualhost count", 2, virtualHostRegistry.getVirtualHosts().size());
+
+ // test topic host
+ VirtualHost topicVirtualHost = virtualHostRegistry.getVirtualHost("topic");
+ Exchange topicExchange = topicVirtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
+
+ assertEquals("Incorrect topic virtualhost name", "topic", topicVirtualHost.getName());
+ assertEquals("Incorrect topic exchange type", "topic", topicExchange.getType().getName().toString());
+
+ // Test fanout host
+ VirtualHost fanoutVirtualHost = virtualHostRegistry.getVirtualHost("fanout");
+ Exchange fanoutExchange = fanoutVirtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.fanout"));
+
+ assertEquals("Incorrect fanout virtualhost name", "fanout", fanoutVirtualHost.getName());
+ assertEquals("Incorrect fanout exchange type", "fanout", fanoutExchange.getType().getName().toString());
+ }
+
+ /**
+ * Test that configuration does not load when virtual hosts are specified in both the main
+ * configuration file and an external file. Should throw a {@link ConfigurationException}.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testInternalAndExternalVirtualhostXMLFile() throws Exception
+ {
+ // Write out vhosts
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeVirtualHostsFile(vhostsFile, "test");
+
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeConfigFile(mainFile, false, true, vhostsFile, "test");
+
+ // Load config
try
{
- ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(configFile), REGISTRY);
-
- VirtualHostRegistry virtualHostRegistry = ApplicationRegistry.getInstance(REGISTRY).getVirtualHostRegistry();
+ @SuppressWarnings("unused")
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ fail("Different virtualhost XML configurations not allowed");
+ }
+ catch (ConfigurationException ce)
+ {
+ assertEquals("Incorrect error message", "Only one of external or embedded virtualhosts configuration allowed.", ce.getMessage());
+ }
+ }
+
+ /**
+ * Test that configuration does not load when virtual hosts are specified in multiple external
+ * files. Should throw a {@link ConfigurationException}.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testMultipleInternalVirtualhostXMLFile() throws Exception
+ {
+ // Write out vhosts
+ File vhostsFileOne = File.createTempFile(getClass().getName(), "vhosts-one");
+ vhostsFileOne.deleteOnExit();
+ writeVirtualHostsFile(vhostsFileOne, "one");
+ File vhostsFileTwo = File.createTempFile(getClass().getName(), "vhosts-two");
+ vhostsFileTwo.deleteOnExit();
+ writeVirtualHostsFile(vhostsFileTwo, "two");
+
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeMultipleVhostsConfigFile(mainFile, new File[] { vhostsFileOne, vhostsFileTwo });
+
+ // Load config
+ try
+ {
+ @SuppressWarnings("unused")
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ fail("Multiple virtualhost XML configurations not allowed");
+ }
+ catch (ConfigurationException ce)
+ {
+ assertEquals("Incorrect error message",
+ "Only one external virtualhosts configuration file allowed, multiple filenames found.",
+ ce.getMessage());
+ }
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file in the first of two configurations and embedded in the second. This
+ * will throe a {@link ConfigurationException} since the configurations have different
+ * types.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedDifferentVirtualhostConfig() throws Exception
+ {
+ // Write out vhosts config
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeVirtualHostsFile(vhostsFile, "external");
+
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "a");
+ File fileB = File.createTempFile(getClass().getName(), "b");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeConfigFile(fileA, false, false, vhostsFile, null);
+ writeConfigFile(fileB, false);
- assertEquals("Incorrect virtualhost count", 3 , virtualHostRegistry.getVirtualHosts().size());
+ // Load config
+ try
+ {
+ @SuppressWarnings("unused")
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+ fail("Different virtualhost XML configurations not allowed");
}
- finally
+ catch (ConfigurationException ce)
{
- ApplicationRegistry.remove(REGISTRY);
+ assertEquals("Incorrect error message", "Only one of external or embedded virtualhosts configuration allowed.", ce.getMessage());
}
}
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified two overriding configurations
+ * each with an embedded virtualhost section. The first configuration section should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedConfigEmbeddedVirtualhost() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "a");
+ File fileB = File.createTempFile(getClass().getName(), "b");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeConfigFile(fileA, false, true, null, "a");
+ writeConfigFile(fileB, false, true, null, "b");
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration virtualHost = config.getVirtualHostConfig("a");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "a", virtualHost.getName());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified two overriding configurations
+ * each with an external virtualhost XML file. The first configuration file should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedConfigExternalVirtualhost() throws Exception
+ {
+ // Write out vhosts config
+ File vhostsOne = File.createTempFile(getClass().getName(), "vhosts-one");
+ vhostsOne.deleteOnExit();
+ writeVirtualHostsFile(vhostsOne, "one");
+ File vhostsTwo = File.createTempFile(getClass().getName(), "vhosts-two");
+ vhostsTwo.deleteOnExit();
+ writeVirtualHostsFile(vhostsTwo, "two");
+
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "a");
+ File fileB = File.createTempFile(getClass().getName(), "b");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeConfigFile(fileA, false, false, vhostsOne, null);
+ writeConfigFile(fileB, false, false, vhostsTwo, null);
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration virtualHost = config.getVirtualHostConfig("one");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "one", virtualHost.getName());
+ }
+
+ /**
+ * Test that configuration loads correctly when an overriding virtualhost configuration resets
+ * a property of an embedded virtualhost section. The overriding configuration property value
+ * should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedConfigEmbeddedVirtualhostOverride() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "override");
+ File fileB = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeTestFishConfigFile(fileB);
+
+ // Write out overriding virtualhosts section
+ FileWriter out = new FileWriter(fileA);
+ out.write("<broker>\n");
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<test>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<durable>false</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</test>\n");
+ out.write("\t\t<fish>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</fish>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.write("</broker>\n");
+ out.close();
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration testHost = config.getVirtualHostConfig("test");
+ ExchangeConfiguration testExchange = testHost.getExchangeConfiguration("test.topic");
+ VirtualHostConfiguration fishHost = config.getVirtualHostConfig("fish");
+ ExchangeConfiguration fishExchange = fishHost.getExchangeConfiguration("fish.topic");
+
+ assertEquals("Incorrect virtualhost count", 2, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "test", testHost.getName());
+ assertFalse("Incorrect exchange durable property", testExchange.getDurable());
+ assertEquals("Incorrect virtualhost name", "fish", fishHost.getName());
+ assertTrue("Incorrect exchange durable property", fishExchange.getDurable());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file only.
+ * <p>
+ * Test for QPID-2360
+ */
+ public void testExternalFirewallVirtualhostXMLFile() throws Exception
+ {
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeConfigFile(mainFile, false, false, vhostsFile, null);
+ writeFirewallVhostsFile(vhostsFile, false);
+
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
+
+ assertEquals("Incorrect virtualhost count", 1, virtualHostRegistry.getVirtualHosts().size());
+ assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
+ }
+
+ /**
+ * Test that configuration loads correctly when the virtualhost configuration is a set of overriding
+ * configuration files that resets a property of a virtualhost. The opmost overriding configuration
+ * property value should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedVirtualhostOverride() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ File fileA = File.createTempFile(getClass().getName(), "vhosts-override");
+ File fileB = File.createTempFile(getClass().getName(), "vhosts-base");
+ mainFile.deleteOnExit();
+ vhostsFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeConfigFile(mainFile, true, false, vhostsFile, null);
+ writeCombinedConfigFile(vhostsFile, fileA, fileB);
+
+ // Write out overriding virtualhosts sections
+ FileWriter out = new FileWriter(fileA);
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<test>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<durable>false</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</test>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.close();
+ writeVirtualHostsFile(fileB, "test");
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration testHost = config.getVirtualHostConfig("test");
+ ExchangeConfiguration testExchange = testHost.getExchangeConfiguration("test.topic");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "test", testHost.getName());
+ assertFalse("Incorrect exchange durable property", testExchange.getDurable());
+ }
+
+ /**
+ * Test that configuration loads correctly when the virtualhost configuration is a set of overriding
+ * configuration files that define multiple virtualhosts, one per file. Only the virtualhosts defined in
+ * the topmost file should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedMultipleVirtualhosts() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ File fileA = File.createTempFile(getClass().getName(), "vhosts-one");
+ File fileB = File.createTempFile(getClass().getName(), "vhosts-two");
+ mainFile.deleteOnExit();
+ vhostsFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeConfigFile(mainFile, true, false, vhostsFile, null);
+ writeCombinedConfigFile(vhostsFile, fileA, fileB);
+
+ // Write both virtualhosts definitions
+ writeVirtualHostsFile(fileA, "test-one");
+ writeVirtualHostsFile(fileB, "test-two");
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration oneHost = config.getVirtualHostConfig("test-one");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "test-one", oneHost.getName());
+ }
}
diff --git a/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
index 33cc90b895..7deb80bcd9 100644
--- a/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
+++ b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
@@ -18,9 +18,6 @@
- specific language governing permissions and limitations
- under the License.
-
-
- This is an example config using the BDBMessageStore available from
- the Red Hat Messaging project at etp.108.redhat.com and distributed under GPL.
-->
<broker>
@@ -68,17 +65,8 @@
</jmx>
</security>
- <virtualhosts>
- <virtualhost>
- <name>dev-only</name>
- <dev-only>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- <environment-path>${work}/bdbstore/dev-only-store</environment-path>
- </store>
- </dev-only>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts-ServerConfigurationTest-New.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
@@ -86,8 +74,6 @@
<queue>
<auto_register>true</auto_register>
</queue>
-
- <virtualhosts>${conf}/virtualhosts-ServerConfigurationTest-New.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-acl-settings.xml b/qpid/java/systests/etc/config-systests-acl-settings.xml
index d7c1ef70df..eebc75f05f 100644
--- a/qpid/java/systests/etc/config-systests-acl-settings.xml
+++ b/qpid/java/systests/etc/config-systests-acl-settings.xml
@@ -20,141 +20,7 @@
-
-->
<broker>
-
- <virtualhosts>
-
- <virtualhost>
- <name>test</name>
- <test>
- <queues>
- <exchange>amq.direct</exchange>
- <!-- 4Mb -->
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 2Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 10 mins -->
- <maximumMessageAge>600000</maximumMessageAge>
- </queues>
-
-
- <security>
- <access>
- <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
- </access>
- <access_control_list>
- <!-- This section grants pubish rights to an exchange + routing key pair -->
- <publish>
- <exchanges>
- <exchange>
- <name>amq.direct</name>
- <routing_keys>
-
- <!-- Allow clients to publish requests -->
- <routing_key>
- <value>example.RequestQueue</value>
- <users>
- <user>client</user>
- </users>
- </routing_key>
-
- <!-- Allow the processor to respond to a client on their Temporary Topic -->
- <routing_key>
- <value>tmp_*</value>
- <users>
- <user>server</user>
- </users>
- </routing_key>
- <routing_key>
- <value>TempQueue*</value>
- <users>
- <user>server</user>
- </users>
- </routing_key>
- </routing_keys>
-
- </exchange>
- </exchanges>
- </publish>
-
- <!-- This section grants users the ability to consume from the broker -->
- <consume>
- <queues>
- <temporary>
- <users>
- <user>client</user>
- </users>
- </temporary>
-
- <!-- Only allow the server to consume from the Request Queue-->
- <queue>
- <name>example.RequestQueue</name>
- <users>
- <user>server</user>
- </users>
- </queue>
-
-
- </queues>
- </consume>
-
- <!-- This section grants users the ability to create queues and exchanges -->
- <create>
- <queues>
- <temporary>
- <users>
- <user>client</user>
- </users>
- </temporary>
-
- <!-- Allow clients to create queue on this exchange-->
- <queue>
- <exchanges>
- <exchange>
- <name>amq.direct</name>
- <users>
- <user>client</user>
- </users>
- </exchange>
- </exchanges>
- </queue>
- <!-- Allow the server to create the Request Queue-->
- <queue>
- <name>example.RequestQueue</name>
- <users>
- <user>server</user>
- </users>
- </queue>
-
- </queues>
- </create>
-
-
- </access_control_list>
-
- </security>
- </test>
- </virtualhost>
-
- <virtualhost>
- <name>test2</name>
- <test2>
- <security>
- <access>
- <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
- </access>
-
- <access_control_list>
- <!-- This section grants specific users full permissions to all artifacts in this virtualhost -->
- <access>
- <users>
- <user>guest</user>
- </users>
- </access>
- </access_control_list>
- </security>
- </test2>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests-acl.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-acl.xml b/qpid/java/systests/etc/config-systests-acl.xml
index 34104dbe6b..535108235e 100644
--- a/qpid/java/systests/etc/config-systests-acl.xml
+++ b/qpid/java/systests/etc/config-systests-acl.xml
@@ -22,7 +22,7 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
+ <xml fileName="${test.config}" optional="true"/>
<xml fileName="${QPID_HOME}/etc/config-systests-acl-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
diff --git a/qpid/java/systests/etc/config-systests-derby-settings.xml b/qpid/java/systests/etc/config-systests-derby-settings.xml
index 9c25b5682e..3ed3a9e33b 100644
--- a/qpid/java/systests/etc/config-systests-derby-settings.xml
+++ b/qpid/java/systests/etc/config-systests-derby-settings.xml
@@ -20,45 +20,7 @@
-
-->
<broker>
- <virtualhosts>
- <directory>${conf}/virtualhosts</directory>
-
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${work}/derbyDB/localhost-store</environment-path>
- </store>
-
- <housekeeping>
- <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
- </housekeeping>
-
- </localhost>
- </virtualhost>
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${work}/derbyDB/development-store</environment-path>
- </store>
- </development>
- </virtualhost>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${work}/derbyDB/test-store</environment-path>
- </store>
- </test>
- </virtualhost>
-
- </virtualhosts>
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests-derby.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-derby.xml b/qpid/java/systests/etc/config-systests-derby.xml
index 18ba0c4ad9..ba27a0c020 100644
--- a/qpid/java/systests/etc/config-systests-derby.xml
+++ b/qpid/java/systests/etc/config-systests-derby.xml
@@ -22,7 +22,7 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
+ <xml fileName="${test.config}" optional="true"/>
<xml fileName="${QPID_HOME}/etc/config-systests-derby-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
diff --git a/qpid/java/systests/etc/config-systests-firewall-2.xml b/qpid/java/systests/etc/config-systests-firewall-2.xml
index 1c560d751d..8380fab3d9 100644
--- a/qpid/java/systests/etc/config-systests-firewall-2.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-2.xml
@@ -96,32 +96,8 @@
</firewall>
</security>
- <virtualhosts>
- <default>test</default>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- <security>
- <firewall default-action="allow"/>
- </security>
- </test>
- </virtualhost>
-
- <virtualhost>
- <name>test2</name>
- <test2>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- </test2>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts-systests-firewall-2.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
diff --git a/qpid/java/systests/etc/config-systests-firewall-3.xml b/qpid/java/systests/etc/config-systests-firewall-3.xml
index 05c4df6069..2068581ca1 100644
--- a/qpid/java/systests/etc/config-systests-firewall-3.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-3.xml
@@ -96,32 +96,8 @@
</firewall>
</security>
- <virtualhosts>
- <default>test</default>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- </test>
- </virtualhost>
-
- <virtualhost>
- <name>test2</name>
- <test2>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- <security>
- <firewall default-action="deny"/>
- </security>
- </test2>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts-systests-firewall-3.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
diff --git a/qpid/java/systests/etc/config-systests-firewall-settings.xml b/qpid/java/systests/etc/config-systests-firewall-settings.xml
index d115e74663..aa73be0646 100644
--- a/qpid/java/systests/etc/config-systests-firewall-settings.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-settings.xml
@@ -25,4 +25,6 @@
<rule access="allow" network="127.0.0.1"/>
</firewall>
</security>
+
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests-firewall.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-firewall.xml b/qpid/java/systests/etc/config-systests-firewall.xml
index 90773f5cc2..c0ce71210f 100644
--- a/qpid/java/systests/etc/config-systests-firewall.xml
+++ b/qpid/java/systests/etc/config-systests-firewall.xml
@@ -22,8 +22,9 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
- <xml fileName="${QPID_FIREWALL_SETTINGS}"/>
+ <xml fileName="${test.config}" optional="true"/>
+ <xml fileName="${QPID_FIREWALL_CONFIG_SETTINGS}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/config-systests-firewall-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
</override>
diff --git a/qpid/java/systests/etc/config-systests-settings.xml b/qpid/java/systests/etc/config-systests-settings.xml
index 4e9c863fda..a7f538aec1 100644
--- a/qpid/java/systests/etc/config-systests-settings.xml
+++ b/qpid/java/systests/etc/config-systests-settings.xml
@@ -26,4 +26,5 @@
<enabled>false</enabled>
</ssl>
</management>
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests.xml b/qpid/java/systests/etc/config-systests.xml
index 290c082a4f..5d7d878e76 100644
--- a/qpid/java/systests/etc/config-systests.xml
+++ b/qpid/java/systests/etc/config-systests.xml
@@ -22,7 +22,7 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
+ <xml fileName="${test.config}" optional="true"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
</override>
diff --git a/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml b/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
index 168aa074da..1b6845662b 100644
--- a/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
+++ b/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
@@ -26,7 +26,7 @@
<dev-only>
<queues>
<exchange>amq.direct</exchange>
- <!-- Small defaults for development -->
+ <!-- Small defaults for development -->
<maximumQueueDepth>102400</maximumQueueDepth> <!-- 100k -->
<maximumMessageSize>20480</maximumMessageSize> <!-- 20kb -->
<maximumMessageAge>60000</maximumMessageAge> <!-- 1 mins -->
@@ -35,6 +35,11 @@
<name>dev-queue</name>
</queue>
</queues>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ <environment-path>${QPID_WORK}/bdbstore/dev-only-store</environment-path>
+ </store>
</dev-only>
</virtualhost>
</virtualhosts>
+ \ No newline at end of file
diff --git a/qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml b/qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml
new file mode 100644
index 0000000000..50fda4e999
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <queues>
+ <exchange>amq.direct</exchange>
+ <!-- 4Mb -->
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 2Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 10 mins -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ </queues>
+
+
+ <security>
+ <access>
+ <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
+ </access>
+ <access_control_list>
+ <!-- This section grants pubish rights to an exchange + routing key pair -->
+ <publish>
+ <exchanges>
+ <exchange>
+ <name>amq.direct</name>
+ <routing_keys>
+
+ <!-- Allow clients to publish requests -->
+ <routing_key>
+ <value>example.RequestQueue</value>
+ <users>
+ <user>client</user>
+ </users>
+ </routing_key>
+
+ <!-- Allow the processor to respond to a client on their Temporary Topic -->
+ <routing_key>
+ <value>tmp_*</value>
+ <users>
+ <user>server</user>
+ </users>
+ </routing_key>
+ <routing_key>
+ <value>TempQueue*</value>
+ <users>
+ <user>server</user>
+ </users>
+ </routing_key>
+ </routing_keys>
+
+ </exchange>
+ </exchanges>
+ </publish>
+
+ <!-- This section grants users the ability to consume from the broker -->
+ <consume>
+ <queues>
+ <temporary>
+ <users>
+ <user>client</user>
+ </users>
+ </temporary>
+
+ <!-- Only allow the server to consume from the Request Queue-->
+ <queue>
+ <name>example.RequestQueue</name>
+ <users>
+ <user>server</user>
+ </users>
+ </queue>
+
+
+ </queues>
+ </consume>
+
+ <!-- This section grants users the ability to create queues and exchanges -->
+ <create>
+ <queues>
+ <temporary>
+ <users>
+ <user>client</user>
+ </users>
+ </temporary>
+
+ <!-- Allow clients to create queue on this exchange-->
+ <queue>
+ <exchanges>
+ <exchange>
+ <name>amq.direct</name>
+ <users>
+ <user>client</user>
+ </users>
+ </exchange>
+ </exchanges>
+ </queue>
+ <!-- Allow the server to create the Request Queue-->
+ <queue>
+ <name>example.RequestQueue</name>
+ <users>
+ <user>server</user>
+ </users>
+ </queue>
+
+ </queues>
+ </create>
+
+
+ </access_control_list>
+
+ </security>
+ </test>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test2</name>
+ <test2>
+ <security>
+ <access>
+ <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
+ </access>
+
+ <access_control_list>
+ <!-- This section grants specific users full permissions to all artifacts in this virtualhost -->
+ <access>
+ <users>
+ <user>guest</user>
+ </users>
+ </access>
+ </access_control_list>
+ </security>
+ </test2>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/systests/etc/virtualhosts-systests-acl.xml b/qpid/java/systests/etc/virtualhosts-systests-acl.xml
new file mode 100644
index 0000000000..4a56c39de0
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-acl.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts-systests-acl-settings.xml"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml b/qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml
new file mode 100644
index 0000000000..ed5ffbb1fd
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <directory>${QPID_HOME}/virtualhosts</directory>
+ <default>test</default>
+
+ <virtualhost>
+ <localhost>
+ <store>
+ <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${QPID_WORK}/derbyDB/localhost-store</environment-path>
+ </store>
+ </localhost>
+ </virtualhost>
+
+ <virtualhost>
+ <development>
+ <store>
+ <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${QPID_WORK}/derbyDB/development-store</environment-path>
+ </store>
+ </development>
+ </virtualhost>
+
+ <virtualhost>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${QPID_WORK}/derbyDB/test-store</environment-path>
+ </store>
+ </test>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/systests/etc/virtualhosts-systests-derby.xml b/qpid/java/systests/etc/virtualhosts-systests-derby.xml
new file mode 100644
index 0000000000..171be37416
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-derby.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts-systests-derby-settings.xml"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml b/qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml
new file mode 100644
index 0000000000..b85ab83676
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <default>test</default>
+
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ <security>
+ <firewall default-action="allow"/>
+ </security>
+ </test>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test2</name>
+ <test2>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ </test2>
+ </virtualhost>
+</virtualhosts> \ No newline at end of file
diff --git a/qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml b/qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml
new file mode 100644
index 0000000000..ebfc2bad20
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <default>test</default>
+
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ </test>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test2</name>
+ <test2>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ <security>
+ <firewall default-action="deny"/>
+ </security>
+ </test2>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/systests/etc/virtualhosts-systests-firewall.xml b/qpid/java/systests/etc/virtualhosts-systests-firewall.xml
new file mode 100644
index 0000000000..51ab6739b3
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-firewall.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_FIREWALL_VIRTUALHOSTS_SETTINGS}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/etc/virtualhosts-systests.xml b/qpid/java/systests/etc/virtualhosts-systests.xml
new file mode 100644
index 0000000000..71f1cc9889
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
index 0a88ef391c..4a2d626a5b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
@@ -42,6 +42,8 @@ public class ServerConfigurationFileTest extends QpidTestCase
}
saveTestConfiguration();
+ saveTestVirtualhosts();
+
_serverConfig = new ServerConfiguration(_configFile);
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
index 3429edd6bc..a4b47268e2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
@@ -20,19 +20,16 @@
*/
package org.apache.qpid.server.logging;
+import javax.jms.Connection;
+import javax.jms.Queue;
+import javax.jms.Session;
+
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.util.FileUtils;
-import org.apache.qpid.util.LogMonitor;
-
-import javax.jms.Connection;
-import javax.jms.Queue;
-import javax.jms.Session;
-import java.io.File;
public class AlertingTest extends AbstractTestLogging
{
@@ -49,6 +46,7 @@ public class AlertingTest extends AbstractTestLogging
{
// Update the configuration to make our virtualhost Persistent.
makeVirtualHostPersistent(VIRTUALHOST);
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.expiredMessageCheckPeriod", "5000");
_numMessages = 50;
@@ -114,7 +112,7 @@ public class AlertingTest extends AbstractTestLogging
message.append(FileUtils.readFileAsString(getTestConfigFile()));
message.append("\nVirtualhost maxMessageCount:\n");
- message.append((new ServerConfiguration(_configFile)).getConfig().getString("virtualhosts.virtualhost." + VIRTUALHOST + ".queues.maximumMessageCount"));
+ message.append(new ServerConfiguration(_configFile).getVirtualHostConfig(VIRTUALHOST).getMaximumMessageCount());
fail(message.toString());
}
@@ -185,7 +183,7 @@ public class AlertingTest extends AbstractTestLogging
setupConnection();
// Validate the queue depth is as expected
- long messageCount = ((AMQSession) _session).getQueueDepth((AMQDestination) _destination);
+ long messageCount = ((AMQSession<?, ?>) _session).getQueueDepth((AMQDestination) _destination);
assertEquals("Broker has invalid message count for test", 2, messageCount);
// Ensure the alert has not occured yet
@@ -198,5 +196,4 @@ public class AlertingTest extends AbstractTestLogging
// Validate that the alert occured.
wasAlertFired();
}
-
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
index 1bcef1dbb0..c3c2574519 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
@@ -20,13 +20,13 @@
*/
package org.apache.qpid.server.logging;
-import org.apache.commons.configuration.Configuration;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
import org.apache.qpid.util.LogMonitor;
-import java.util.List;
-
/**
* The MessageStore test suite validates that the follow log messages as
* specified in the Functional Specification.
@@ -90,7 +90,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
// Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
//Validate each vhost logs a creation
results = _monitor.waitAndFindMatches("MST-1001", DEFAULT_LOG_WAIT);
@@ -101,15 +101,12 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
{
String result = getLog(results.get(index));
- // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // getSlice will return extract the vhost from vh(/test) -> '/test'
// so remove the '/' to get the name
String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ // Get the store class used in the configuration for the virtualhost.
+ String fullStoreName = configuration.getVirtualHostConfig(vhostName).getMessageStoreClass();
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -157,7 +154,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
// Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
//Validate each vhost logs a creation
results = _monitor.waitAndFindMatches("MST-1003", DEFAULT_LOG_WAIT);
@@ -168,15 +165,12 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
{
String result = getLog(results.get(index));
- // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // getSlice will return extract the vhost from vh(/test) -> '/test'
// so remove the '/' to get the name
String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ // Get the store class used in the configuration for the virtualhost.
+ String fullStoreName = configuration.getVirtualHostConfig(vhostName).getMessageStoreClass();
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
index b97bd64a55..d4c3689365 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
@@ -21,11 +21,12 @@
package org.apache.qpid.server.logging;
+import java.util.Arrays;
+import java.util.List;
+
import junit.framework.AssertionFailedError;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import java.util.List;
+import org.apache.qpid.server.configuration.ServerConfiguration;
/**
* Virtualhost Test Cases
@@ -60,28 +61,26 @@ public class VirtualHostLoggingTest extends AbstractTestLogging
public void testVirtualhostCreation() throws Exception
{
//Wait for the correct VHT message to arrive.
- _monitor.waitForMessage("VHT-1001",DEFAULT_LOG_WAIT);
-
- List<String> results = _monitor.findMatches(VHT_PREFIX);
+ _monitor.waitForMessage(VHT_PREFIX + "1001", DEFAULT_LOG_WAIT);
+
+ //Validate each vhost logs a creation
+ List<String> results = _monitor.findMatches(VHT_PREFIX + "1001");
+
try
{
- // Validation
+ // Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = _monitor.findMatches("VHT-1001");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
assertEquals("Each vhost did not create a store.", vhosts.size(), results.size());
for (int index = 0; index < results.size(); index++)
{
- String result = getLog(results.get(index));
-
// Retrieve the vhostname from the log entry message 'Created : <vhostname>'
+ String result = getLog(results.get(index));
String vhostName = getMessageString(fromMessage(result)).split(" ")[2];
- assertTrue("Virualhost named in log not found in config file:" + vhostName + ":" + vhosts, vhosts.contains(vhostName));
+ assertTrue("Virtualhost named in log not found in config file:" + vhostName + ":" + vhosts, vhosts.contains(vhostName));
}
}
catch (AssertionFailedError afe)
@@ -114,21 +113,19 @@ public class VirtualHostLoggingTest extends AbstractTestLogging
{
stopBroker();
- //Wait for the correct VHT message to arrive.
- _monitor.waitForMessage("VHT-1002",DEFAULT_LOG_WAIT);
-
- List<String> results = _monitor.findMatches(VHT_PREFIX);
+ // Wait for the correct VHT message to arrive.
+ _monitor.waitForMessage(VHT_PREFIX + "1002", DEFAULT_LOG_WAIT);
+
+ // Validate each vhost logs a closure
+ List<String> results = _monitor.findMatches(VHT_PREFIX + "1002");
+
try
{
- // Validation
-
+ // Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = _monitor.findMatches("VHT-1002");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
- assertEquals("Each vhost did not create a store.", vhosts.size(), results.size());
+ assertEquals("Each vhost did not close their store.", vhosts.size(), results.size());
}
catch (AssertionFailedError afe)
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
index 5e387be91b..ec9a297047 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
@@ -33,8 +33,8 @@ import org.apache.qpid.test.utils.QpidTestCase;
public class FirewallConfigTest extends QpidTestCase
{
-
- private File tmpFile = null;
+ private File _tmpConfig, _tmpVirtualhosts;
+
@Override
protected void setUp() throws Exception
{
@@ -46,22 +46,32 @@ public class FirewallConfigTest extends QpidTestCase
fail("QPID_HOME not set");
}
- // Setup initial config.
+ // Setup initial config file.
_configFile = new File(QPID_HOME, "etc/config-systests-firewall.xml");
- tmpFile = File.createTempFile("config-systests-firewall", ".xml");
- setSystemProperty("QPID_FIREWALL_SETTINGS", tmpFile.getAbsolutePath());
- tmpFile.deleteOnExit();
+
+ // Setup temporary config file
+ _tmpConfig = File.createTempFile("config-systests-firewall", ".xml");
+ setSystemProperty("QPID_FIREWALL_CONFIG_SETTINGS", _tmpConfig.getAbsolutePath());
+ _tmpConfig.deleteOnExit();
+
+ // Setup temporary virtualhosts file
+ _tmpVirtualhosts = File.createTempFile("virtualhosts-systests-firewall", ".xml");
+ setSystemProperty("QPID_FIREWALL_VIRTUALHOSTS_SETTINGS", _tmpVirtualhosts.getAbsolutePath());
+ _tmpVirtualhosts.deleteOnExit();
}
private void writeFirewallFile(boolean allow, boolean inVhost) throws IOException
{
- FileWriter out = new FileWriter(tmpFile);
+ FileWriter out = new FileWriter(inVhost ? _tmpVirtualhosts : _tmpConfig);
String ipAddr = "127.0.0.1"; // FIXME: get this from InetAddress.getLocalHost().getAddress() ?
- out.write("<broker>");
if (inVhost)
{
out.write("<virtualhosts><virtualhost><test>");
}
+ else
+ {
+ out.write("<broker>");
+ }
out.write("<security><firewall>");
out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\""+ipAddr +"\"/>");
out.write("</firewall></security>");
@@ -69,7 +79,10 @@ public class FirewallConfigTest extends QpidTestCase
{
out.write("</test></virtualhost></virtualhosts>");
}
- out.write("</broker>");
+ else
+ {
+ out.write("</broker>");
+ }
out.close();
}
@@ -188,6 +201,23 @@ public class FirewallConfigTest extends QpidTestCase
});
}
+ public void testAllowOnReloadInVhost() throws Exception
+ {
+ testFirewall(false, true, new Runnable() {
+
+ public void run()
+ {
+ try
+ {
+ reloadBroker();
+ } catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+ }
+ });
+ }
+
public void testDenyOnReload() throws Exception
{
testDeny(false, new Runnable() {
@@ -224,18 +254,17 @@ public class FirewallConfigTest extends QpidTestCase
);
}
-
+
private void testDeny(boolean inVhost, Runnable restartOrReload) throws Exception
{
- if (_broker.equals(VM))
- {
- // No point running this test in a vm broker
- return;
- }
-
- writeFirewallFile(false, inVhost);
- super.setUp();
-
+ testFirewall(true, inVhost, restartOrReload);
+ }
+
+ /*
+ * Check we can get a connection
+ */
+ private boolean checkConnection() throws Exception
+ {
Exception exception = null;
Connection conn = null;
try
@@ -246,22 +275,27 @@ public class FirewallConfigTest extends QpidTestCase
{
exception = e;
}
- assertNotNull(exception);
- // Check we can get a connection
+ return conn != null;
+ }
+
+ private void testFirewall(boolean initial, boolean inVhost, Runnable restartOrReload) throws Exception
+ {
+ if (_broker.equals(VM))
+ {
+ // No point running this test in a vm broker
+ return;
+ }
+
+ writeFirewallFile(initial, inVhost);
+ super.setUp();
- writeFirewallFile(true, inVhost);
+ assertEquals("Initial connection check failed", initial, checkConnection());
+
+ // Reload changed firewall file after restart or reload
+ writeFirewallFile(!initial, inVhost);
restartOrReload.run();
- exception = null;
- try
- {
- conn = getConnection();
- }
- catch (JMSException e)
- {
- exception = e;
- }
- assertNull(exception);
- }
+ assertEquals("Second connection check failed", !initial, checkConnection());
+ }
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
index d693c7f6c1..9ec0f61351 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -17,14 +17,41 @@
*/
package org.apache.qpid.test.utils;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import junit.framework.TestCase;
import junit.framework.TestResult;
+
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
@@ -39,33 +66,8 @@ import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
import org.apache.qpid.server.store.DerbyMessageStore;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.util.LogMonitor;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.PrintStream;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -86,6 +88,7 @@ public class QpidTestCase extends TestCase
private Map<org.apache.log4j.Logger, Level> _loggerLevelSetForTest = new HashMap<org.apache.log4j.Logger, Level>();
private XMLConfiguration _testConfiguration = new XMLConfiguration();
+ private XMLConfiguration _testVirtualhosts = new XMLConfiguration();
protected static final String INDEX = "index";
@@ -178,9 +181,10 @@ public class QpidTestCase extends TestCase
protected static final String QPID_HOME = "QPID_HOME";
- protected static int DEFAULT_VM_PORT = 1;
- protected static int DEFAULT_PORT = Integer.getInteger("test.port", 5672);
- protected static int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", 8999);
+ public static final int DEFAULT_VM_PORT = 1;
+ public static final int DEFAULT_PORT = Integer.getInteger("test.port", ServerConfiguration.DEFAULT_PORT);
+ public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", ServerConfiguration.DEFAULT_JMXPORT);
+ public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.sslport", ServerConfiguration.DEFAULT_SSL_PORT);
protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA);
protected String _broker = System.getProperty(BROKER, VM);
@@ -208,6 +212,7 @@ public class QpidTestCase extends TestCase
protected List<Connection> _connections = new ArrayList<Connection>();
public static final String QUEUE = "queue";
public static final String TOPIC = "topic";
+
/** Map to hold test defined environment properties */
private Map<String, String> _env;
@@ -477,14 +482,16 @@ public class QpidTestCase extends TestCase
{
port = getPort(port);
- // Save any configuratio changes that have been made
+ // Save any configuration changes that have been made
saveTestConfiguration();
+ saveTestVirtualhosts();
Process process = null;
if (_broker.equals(VM))
{
setConfigurationProperty("management.jmxport", String.valueOf(getManagementPort(port)));
saveTestConfiguration();
+
// create an in_VM broker
final ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(_configFile);
try
@@ -608,22 +615,41 @@ public class QpidTestCase extends TestCase
public String getTestConfigFile()
{
String path = _output == null ? System.getProperty("java.io.tmpdir") : _output;
- return path + "/" + getTestQueueName() + ".xml";
+ return path + "/" + getTestQueueName() + "-config.xml";
+ }
+
+ public String getTestVirtualhostsFile()
+ {
+ String path = _output == null ? System.getProperty("java.io.tmpdir") : _output;
+ return path + "/" + getTestQueueName() + "-virtualhosts.xml";
}
protected void saveTestConfiguration() throws ConfigurationException
{
+ // Specifiy the test config file
String testConfig = getTestConfigFile();
- //Specifiy the test configuration
setSystemProperty("test.config", testConfig);
- // This is a work
+ // Create the file if configuration does not exist
if (_testConfiguration.isEmpty())
{
- _testConfiguration.addProperty("test", getTestQueueName());
+ _testConfiguration.addProperty("__ignore", "true");
}
+ _testConfiguration.save(testConfig);
+ }
- _testConfiguration.save(getTestConfigFile());
+ protected void saveTestVirtualhosts() throws ConfigurationException
+ {
+ // Specifiy the test virtualhosts file
+ String testVirtualhosts = getTestVirtualhostsFile();
+ setSystemProperty("test.virtualhosts", testVirtualhosts);
+
+ // Create the file if configuration does not exist
+ if (_testVirtualhosts.isEmpty())
+ {
+ _testVirtualhosts.addProperty("__ignore", "true");
+ }
+ _testVirtualhosts.save(testVirtualhosts);
}
public void cleanBroker()
@@ -690,29 +716,23 @@ public class QpidTestCase extends TestCase
protected void makeVirtualHostPersistent(String virtualhost)
throws ConfigurationException, IOException
{
- Class storeClass = DerbyMessageStore.class;
-
- Class bdb = null;
+ Class<?> storeClass = null;
try
{
- bdb = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
+ // Try and lookup the BDB class
+ storeClass = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
}
catch (ClassNotFoundException e)
{
// No BDB store, we'll use Derby instead.
- }
-
- if (bdb != null)
- {
- storeClass = bdb;
+ storeClass = DerbyMessageStore.class;
}
- _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost +
- ".store.class", storeClass.getName());
- _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost +
- ".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
- "${QPID_WORK}/" + virtualhost);
+ setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store.class",
+ storeClass.getName());
+ setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
+ "${QPID_WORK}/" + virtualhost);
}
/**
@@ -730,6 +750,7 @@ public class QpidTestCase extends TestCase
// Call save Configuration to be sure we have saved the test specific
// file. As the optional status
saveTestConfiguration();
+ saveTestVirtualhosts();
ServerConfiguration configuration = new ServerConfiguration(_configFile);
return configuration.getConfig().getString(property);
@@ -753,9 +774,15 @@ public class QpidTestCase extends TestCase
protected void setConfigurationProperty(String property, String value)
throws ConfigurationException, IOException
{
- //Write the value in to this configuration file which will override the
- // defaults.
- _testConfiguration.setProperty(property, value);
+ // Choose which file to write the property to based on prefix.
+ if (property.startsWith("virtualhosts"))
+ {
+ _testVirtualhosts.setProperty(StringUtils.substringAfter(property, "virtualhosts."), value);
+ }
+ else
+ {
+ _testConfiguration.setProperty(property, value);
+ }
}
/**
diff --git a/qpid/java/test-profiles/log4j-test.xml b/qpid/java/test-profiles/log4j-test.xml
index 2d77942a81..39d30d104a 100644
--- a/qpid/java/test-profiles/log4j-test.xml
+++ b/qpid/java/test-profiles/log4j-test.xml
@@ -51,6 +51,10 @@
<level value="WARN"/>
</logger>
+ <logger name="apache.commons.configuration.ConfigurationFactory">
+ <level value="ERROR"/>
+ </logger>
+
<root>
<level value="${root.logging.level}"/>
<appender-ref ref="console" />