summaryrefslogtreecommitdiff
path: root/java/systests
diff options
context:
space:
mode:
Diffstat (limited to 'java/systests')
-rw-r--r--java/systests/etc/config-systests-ServerConfigurationTest-New.xml18
-rw-r--r--java/systests/etc/config-systests-acl-settings.xml136
-rw-r--r--java/systests/etc/config-systests-acl.xml2
-rw-r--r--java/systests/etc/config-systests-derby-settings.xml40
-rw-r--r--java/systests/etc/config-systests-derby.xml2
-rw-r--r--java/systests/etc/config-systests-firewall-2.xml28
-rw-r--r--java/systests/etc/config-systests-firewall-3.xml28
-rw-r--r--java/systests/etc/config-systests-firewall-settings.xml2
-rw-r--r--java/systests/etc/config-systests-firewall.xml5
-rw-r--r--java/systests/etc/config-systests-settings.xml1
-rw-r--r--java/systests/etc/config-systests.xml2
-rw-r--r--java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml7
-rw-r--r--java/systests/etc/virtualhosts-systests-acl-settings.xml156
-rw-r--r--java/systests/etc/virtualhosts-systests-acl.xml29
-rw-r--r--java/systests/etc/virtualhosts-systests-derby-settings.xml54
-rw-r--r--java/systests/etc/virtualhosts-systests-derby.xml29
-rw-r--r--java/systests/etc/virtualhosts-systests-firewall-2.xml47
-rw-r--r--java/systests/etc/virtualhosts-systests-firewall-3.xml49
-rw-r--r--java/systests/etc/virtualhosts-systests-firewall.xml29
-rw-r--r--java/systests/etc/virtualhosts-systests.xml28
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java19
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java28
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java47
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java100
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java139
26 files changed, 637 insertions, 390 deletions
diff --git a/java/systests/etc/config-systests-ServerConfigurationTest-New.xml b/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
index 33cc90b895..7deb80bcd9 100644
--- a/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
+++ b/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/java/systests/etc/config-systests-acl-settings.xml b/java/systests/etc/config-systests-acl-settings.xml
index d7c1ef70df..eebc75f05f 100644
--- a/java/systests/etc/config-systests-acl-settings.xml
+++ b/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/java/systests/etc/config-systests-acl.xml b/java/systests/etc/config-systests-acl.xml
index 34104dbe6b..535108235e 100644
--- a/java/systests/etc/config-systests-acl.xml
+++ b/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/java/systests/etc/config-systests-derby-settings.xml b/java/systests/etc/config-systests-derby-settings.xml
index 9c25b5682e..3ed3a9e33b 100644
--- a/java/systests/etc/config-systests-derby-settings.xml
+++ b/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/java/systests/etc/config-systests-derby.xml b/java/systests/etc/config-systests-derby.xml
index 18ba0c4ad9..ba27a0c020 100644
--- a/java/systests/etc/config-systests-derby.xml
+++ b/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/java/systests/etc/config-systests-firewall-2.xml b/java/systests/etc/config-systests-firewall-2.xml
index 1c560d751d..8380fab3d9 100644
--- a/java/systests/etc/config-systests-firewall-2.xml
+++ b/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/java/systests/etc/config-systests-firewall-3.xml b/java/systests/etc/config-systests-firewall-3.xml
index 05c4df6069..2068581ca1 100644
--- a/java/systests/etc/config-systests-firewall-3.xml
+++ b/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/java/systests/etc/config-systests-firewall-settings.xml b/java/systests/etc/config-systests-firewall-settings.xml
index d115e74663..aa73be0646 100644
--- a/java/systests/etc/config-systests-firewall-settings.xml
+++ b/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/java/systests/etc/config-systests-firewall.xml b/java/systests/etc/config-systests-firewall.xml
index 90773f5cc2..c0ce71210f 100644
--- a/java/systests/etc/config-systests-firewall.xml
+++ b/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/java/systests/etc/config-systests-settings.xml b/java/systests/etc/config-systests-settings.xml
index 4e9c863fda..a7f538aec1 100644
--- a/java/systests/etc/config-systests-settings.xml
+++ b/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/java/systests/etc/config-systests.xml b/java/systests/etc/config-systests.xml
index 290c082a4f..5d7d878e76 100644
--- a/java/systests/etc/config-systests.xml
+++ b/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/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml b/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
index 168aa074da..1b6845662b 100644
--- a/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
+++ b/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/java/systests/etc/virtualhosts-systests-acl-settings.xml b/java/systests/etc/virtualhosts-systests-acl-settings.xml
new file mode 100644
index 0000000000..50fda4e999
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests-acl.xml b/java/systests/etc/virtualhosts-systests-acl.xml
new file mode 100644
index 0000000000..4a56c39de0
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests-derby-settings.xml b/java/systests/etc/virtualhosts-systests-derby-settings.xml
new file mode 100644
index 0000000000..ed5ffbb1fd
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests-derby.xml b/java/systests/etc/virtualhosts-systests-derby.xml
new file mode 100644
index 0000000000..171be37416
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests-firewall-2.xml b/java/systests/etc/virtualhosts-systests-firewall-2.xml
new file mode 100644
index 0000000000..b85ab83676
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests-firewall-3.xml b/java/systests/etc/virtualhosts-systests-firewall-3.xml
new file mode 100644
index 0000000000..ebfc2bad20
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests-firewall.xml b/java/systests/etc/virtualhosts-systests-firewall.xml
new file mode 100644
index 0000000000..51ab6739b3
--- /dev/null
+++ b/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/java/systests/etc/virtualhosts-systests.xml b/java/systests/etc/virtualhosts-systests.xml
new file mode 100644
index 0000000000..71f1cc9889
--- /dev/null
+++ b/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/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
index 0a88ef391c..4a2d626a5b 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
+++ b/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/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
index 3429edd6bc..a4b47268e2 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
+++ b/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/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
index 1bcef1dbb0..c3c2574519 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
+++ b/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/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
index b97bd64a55..d4c3689365 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
+++ b/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/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
index 5e387be91b..ec9a297047 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
+++ b/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/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
index d693c7f6c1..9ec0f61351 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/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);
+ }
}
/**