From 7d6a028be9f6c47418e98a6fa74a359864428150 Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Thu, 17 Sep 2009 16:21:13 +0000 Subject: Merge from trunk git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-network-refactor@816261 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/broker/bin/qpid-passwd | 70 +-- qpid/java/broker/etc/acl.config.xml | 230 --------- qpid/java/broker/etc/config-systests-derby.xml | 141 ------ qpid/java/broker/etc/config-systests.xml | 143 ------ qpid/java/broker/etc/config.xml | 132 +++++- .../broker/etc/persistent_config-config-test.xml | 93 ---- qpid/java/broker/etc/sample-parsed-config.xml | 72 --- qpid/java/broker/etc/virtualhosts-config-test.xml | 40 -- qpid/java/broker/etc/virtualhosts-systests.xml | 124 ----- qpid/java/broker/etc/virtualhosts.xml | 123 ----- .../apache/qpid/server/AMQBrokerManagerMBean.java | 6 +- .../server/configuration/ServerConfiguration.java | 35 +- .../qpid/server/virtualhost/VirtualHost.java | 12 + .../configuration/ServerConfigurationTest.java | 55 ++- ...config-systests-ServerConfigurationTest-New.xml | 93 ++++ ...config-systests-ServerConfigurationTest-Old.xml | 72 +++ .../systests/etc/config-systests-acl-settings.xml | 139 ++++++ qpid/java/systests/etc/config-systests-acl.xml | 30 ++ .../etc/config-systests-derby-settings.xml | 64 +++ qpid/java/systests/etc/config-systests-derby.xml | 30 ++ .../java/systests/etc/config-systests-settings.xml | 29 ++ qpid/java/systests/etc/config-systests.xml | 29 ++ .../virtualhosts-ServerConfigurationTest-New.xml | 40 ++ .../management/jmx/ManagementActorLoggingTest.java | 527 +++++++-------------- .../configuration/ServerConfigurationFileTest.java | 2 + .../apache/qpid/server/logging/AlertingTest.java | 14 +- .../logging/DerbyMessageStoreLoggingTest.java | 43 +- .../qpid/server/logging/ManagementLoggingTest.java | 6 +- .../logging/MemoryMessageStoreLoggingTest.java | 12 +- .../server/logging/VirtualHostLoggingTest.java | 8 +- .../org/apache/qpid/server/queue/ModelTest.java | 299 ++++++++++++ .../qpid/server/security/acl/SimpleACLTest.java | 134 +++--- .../test/client/timeouts/SyncWaitDelayTest.java | 21 +- .../apache/qpid/test/utils/FailoverBaseCase.java | 4 +- .../org/apache/qpid/test/utils/JMXTestUtils.java | 208 ++++++++ .../org/apache/qpid/test/utils/QpidTestCase.java | 139 +++--- qpid/java/test-profiles/010Excludes | 3 + qpid/java/test-profiles/08Excludes | 5 + qpid/java/test-profiles/Excludes | 6 +- qpid/java/test-profiles/cpp.testprofile | 1 + qpid/java/test-profiles/default.testprofile | 5 +- 41 files changed, 1636 insertions(+), 1603 deletions(-) delete mode 100644 qpid/java/broker/etc/acl.config.xml delete mode 100644 qpid/java/broker/etc/config-systests-derby.xml delete mode 100644 qpid/java/broker/etc/config-systests.xml delete mode 100644 qpid/java/broker/etc/persistent_config-config-test.xml delete mode 100644 qpid/java/broker/etc/sample-parsed-config.xml delete mode 100644 qpid/java/broker/etc/virtualhosts-config-test.xml delete mode 100644 qpid/java/broker/etc/virtualhosts-systests.xml delete mode 100644 qpid/java/broker/etc/virtualhosts.xml create mode 100644 qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml create mode 100644 qpid/java/systests/etc/config-systests-ServerConfigurationTest-Old.xml create mode 100644 qpid/java/systests/etc/config-systests-acl-settings.xml create mode 100644 qpid/java/systests/etc/config-systests-acl.xml create mode 100644 qpid/java/systests/etc/config-systests-derby-settings.xml create mode 100644 qpid/java/systests/etc/config-systests-derby.xml create mode 100644 qpid/java/systests/etc/config-systests-settings.xml create mode 100644 qpid/java/systests/etc/config-systests.xml create mode 100644 qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml create mode 100644 qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java create mode 100644 qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java (limited to 'qpid/java') diff --git a/qpid/java/broker/bin/qpid-passwd b/qpid/java/broker/bin/qpid-passwd index 63b30b5e71..b84580da60 100755 --- a/qpid/java/broker/bin/qpid-passwd +++ b/qpid/java/broker/bin/qpid-passwd @@ -1,35 +1,35 @@ -#!/bin/bash -# -# 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. -# - -if [ -z "$QPID_HOME" ]; then - export QPID_HOME=$(dirname $(dirname $(readlink -f $0))) - export PATH=${PATH}:${QPID_HOME}/bin -fi - -# Set classpath to include Qpid jar with all required jars in manifest -QPID_LIBS=$QPID_HOME/lib/qpid-all.jar - -# Set other variables used by the qpid-run script before calling -export JAVA=java \ - JAVA_VM=-server \ - JAVA_MEM=-Xmx1024m \ - QPID_CLASSPATH=$QPID_LIBS - -. qpid-run org.apache.qpid.tools.security.Passwd "$@" +#!/bin/bash +# +# 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. +# + +if [ -z "$QPID_HOME" ]; then + export QPID_HOME=$(dirname $(dirname $(readlink -f $0))) + export PATH=${PATH}:${QPID_HOME}/bin +fi + +# Set classpath to include Qpid jar with all required jars in manifest +QPID_LIBS=$QPID_HOME/lib/qpid-all.jar + +# Set other variables used by the qpid-run script before calling +export JAVA=java \ + JAVA_VM=-server \ + JAVA_MEM=-Xmx1024m \ + QPID_CLASSPATH=$QPID_LIBS + +. qpid-run org.apache.qpid.tools.security.Passwd "$@" diff --git a/qpid/java/broker/etc/acl.config.xml b/qpid/java/broker/etc/acl.config.xml deleted file mode 100644 index a2b723fc63..0000000000 --- a/qpid/java/broker/etc/acl.config.xml +++ /dev/null @@ -1,230 +0,0 @@ - - - - ${QPID_HOME} - ${QPID_WORK} - ${prefix}/etc - - - false - - false - nio - 5672 - 8672 - 32768 - 32768 - - - false - 8999 - false - - - - false - false - 65535 - false - false - - - - - - - passwordfile - org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase - - - passwordFile - ${conf}/passwd - - - - - - - org.apache.qpid.server.security.access.plugins.DenyAll - - - - ${conf}/jmxremote.access - passwordfile - - - - - ${conf}/virtualhosts - - - test - - - org.apache.qpid.server.store.MemoryMessageStore - - - - amq.direct - - 4235264 - - 2117632 - - 600000 - - - - - - org.apache.qpid.server.security.access.plugins.SimpleXML - - - - - - - amq.direct - - - - - example.RequestQueue - - client - - - - - - tmp_* - - server - - - - TempQueue* - - server - - - - - - - - - - - - - - - - - client - - - - - - - example.RequestQueue - - server - - - - - - - - - - - - - - - - amq.direct - - client - - - - - - - example.RequestQueue - - server - - - - - - - - - - - - - - - - development - - - org.apache.qpid.server.store.MemoryMessageStore - - - - - - localhost - - - org.apache.qpid.server.store.MemoryMessageStore - - - - - - - - 0 - 2.0 - - - ${conf}/virtualhosts.xml - - - diff --git a/qpid/java/broker/etc/config-systests-derby.xml b/qpid/java/broker/etc/config-systests-derby.xml deleted file mode 100644 index e9cfa04ab5..0000000000 --- a/qpid/java/broker/etc/config-systests-derby.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - ${QPID_HOME} - ${QPID_WORK} - ${prefix}/etc - - - false - - false - - nio - 5672 - 8672 - 32768 - 32768 - - - false - 8999 - - false - - ${prefix}/../test-profiles/test_resources/ssl/keystore.jks - password - - - - - false - false - 65535 - false - false - - - - - - - passwordfile - org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase - - - passwordFile - ${conf}/passwd - - - - - - - org.apache.qpid.server.security.access.plugins.AllowAll - - - false - - - ${conf}/jmxremote.access - passwordfile - - - - - ${conf}/virtualhosts - - - localhost - - - org.apache.qpid.server.store.DerbyMessageStore - ${work}/derbyDB/localhost-store - - - - 20000 - - - - - - - development - - - org.apache.qpid.server.store.DerbyMessageStore - ${work}/derbyDB/development-store - - - - - - test - - - org.apache.qpid.server.store.DerbyMessageStore - ${work}/derbyDB/test-store - - - - - - - 0 - 2.0 - - - true - - - ${conf}/virtualhosts-systests.xml - - - diff --git a/qpid/java/broker/etc/config-systests.xml b/qpid/java/broker/etc/config-systests.xml deleted file mode 100644 index 42e8c9dbba..0000000000 --- a/qpid/java/broker/etc/config-systests.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - ${QPID_HOME} - ${QPID_WORK} - ${prefix}/etc - - - false - - false - 262144 - 262144 - - nio - 5672 - 8672 - 32768 - 32768 - - - false - 8999 - - false - - ${prefix}/../test-profiles/test_resources/ssl/keystore.jks - password - - - - - false - false - 65535 - false - false - en_US - - - - - - - passwordfile - org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase - - - passwordFile - ${conf}/passwd - - - - - - - org.apache.qpid.server.security.access.plugins.AllowAll - - - false - - - ${conf}/jmxremote.access - passwordfile - - - - - ${conf}/virtualhosts - - - localhost - - - org.apache.qpid.server.store.MemoryMessageStore - - - - 20000 - - - - - - - development - - - org.apache.qpid.server.store.MemoryMessageStore - - - - - - test - - - org.apache.qpid.server.store.MemoryMessageStore - - - - - - - 0 - 2.0 - - - true - - - ON - - ${conf}/virtualhosts-systests.xml - - - diff --git a/qpid/java/broker/etc/config.xml b/qpid/java/broker/etc/config.xml index 928b773606..8fb3a8cf5a 100644 --- a/qpid/java/broker/etc/config.xml +++ b/qpid/java/broker/etc/config.xml @@ -24,17 +24,20 @@ ${QPID_WORK} ${prefix}/etc - - true - true + false + false /path/to/keystore.ks keystorepass - --> + false false + 262144 + 262144 nio 5672 @@ -59,6 +62,7 @@ 65535 false false + en_US @@ -89,40 +93,143 @@ - ${conf}/virtualhosts + test localhost - org.apache.qpid.server.store.MemoryMessageStore + org.apache.qpid.server.store.MemoryMessageStore + 20000 + + + direct + test.direct + true + + + topic + test.topic + + + + amq.direct + 4235264 + + 2117632 + + 600000 + + 50 + + + + queue + + + ping + + + test-queue + + test.direct + true + + + + test-ping + + test.direct + + + + + development - org.apache.qpid.server.store.MemoryMessageStore + org.apache.qpid.server.store.MemoryMessageStore + + + + 30000 + 50 + + queue + + amq.direct + 4235264 + + 2117632 + + 600000 + + + + + ping + + amq.direct + 4235264 + + 2117632 + + 600000 + + + + - test - org.apache.qpid.server.store.MemoryMessageStore + org.apache.qpid.server.store.MemoryMessageStore + + + + 30000 + 50 + + queue + + amq.direct + 4235264 + + 2117632 + + 600000 + + + + + ping + + amq.direct + 4235264 + + 2117632 + + 600000 + + + + - 0 @@ -132,7 +239,8 @@ true - ${conf}/virtualhosts.xml + ON + diff --git a/qpid/java/broker/etc/persistent_config-config-test.xml b/qpid/java/broker/etc/persistent_config-config-test.xml deleted file mode 100644 index 258f54397d..0000000000 --- a/qpid/java/broker/etc/persistent_config-config-test.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - ${QPID_WORK} - ${QPID_HOME}/etc - ${conf} - - nio - 5672 - 32768 - 32768 - - - false - 8999 - - - - false - false - 65535 - false - - - - - - passwordfile - org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase - - - passwordFile - ${passwordDir}/passwd - - - - - - - org.apache.qpid.server.security.access.plugins.AllowAll - - - ${passwordDir}/jmxremote.access - passwordfile - - - - - - dev-only - - - org.apache.qpid.server.store.MemoryMessageStore - ${work}/bdbstore/dev-only-store - - - - - - 0 - 2.0 - - - true - - - ${conf}/virtualhosts-config-test.xml - - - diff --git a/qpid/java/broker/etc/sample-parsed-config.xml b/qpid/java/broker/etc/sample-parsed-config.xml deleted file mode 100644 index 37dfae4d2e..0000000000 --- a/qpid/java/broker/etc/sample-parsed-config.xml +++ /dev/null @@ -1,72 +0,0 @@ - - -${QPID_WORK} -${QPID_HOME}/etc -${conf} - -nio -5672 -32768 -32768 - - -false -8999 - - - -false -false -65535 -false - - - - -passwordfile -org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase - - -passwordFile -${passwordDir}/passwd - - - - - -org.apache.qpid.server.security.access.plugins.AllowAll - - -${passwordDir}/jmxremote.access -passwordfile - - -${conf}/virtualhosts-config-test.xml -dev-only - -dev-only - - -org.apache.qpid.server.store.MemoryMessageStore -${work}/bdbstore/dev-only-store - - -amq.direct -102400 -20480 -60000 - -dev-queue - - - - - - -0 -2.0 - - -true - - diff --git a/qpid/java/broker/etc/virtualhosts-config-test.xml b/qpid/java/broker/etc/virtualhosts-config-test.xml deleted file mode 100644 index 168aa074da..0000000000 --- a/qpid/java/broker/etc/virtualhosts-config-test.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - dev-only - - dev-only - - - amq.direct - - 102400 - 20480 - 60000 - - - dev-queue - - - - - diff --git a/qpid/java/broker/etc/virtualhosts-systests.xml b/qpid/java/broker/etc/virtualhosts-systests.xml deleted file mode 100644 index 4f23f55579..0000000000 --- a/qpid/java/broker/etc/virtualhosts-systests.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - test - - localhost - - - - direct - test.direct - true - - - topic - test.topic - - - - amq.direct - 4235264 - 2117632 - 600000 - 50 - - - queue - - - ping - - - test-queue - - test.direct - true - - - - test-ping - - test.direct - - - - - - - - - - development - - - 30000 - 50 - - queue - - amq.direct - 4235264 - 2117632 - 600000 - - - - ping - - amq.direct - 4235264 - 2117632 - 600000 - - - - - - - test - - - 30000 - 50 - - queue - - amq.direct - 4235264 - 2117632 - 600000 - - - - ping - - amq.direct - 4235264 - 2117632 - 600000 - - - - - - diff --git a/qpid/java/broker/etc/virtualhosts.xml b/qpid/java/broker/etc/virtualhosts.xml deleted file mode 100644 index f62ec3f5d7..0000000000 --- a/qpid/java/broker/etc/virtualhosts.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - test - - localhost - - - - direct - test.direct - true - - - topic - test.topic - - - - amq.direct - 4235264 - 2117632 - 600000 - - - queue - - - ping - - - test-queue - - test.direct - true - - - - test-ping - - test.direct - - - - - - - - - - development - - - 30000 - 5000 - - queue - - amq.direct - 4235264 - 2117632 - 600000 - - - - ping - - amq.direct - 4235264 - 2117632 - 600000 - - - - - - - test - - - 30000 - 5000 - - queue - - amq.direct - 4235264 - 2117632 - 600000 - - - - ping - - amq.direct - 4235264 - 2117632 - 600000 - - - - - - diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java index 2afd3c1dc3..5cfa8066e5 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java @@ -317,8 +317,10 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr try { queue.delete(); - _messageStore.removeQueue(queue); - + if (queue.isDurable()) + { + _messageStore.removeQueue(queue); + } } catch (AMQException ex) { 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 b3c8975c7c..a72c2889d1 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 @@ -148,32 +148,27 @@ public class ServerConfiguration implements SignalHandler 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); - 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 - - Configuration myConf = vhostConfiguration.subset("virtualhost." + name); - Iterator k = myConf.getKeys(); - while (k.hasNext()) - { - String key = (String) k.next(); - conf.setProperty("virtualhosts.virtualhost."+name+"."+key, myConf.getProperty(key)); - } - VirtualHostConfiguration vhostConfig = new VirtualHostConfiguration(name, conf.subset("virtualhosts.virtualhost."+name)); - _virtualHosts.put(vhostConfig.getName(), vhostConfig); - } - // Grab things other than the virtualhosts themselves Iterator keys = vhostConfiguration.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); - conf.setProperty("virtualhosts."+key, vhostConfiguration.getProperty(key)); + conf.setProperty("virtualhosts." + key, vhostConfiguration.getProperty(key)); } } } + + List hosts = conf.getList("virtualhosts.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); + } + } private void substituteEnvironmentVariables() @@ -203,7 +198,7 @@ public class ServerConfiguration implements SignalHandler } /** - * Check the configuration file to see if status updates are enabled. + * Check the configuration file to see if status updates are enabled. * @return true if status updates are enabled */ public boolean getStatusUpdatesEnabled() @@ -467,7 +462,7 @@ public class ServerConfiguration implements SignalHandler { return getConfig().getBoolean("management.enabled", true); } - + public void setManagementEnabled(boolean enabled) { getConfig().setProperty("management.enabled", enabled); diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java index aec437b700..3b776a62b4 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java @@ -195,10 +195,22 @@ public class VirtualHost implements Accessable // perform a createExchange twice with the same details in the // MessageStore(RoutingTable) as some instances may not like that. // Derby being one. + // todo this can be removed with the resolution fo QPID-2096 configFileRT.exchange.clear(); initialiseModel(hostConfig); + //todo REMOVE Work Around for QPID-2096 + // This means that all durable exchanges declared in the configuration + // will not be stored in the MessageStore. + // They will still be created/registered/available on startup for as + // long as they are contained in the configuration. However, when they + // are removed from the configuration they will no longer exist. + // This differs from durable queues as they will be writen to to the + // store. After QPID-2096 has been resolved exchanges will mirror that + // functionality. + configFileRT.exchange.clear(); + if (store != null) { _messageStore = store; 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 2285f5256e..93e7e756e6 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 @@ -54,7 +54,7 @@ public class ServerConfigurationTest extends TestCase _config = new XMLConfiguration(); } - + @Override public void tearDown() throws Exception { @@ -727,7 +727,7 @@ public class ServerConfigurationTest extends TestCase assertEquals(true, config.getQpidNIO()); // From the second file, not // present in the first } - + public void testVariableInterpolation() throws Exception { File mainFile = File.createTempFile(getClass().getName(), null); @@ -742,7 +742,7 @@ public class ServerConfigurationTest extends TestCase out.close(); ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile()); - assertEquals("Did not get correct interpolated value", + assertEquals("Did not get correct interpolated value", "foo", config.getManagementKeyStorePath()); } @@ -783,7 +783,7 @@ public class ServerConfigurationTest extends TestCase out.write("\t\n"); out.write("\n"); out.close(); - + // Load config ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile); ApplicationRegistry.initialise(reg, 1); @@ -791,18 +791,18 @@ public class ServerConfigurationTest extends TestCase // Test config VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry(); VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test"); - + TestNetworkDriver testDriver = new TestNetworkDriver(); testDriver.setRemoteAddress("127.0.0.1"); AMQProtocolEngine session = new AMQProtocolEngine(virtualHostRegistry, testDriver); assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost)); - + testDriver.setRemoteAddress("127.1.2.3"); session = new AMQProtocolEngine(virtualHostRegistry, testDriver); assertTrue(reg.getAccessManager().authoriseConnect(session, virtualHost)); } - + public void testCombinedConfigurationFirewall() throws Exception { // Write out config @@ -868,7 +868,7 @@ public class ServerConfigurationTest extends TestCase TestNetworkDriver testDriver = new TestNetworkDriver(); testDriver.setRemoteAddress("127.0.0.1"); - + AMQProtocolEngine session = new AMQProtocolEngine(virtualHostRegistry, testDriver); session.setNetworkDriver(testDriver); assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost)); @@ -945,22 +945,22 @@ public class ServerConfigurationTest extends TestCase fileBRandom.setLength(0); fileBRandom.seek(0); fileBRandom.close(); - + out = new FileWriter(fileB); out.write("\n"); out.write("\t"); out.write("\n"); out.close(); - + reg.getConfiguration().reparseConfigFile(); - + assertTrue(reg.getAccessManager().authoriseConnect(session, virtualHost)); - + fileBRandom = new RandomAccessFile(fileB, "rw"); fileBRandom.setLength(0); fileBRandom.seek(0); fileBRandom.close(); - + out = new FileWriter(fileB); out.write("\n"); out.write("\t"); @@ -968,17 +968,17 @@ public class ServerConfigurationTest extends TestCase out.close(); reg.getConfiguration().reparseConfigFile(); - + assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost)); } public void testnewParserOutputVsOldParserOutput() throws ConfigurationException { String configDir = System.getProperty("QPID_HOME")+"/etc"; - - XMLConfiguration oldConfig = new XMLConfiguration(configDir +"/sample-parsed-config.xml"); - Configuration newConfig = new ServerConfiguration(new File(configDir+"/persistent_config-config-test.xml")).getConfig(); - + + XMLConfiguration oldConfig = new XMLConfiguration(configDir +"/config-systests-ServerConfigurationTest-Old.xml"); + Configuration newConfig = new ServerConfiguration(new File(configDir+"/config-systests-ServerConfigurationTest-New.xml")).getConfig(); + Iterator xmlKeys = oldConfig.getKeys(); while (xmlKeys.hasNext()) { @@ -986,6 +986,21 @@ public class ServerConfigurationTest extends TestCase assertEquals("Incorrect value for "+key, oldConfig.getProperty(key), newConfig.getProperty(key)); } } - - + + + public void testNoVirtualhostXMLFile() throws Exception + { + int REGISTRY=1; + + File configFile = new File(System.getProperty("QPID_HOME")+"/etc/config.xml"); + assertTrue(configFile.exists()); + + ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(configFile), REGISTRY); + + VirtualHostRegistry virtualHostRegistry = ApplicationRegistry.getInstance(REGISTRY).getVirtualHostRegistry(); + + assertEquals("Incorrect virtualhost count", 3 , virtualHostRegistry.getVirtualHosts().size()); + } + + } diff --git a/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml new file mode 100644 index 0000000000..33cc90b895 --- /dev/null +++ b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml @@ -0,0 +1,93 @@ + + + + + ${QPID_WORK} + ${QPID_HOME}/etc + ${conf} + + nio + 5672 + 32768 + 32768 + + + false + 8999 + + + + false + false + 65535 + false + + + + + + passwordfile + org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase + + + passwordFile + ${passwordDir}/passwd + + + + + + + org.apache.qpid.server.security.access.plugins.AllowAll + + + ${passwordDir}/jmxremote.access + passwordfile + + + + + + dev-only + + + org.apache.qpid.server.store.MemoryMessageStore + ${work}/bdbstore/dev-only-store + + + + + + 0 + 2.0 + + + true + + + ${conf}/virtualhosts-ServerConfigurationTest-New.xml + + + diff --git a/qpid/java/systests/etc/config-systests-ServerConfigurationTest-Old.xml b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-Old.xml new file mode 100644 index 0000000000..67e0702c41 --- /dev/null +++ b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-Old.xml @@ -0,0 +1,72 @@ + + +${QPID_WORK} +${QPID_HOME}/etc +${conf} + +nio +5672 +32768 +32768 + + +false +8999 + + + +false +false +65535 +false + + + + +passwordfile +org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase + + +passwordFile +${passwordDir}/passwd + + + + + +org.apache.qpid.server.security.access.plugins.AllowAll + + +${passwordDir}/jmxremote.access +passwordfile + + +${conf}/virtualhosts-ServerConfigurationTest-New.xml +dev-only + +dev-only + + +org.apache.qpid.server.store.MemoryMessageStore +${work}/bdbstore/dev-only-store + + +amq.direct +102400 +20480 +60000 + +dev-queue + + + + + + +0 +2.0 + + +true + + diff --git a/qpid/java/systests/etc/config-systests-acl-settings.xml b/qpid/java/systests/etc/config-systests-acl-settings.xml new file mode 100644 index 0000000000..c5374a5c5e --- /dev/null +++ b/qpid/java/systests/etc/config-systests-acl-settings.xml @@ -0,0 +1,139 @@ + + + + + + + + test + + + amq.direct + + 4235264 + + 2117632 + + 600000 + + + + + + org.apache.qpid.server.security.access.plugins.SimpleXML + + + + + + + amq.direct + + + + + example.RequestQueue + + client + + + + + + tmp_* + + server + + + + TempQueue* + + server + + + + + + + + + + + + + + + + + client + + + + + + + example.RequestQueue + + server + + + + + + + + + + + + + + + + amq.direct + + client + + + + + + + example.RequestQueue + + server + + + + + + + + + + + + + + + + diff --git a/qpid/java/systests/etc/config-systests-acl.xml b/qpid/java/systests/etc/config-systests-acl.xml new file mode 100644 index 0000000000..34104dbe6b --- /dev/null +++ b/qpid/java/systests/etc/config-systests-acl.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/qpid/java/systests/etc/config-systests-derby-settings.xml b/qpid/java/systests/etc/config-systests-derby-settings.xml new file mode 100644 index 0000000000..9c25b5682e --- /dev/null +++ b/qpid/java/systests/etc/config-systests-derby-settings.xml @@ -0,0 +1,64 @@ + + + + + ${conf}/virtualhosts + + + localhost + + + org.apache.qpid.server.store.DerbyMessageStore + ${work}/derbyDB/localhost-store + + + + 20000 + + + + + + + development + + + org.apache.qpid.server.store.DerbyMessageStore + ${work}/derbyDB/development-store + + + + + + test + + + org.apache.qpid.server.store.DerbyMessageStore + ${work}/derbyDB/test-store + + + + + + + + diff --git a/qpid/java/systests/etc/config-systests-derby.xml b/qpid/java/systests/etc/config-systests-derby.xml new file mode 100644 index 0000000000..18ba0c4ad9 --- /dev/null +++ b/qpid/java/systests/etc/config-systests-derby.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/qpid/java/systests/etc/config-systests-settings.xml b/qpid/java/systests/etc/config-systests-settings.xml new file mode 100644 index 0000000000..4e9c863fda --- /dev/null +++ b/qpid/java/systests/etc/config-systests-settings.xml @@ -0,0 +1,29 @@ + + + + + false + + false + + + diff --git a/qpid/java/systests/etc/config-systests.xml b/qpid/java/systests/etc/config-systests.xml new file mode 100644 index 0000000000..290c082a4f --- /dev/null +++ b/qpid/java/systests/etc/config-systests.xml @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml b/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml new file mode 100644 index 0000000000..168aa074da --- /dev/null +++ b/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml @@ -0,0 +1,40 @@ + + + + dev-only + + dev-only + + + amq.direct + + 102400 + 20480 + 60000 + + + dev-queue + + + + + diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java index b4ba6e8156..2e107ada34 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java @@ -20,26 +20,19 @@ */ package org.apache.qpid.management.jmx; -import org.apache.qpid.commands.objects.AllObjects; -import org.apache.qpid.management.common.JMXConnnectionFactory; import org.apache.qpid.management.common.mbeans.ManagedBroker; import org.apache.qpid.management.common.mbeans.ManagedConnection; import org.apache.qpid.management.common.mbeans.ManagedExchange; import org.apache.qpid.server.logging.AbstractTestLogging; import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject; +import org.apache.qpid.test.utils.JMXTestUtils; import javax.jms.Connection; import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.management.JMException; -import javax.management.MBeanException; -import javax.management.MBeanServerConnection; -import javax.management.MBeanServerInvocationHandler; -import javax.management.ObjectName; -import javax.management.remote.JMXConnector; import java.io.IOException; import java.util.List; -import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -50,33 +43,21 @@ import java.util.concurrent.TimeUnit; */ public class ManagementActorLoggingTest extends AbstractTestLogging { - MBeanServerConnection _mbsc; - JMXConnector _jmxc; + private JMXTestUtils _jmxUtils; private static final String USER = "admin"; @Override public void setUp() throws Exception { - setConfigurationProperty("management.enabled", "true"); + _jmxUtils = new JMXTestUtils(this, USER, USER); + _jmxUtils.setUp(); super.setUp(); - - if (isExternalBroker()) - { - _jmxc = JMXConnnectionFactory.getJMXConnection( - 5000, "127.0.0.1", - getManagementPort(getPort()), USER, USER); - - _mbsc = _jmxc.getMBeanServerConnection(); - } } @Override public void tearDown() throws Exception { - if (isExternalBroker()) - { - _jmxc.close(); - } + _jmxUtils.close(); super.tearDown(); } @@ -107,34 +88,31 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testJMXManagementConsoleConnection() throws IOException { - if (isExternalBroker()) - { - List results = _monitor.findMatches("MNG-1007"); + List results = _monitor.findMatches("MNG-1007"); - assertEquals("Unexpected Management Connection count", 1, results.size()); + assertEquals("Unexpected Management Connection count", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - validateMessageID("MNG-1007", log); + validateMessageID("MNG-1007", log); - assertTrue("User not in log message:" + log, log.endsWith(USER)); - // Extract the id from the log string - // MESSAGE [mng:1(rmi://169.24.29.116)] MNG-1007 : Open : User admin - int connectionID = Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + ""); + assertTrue("User not in log message:" + log, log.endsWith(USER)); + // Extract the id from the log string + // MESSAGE [mng:1(rmi://169.24.29.116)] MNG-1007 : Open : User admin + int connectionID = Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + ""); - results = _monitor.findMatches("MNG-1008"); + results = _monitor.findMatches("MNG-1008"); - assertEquals("Unexpected Management Connection close count", 0, results.size()); + assertEquals("Unexpected Management Connection close count", 0, results.size()); - _jmxc.close(); + _jmxUtils.close(); - results = _monitor.findMatches("MNG-1008"); + results = _monitor.findMatches("MNG-1008"); - assertEquals("Unexpected Management Connection count", 1, results.size()); + assertEquals("Unexpected Management Connection count", 1, results.size()); - assertEquals("Close does not have same id as open,", connectionID, - Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + "")); - } + assertEquals("Close does not have same id as open,", connectionID, + Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + "")); } /** @@ -159,56 +137,40 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testConnectionCloseViaManagement() throws IOException, Exception { - if (isExternalBroker()) + //Create a connection to the broker + Connection connection = getConnection(); + + // Monitor the connection for an exception being thrown + // this should be a DisconnectionException but it is not this tests + // job to valiate that. Only use the exception as a synchronisation + // to check the log file for the Close message + final CountDownLatch exceptionReceived = new CountDownLatch(1); + connection.setExceptionListener(new ExceptionListener() { - - //Create a connection to the broker - Connection connection = getConnection(); - - // Monitor the connection for an exception being thrown - // this should be a DisconnectionException but it is not this tests - // job to valiate that. Only use the exception as a synchronisation - // to check the log file for the Close message - final CountDownLatch exceptionReceived = new CountDownLatch(1); - connection.setExceptionListener(new ExceptionListener() + public void onException(JMSException e) { - public void onException(JMSException e) - { - //Failover being attempted. - exceptionReceived.countDown(); - } - }); - - //Remove the connection close from any 0-10 connections - _monitor.reset(); + //Failover being attempted. + exceptionReceived.countDown(); + } + }); - // Get all active AMQP connections - AllObjects allObject = new AllObjects(_mbsc); - allObject.querystring = "org.apache.qpid:type=VirtualHost.Connection,*"; + //Remove the connection close from any 0-10 connections + _monitor.reset(); - Set objectNames = allObject.returnObjects(); + // Get a managedConnection + ManagedConnection mangedConnection = _jmxUtils.getManagedObject(ManagedConnection.class, "org.apache.qpid:type=VirtualHost.Connection,*"); - assertEquals("More than one test connection returned", 1, objectNames.size()); + //Close the connection + mangedConnection.closeConnection(); - ObjectName connectionName = objectNames.iterator().next(); + //Wait for the connection to close + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); - ManagedConnection mangedConnection = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, connectionName, - ManagedConnection.class, false); + //Validate results + List results = _monitor.findMatches("CON-1002"); - - //Close the connection - mangedConnection.closeConnection(); - - //Wait for the connection to close - assertTrue("Timed out waiting for conneciton to report close", - exceptionReceived.await(2, TimeUnit.SECONDS)); - - //Validate results - List results = _monitor.findMatches("CON-1002"); - - assertEquals("Unexpected Connection Close count", 1, results.size()); - } + assertEquals("Unexpected Connection Close count", 1, results.size()); } /** @@ -234,114 +196,100 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testCreateExchangeDirectTransientViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous exchange declares - _monitor.reset(); - - createExchange("direct"); + _monitor.reset(); - // Validate + _jmxUtils.createExchange("test", "direct", null, false); - //1 - ID is correct - List results = _monitor.findMatches("EXH-1001"); + // Validate - assertEquals("More than one exchange creation found", 1, results.size()); + //1 - ID is correct + List results = _monitor.findMatches("EXH-1001"); - String log = getLog(results.get(0)); + assertEquals("More than one exchange creation found", 1, results.size()); - // Validate correct exchange name - assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); + String log = getLog(results.get(0)); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); + // Validate correct exchange name + assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); - } + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); } public void testCreateExchangeTopicTransientViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous exchange declares - _monitor.reset(); + //Remove any previous exchange declares + _monitor.reset(); - createExchange("topic"); + _jmxUtils.createExchange("test", "topic", null, false); - // Validate + // Validate - //1 - ID is correct - List results = _monitor.findMatches("EXH-1001"); + //1 - ID is correct + List results = _monitor.findMatches("EXH-1001"); - assertEquals("More than one exchange creation found", 1, results.size()); + assertEquals("More than one exchange creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct exchange name - assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); + // Validate correct exchange name + assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } } public void testCreateExchangeFanoutTransientViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous exchange declares - _monitor.reset(); + //Remove any previous exchange declares + _monitor.reset(); - createExchange("fanout"); + _jmxUtils.createExchange("test", "fanout", null, false); - // Validate + // Validate - //1 - ID is correct - List results = _monitor.findMatches("EXH-1001"); + //1 - ID is correct + List results = _monitor.findMatches("EXH-1001"); - assertEquals("More than one exchange creation found", 1, results.size()); + assertEquals("More than one exchange creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct exchange name - assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); + // Validate correct exchange name + assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } } public void testCreateExchangeHeadersTransientViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous exchange declares - _monitor.reset(); + //Remove any previous exchange declares + _monitor.reset(); - createExchange("headers"); + _jmxUtils.createExchange("test", "headers", null, false); - // Validate + // Validate - //1 - ID is correct - List results = _monitor.findMatches("EXH-1001"); + //1 - ID is correct + List results = _monitor.findMatches("EXH-1001"); - assertEquals("More than one exchange creation found", 1, results.size()); + assertEquals("More than one exchange creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct exchange name - assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); + // Validate correct exchange name + assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName())); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } } /** @@ -365,29 +313,26 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testCreateQueueTransientViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous queue declares - _monitor.reset(); + //Remove any previous queue declares + _monitor.reset(); - createQueue(); + _jmxUtils.createQueue("test", getName(), null, false); - // Validate + // Validate - List results = _monitor.findMatches("QUE-1001"); + List results = _monitor.findMatches("QUE-1001"); - assertEquals("More than one queue creation found", 1, results.size()); + assertEquals("More than one queue creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct queue name - String subject = fromSubject(log); - assertEquals("Incorrect queue name created", getName(), AbstractTestLogSubject.getSlice("qu", subject)); + // Validate correct queue name + String subject = fromSubject(log); + assertEquals("Incorrect queue name created", getName(), AbstractTestLogSubject.getSlice("qu", subject)); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); } /** @@ -411,34 +356,29 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testQueueDeleteViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous queue declares - _monitor.reset(); + //Remove any previous queue declares + _monitor.reset(); - createQueue(); + _jmxUtils.createQueue("test", getName(), null, false); - ManagedBroker managedBroker = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getVirtualHostManagerObjectName(), - ManagedBroker.class, false); + ManagedBroker managedBroker = _jmxUtils.getManagedBroker("test"); - managedBroker.deleteQueue(getName()); + managedBroker.deleteQueue(getName()); - List results = _monitor.findMatches("QUE-1002"); + List results = _monitor.findMatches("QUE-1002"); - assertEquals("More than one queue deletion found", 1, results.size()); + assertEquals("More than one queue deletion found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct binding - String subject = fromSubject(log); - assertEquals("Incorrect queue named in delete", getName(), AbstractTestLogSubject.getSlice("qu", subject)); + // Validate correct binding + String subject = fromSubject(log); + assertEquals("Incorrect queue named in delete", getName(), AbstractTestLogSubject.getSlice("qu", subject)); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } } /** @@ -462,98 +402,83 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testBindingCreateOnDirectViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous queue declares - _monitor.reset(); + //Remove any previous queue declares + _monitor.reset(); - createQueue(); + _jmxUtils.createQueue("test", getName(), null, false); - ManagedExchange managedExchange = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getExchange("amq.direct"), - ManagedExchange.class, false); + ManagedExchange managedExchange = _jmxUtils.getManagedExchange("amq.direct"); - managedExchange.createNewBinding(getName(), getName()); + managedExchange.createNewBinding(getName(), getName()); - List results = _monitor.findMatches("BND-1001"); + List results = _monitor.findMatches("BND-1001"); - assertEquals("More than one bind creation found", 1, results.size()); + assertEquals("More than one bind creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct binding - String subject = fromSubject(log); - assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject)); - assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject)); + // Validate correct binding + String subject = fromSubject(log); + assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject)); + assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject)); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); } public void testBindingCreateOnTopicViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous queue declares - _monitor.reset(); + //Remove any previous queue declares + _monitor.reset(); - createQueue(); + _jmxUtils.createQueue("test", getName(), null, false); - ManagedExchange managedExchange = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getExchange("amq.topic"), - ManagedExchange.class, false); + ManagedExchange managedExchange = _jmxUtils.getManagedExchange("amq.topic"); - managedExchange.createNewBinding(getName(), getName()); + managedExchange.createNewBinding(getName(), getName()); - List results = _monitor.findMatches("BND-1001"); + List results = _monitor.findMatches("BND-1001"); - assertEquals("More than one bind creation found", 1, results.size()); + assertEquals("More than one bind creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct binding - String subject = fromSubject(log); - assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject)); - assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject)); + // Validate correct binding + String subject = fromSubject(log); + assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject)); + assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject)); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); } public void testBindingCreateOnFanoutViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { - //Remove any previous queue declares - _monitor.reset(); + //Remove any previous queue declares + _monitor.reset(); - createQueue(); + _jmxUtils.createQueue("test", getName(), null, false); - ManagedExchange managedExchange = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getExchange("amq.fanout"), - ManagedExchange.class, false); + ManagedExchange managedExchange = _jmxUtils.getManagedExchange("amq.fanout"); - managedExchange.createNewBinding(getName(), getName()); + managedExchange.createNewBinding(getName(), getName()); - List results = _monitor.findMatches("BND-1001"); + List results = _monitor.findMatches("BND-1001"); - assertEquals("More than one bind creation found", 1, results.size()); + assertEquals("More than one bind creation found", 1, results.size()); - String log = getLog(results.get(0)); + String log = getLog(results.get(0)); - // Validate correct binding - String subject = fromSubject(log); - assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject)); - assertEquals("Incorrect routing key in create", "*", AbstractTestLogSubject.getSlice("rk", subject)); + // Validate correct binding + String subject = fromSubject(log); + assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject)); + assertEquals("Incorrect routing key in create", "*", AbstractTestLogSubject.getSlice("rk", subject)); - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); } /** @@ -578,114 +503,28 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testUnRegisterExchangeViaManagementConsole() throws IOException, JMException { - if (isExternalBroker()) - { + //Remove any previous queue declares + _monitor.reset(); - //Remove any previous queue declares - _monitor.reset(); + _jmxUtils.createExchange("test", "direct", null, false); - createExchange("direct"); + ManagedBroker managedBroker = _jmxUtils.getManagedBroker("test"); - ManagedBroker managedBroker = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getVirtualHostManagerObjectName(), - ManagedBroker.class, false); + managedBroker.unregisterExchange(getName()); - managedBroker.unregisterExchange(getName()); + List results = _monitor.findMatches("EXH-1002"); - List results = _monitor.findMatches("EXH-1002"); - - assertEquals("More than one exchange deletion found", 1, results.size()); - - String log = getLog(results.get(0)); - - // Validate correct binding - String subject = fromSubject(log); - assertEquals("Incorrect exchange named in delete", "direct/" + getName(), AbstractTestLogSubject.getSlice("ex", subject)); - - // Validate it was a management actor. - String actor = fromActor(log); - assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); - } - } - - /** - * Create a non-durable test exchange with the current test name - * - * @throws JMException - is thrown if a exchange with this testName already exists - * @throws IOException - if there is a problem with the JMX Connection - * @throws javax.management.MBeanException - * - if there is another problem creating the exchange - */ - private void createExchange(String type) - throws JMException, IOException, MBeanException - { - ManagedBroker managedBroker = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getVirtualHostManagerObjectName(), - ManagedBroker.class, false); - - managedBroker.createNewExchange(getName(), type, false); - } - - /** - * Create a non-durable queue (with no owner) that is named after the - * creating test. - * - * @throws JMException - is thrown if a queue with this testName already exists - * @throws IOException - if there is a problem with the JMX Connection - */ - private void createQueue() - throws JMException, IOException - { - ManagedBroker managedBroker = MBeanServerInvocationHandler. - newProxyInstance(_mbsc, getVirtualHostManagerObjectName(), - ManagedBroker.class, false); - - managedBroker.createNewQueue(getName(), null, false); - } - - /** - * Retrive the ObjectName for the test Virtualhost. - * - * This is then use to create aproxy to the ManagedBroker MBean. - * - * @return the ObjectName for the 'test' VirtualHost. - */ - private ObjectName getVirtualHostManagerObjectName() - { - // Get the name of the test manager - AllObjects allObject = new AllObjects(_mbsc); - allObject.querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=test,*"; - - Set objectNames = allObject.returnObjects(); - - assertEquals("Incorrect number test vhosts returned", 1, objectNames.size()); - - // We have verified we have only one value in objectNames so return it - return objectNames.iterator().next(); - } - - /** - * Retrive the ObjectName for the given Exchange on the test Virtualhost. - * - * This is then use to create aproxy to the ManagedExchange MBean. - * - * @param exchange The exchange to retireve e.g. 'direct' - * - * @return the ObjectName for the given exchange on the test VirtualHost. - */ - private ObjectName getExchange(String exchange) - { - // Get the name of the test manager - AllObjects allObject = new AllObjects(_mbsc); - allObject.querystring = "org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=test,name=" + exchange + ",*"; + assertEquals("More than one exchange deletion found", 1, results.size()); - Set objectNames = allObject.returnObjects(); + String log = getLog(results.get(0)); - assertEquals("Incorrect number of exchange with name '" + exchange + - "' returned", 1, objectNames.size()); + // Validate correct binding + String subject = fromSubject(log); + assertEquals("Incorrect exchange named in delete", "direct/" + getName(), AbstractTestLogSubject.getSlice("ex", subject)); - // We have verified we have only one value in objectNames so return it - return objectNames.iterator().next(); + // Validate it was a management actor. + String actor = fromActor(log); + assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng")); } } 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 c4803e121e..0a88ef391c 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 @@ -40,6 +40,8 @@ public class ServerConfigurationFileTest extends QpidTestCase { fail("Unable to test without config file:" + _configFile); } + + saveTestConfiguration(); _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 620b2a5161..683abee4da 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 @@ -94,7 +94,7 @@ public class AlertingTest extends AbstractTestLogging { _connection = getConnection(); _session = _connection.createSession(true, Session.SESSION_TRANSACTED); - _destination = _session.createQueue("testQueue"); + _destination = _session.createQueue(getTestQueueName()); // Consumer is only used to actually create the destination _session.createConsumer(_destination).close(); @@ -116,14 +116,12 @@ public class AlertingTest extends AbstractTestLogging // Add the current contents of the log file to test output message.append(_monitor.readFile()); - // Write the server config file to test output - message.append("Server configuration file in use:\n"); - message.append(FileUtils.readFileAsString(_configFile)); + // Write the test config file to test output + message.append("Server configuration overrides in use:\n"); + message.append(FileUtils.readFileAsString(getTestConfigFile())); - // Write the virtualhost config file to test output - message.append("\nVirtualhost configuration file in use:\n"); - message.append(FileUtils.readFileAsString(ServerConfiguration. - flatConfig(_configFile).getString("virtualhosts"))); + message.append("\nVirtualhost maxMessageCount:\n"); + message.append((new ServerConfiguration(_configFile)).getConfig().getString("virtualhosts.virtualhost." + VIRTUALHOST + ".queues.maximumMessageCount")); fail(message.toString()); } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java index 254ec9693d..cc3993249c 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java @@ -28,6 +28,7 @@ import javax.jms.Connection; import javax.jms.Queue; import javax.jms.Session; import java.util.List; +import java.io.File; /** * The MessageStore test suite validates that the follow log messages as @@ -56,9 +57,9 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest //We call super.setUp but this will not start the broker as that is //part of the test case. - // Load current configuration file to get the list of defined vhosts - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + // Load the default configuration file to get the list of defined vhosts + ServerConfiguration configuration = new ServerConfiguration(new File(_configFile.getParent() + "/config.xml")); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); // Make them all persistent i.e. Use DerbyMessageStore and // test that it logs correctly. @@ -97,8 +98,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1002"); @@ -117,7 +118,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // Get the Simple class name from the expected class name of o.a.q.s.s.MMS String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1); @@ -160,8 +161,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1004"); @@ -186,7 +187,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // Get the Simple class name from the expected class name of o.a.q.s.s.MMS String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1); @@ -227,8 +228,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1006"); @@ -253,7 +254,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // Get the Simple class name from the expected class name of o.a.q.s.s.MMS String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1); @@ -293,8 +294,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1004 : Recovery Start :"); @@ -316,7 +317,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // Get the Simple class name from the expected class name of o.a.q.s.s.MMS String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1); @@ -358,8 +359,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1006 : Recovery Complete :"); @@ -381,7 +382,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // Get the Simple class name from the expected class name of o.a.q.s.s.MMS String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1); @@ -500,8 +501,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1004 : Recovery Start : " + queueName); @@ -542,7 +543,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // 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/ManagementLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java index 11c003a2a7..8b7c881a32 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java @@ -24,6 +24,7 @@ import junit.framework.AssertionFailedError; import org.apache.qpid.util.LogMonitor; import java.util.List; +import java.io.File; /** * Management Console Test Suite @@ -308,9 +309,8 @@ public class ManagementLoggingTest extends AbstractTestLogging // We expect the RMIConnector Server port to be 100 higher than // the RMI Server Port - int mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT) + 100; - assertTrue("SSL Keystore entry expected(" + mPort + ").:" + getMessageString(log), - getMessageString(log).endsWith(getConfigurationStringProperty("management.ssl.keyStorePath"))); + assertTrue("SSL Keystore entry expected.:" + getMessageString(log), + getMessageString(log).endsWith(new File(getConfigurationStringProperty("management.ssl.keyStorePath")).getName())); } catch (AssertionFailedError afe) { 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 a1cbeca6de..2298ba4da0 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 @@ -89,8 +89,8 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging assertEquals("MST-1001 is not the first MST message", "MST-1001", getMessageID(fromMessage(log))); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1001"); @@ -109,7 +109,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // Get the Simple class name from the expected class name of o.a.q.s.s.MMS String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1); @@ -156,8 +156,8 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging assertTrue("MST messages not logged", results.size() > 0); // Load VirtualHost list from file. - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("MST-1003"); @@ -176,7 +176,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging // 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.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); + String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class"); // 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 7bf644508e..f4a0c8b27d 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 @@ -64,8 +64,8 @@ public class VirtualHostLoggingTest extends AbstractTestLogging try { // Validation - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("VHT-1001"); @@ -117,8 +117,8 @@ public class VirtualHostLoggingTest extends AbstractTestLogging { // Validation - Configuration configuration = ServerConfiguration.flatConfig(_configFile); - List vhosts = configuration.getList("virtualhosts.virtualhost.name"); + ServerConfiguration configuration = new ServerConfiguration(_configFile); + List vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation results = _monitor.findMatches("VHT-1002"); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java new file mode 100644 index 0000000000..078b8f43ce --- /dev/null +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java @@ -0,0 +1,299 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.queue; + +import org.apache.qpid.AMQException; +import org.apache.qpid.client.AMQConnection; +import org.apache.qpid.client.AMQSession; +import org.apache.qpid.framing.AMQShortString; +import org.apache.qpid.management.common.mbeans.ManagedBroker; +import org.apache.qpid.management.common.mbeans.ManagedQueue; +import org.apache.qpid.test.utils.JMXTestUtils; +import org.apache.qpid.test.utils.QpidTestCase; + +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Session; +import javax.management.JMException; +import javax.management.MBeanException; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.UndeclaredThrowableException; + +/** + * This Test validates the Queue Model on the broker. + * Currently it has some basic queue creation / deletion tests. + * However, it should be expanded to include other tests that relate to the + * model. i.e. + * + * The Create and Delete tests should ensure that the requisite logging is + * performed. + * + * Additions to this suite would be to complete testing of creations, validating + * fields such as owner/exclusive, autodelete and priority are correctly set. + * + * Currently this test uses the JMX interface to validate that the queue has + * been declared as expected so these tests cannot run against a CPP broker. + * + * + * Tests should ensure that they clean up after themselves. + * e,g. Durable queue creation test should perform a queue delete. + */ +public class ModelTest extends QpidTestCase +{ + + private static final String USER = "admin"; + private JMXTestUtils _jmxUtils; + private static final String VIRTUALHOST_NAME = "test"; + + @Override + public void setUp() throws Exception + { + // Create a JMX Helper + _jmxUtils = new JMXTestUtils(this, USER, USER); + _jmxUtils.setUp(); + super.setUp(); + + // Open the JMX Connection + _jmxUtils.open(); + } + + @Override + public void tearDown() throws Exception + { + // Close the JMX Connection + _jmxUtils.close(); + super.tearDown(); + } + + /** + * Test that a transient queue can be created via AMQP. + * + * @throws Exception On unexpected error + */ + public void testQueueCreationTransientViaAMQP() throws Exception + { + Connection connection = getConnection(); + + String queueName = getTestQueueName(); + boolean durable = false; + boolean autoDelete = false; + boolean exclusive = false; + + createViaAMQPandValidateViaJMX(connection, queueName, durable, + autoDelete, exclusive); + } + + /** + * Test that a durable queue can be created via AMQP. + * + * @throws Exception On unexpected error + */ + + public void testQueueCreationDurableViaAMQP() throws Exception + { + Connection connection = getConnection(); + + String queueName = getTestQueueName(); + boolean durable = true; + boolean autoDelete = false; + boolean exclusive = false; + + createViaAMQPandValidateViaJMX(connection, queueName, durable, + autoDelete, exclusive); + + // Clean up + ManagedBroker managedBroker = + _jmxUtils.getManagedBroker(VIRTUALHOST_NAME); + managedBroker.deleteQueue(queueName); + } + + /** + * Test that a transient queue can be created via JMX. + * + * @throws IOException if there is a problem via the JMX connection + * @throws javax.management.JMException if there is a problem with the JMX command + */ + public void testCreationTransientViaJMX() throws IOException, JMException + { + String name = getName(); + String owner = null; + boolean durable = false; + + createViaJMXandValidateViaJMX(name, owner, durable, durable); + } + + /** + * Test that a durable queue can be created via JMX. + * + * @throws IOException if there is a problem via the JMX connection + * @throws javax.management.JMException if there is a problem with the JMX command + */ + public void testCreationDurableViaJMX() throws IOException, JMException + { + String name = getName(); + String owner = null; + boolean durable = true; + + createViaJMXandValidateViaJMX(name, owner, durable, durable); + + // Clean up + ManagedBroker managedBroker = + _jmxUtils.getManagedBroker(VIRTUALHOST_NAME); + managedBroker.deleteQueue(name); + } + + /** + * Test that a transient queue can be deleted via JMX. + * + * @throws IOException if there is a problem via the JMX connection + * @throws javax.management.JMException if there is a problem with the JMX command + */ + public void testDeletionTransientViaJMX() throws IOException, JMException + { + String name = getName(); + + _jmxUtils.createQueue(VIRTUALHOST_NAME, name, null, false); + + ManagedBroker managedBroker = _jmxUtils. + getManagedBroker(VIRTUALHOST_NAME); + + try + { + managedBroker.deleteQueue(name); + } + catch (UndeclaredThrowableException e) + { + fail(((MBeanException) ((InvocationTargetException) + e.getUndeclaredThrowable()).getTargetException()).getTargetException().getMessage()); + } + } + + /** + * Test that a durable queue can be created via JMX. + * + * @throws IOException if there is a problem via the JMX connection + * @throws javax.management.JMException if there is a problem with the JMX command + */ + public void testDeletionDurableViaJMX() throws IOException, JMException + { + String name = getName(); + + _jmxUtils.createQueue(VIRTUALHOST_NAME, name, null, true); + + ManagedBroker managedBroker = _jmxUtils. + getManagedBroker(VIRTUALHOST_NAME); + + try + { + managedBroker.deleteQueue(name); + } + catch (UndeclaredThrowableException e) + { + fail(((MBeanException) ((InvocationTargetException) + e.getUndeclaredThrowable()).getTargetException()).getTargetException().getMessage()); + } + } + + /* + * Helper Methods + */ + + /** + * Using the provided JMS Connection create a queue using the AMQP extension + * with the given properties and then validate it was created correctly via + * the JMX Connection + * + * @param connection Qpid JMS Connection + * @param queueName String the desired QueueName + * @param durable boolean if the queue should be durable + * @param autoDelete boolean if the queue is an autoDelete queue + * @param exclusive boolean if the queue is exclusive + * + * @throws AMQException if there is a problem with the createQueue call + * @throws JMException if there is a problem with the JMX validatation + * @throws IOException if there is a problem with the JMX connection + * @throws JMSException if there is a problem creating the JMS Session + */ + private void createViaAMQPandValidateViaJMX(Connection connection, + String queueName, + boolean durable, + boolean autoDelete, + boolean exclusive) + throws AMQException, JMException, IOException, JMSException + { + AMQSession session = (AMQSession) connection.createSession(false, + Session.AUTO_ACKNOWLEDGE); + + session.createQueue(new AMQShortString(queueName), + autoDelete, durable, exclusive); + + validateQueueViaJMX(queueName, exclusive ? ((AMQConnection) connection). + getUsername() : null, durable, autoDelete); + } + + /** + * Use the JMX Helper to create a queue with the given properties and then + * validate it was created correctly via the JMX Connection + * + * @param queueName String the desired QueueName + * @param owner String the owner value that should be set + * @param durable boolean if the queue should be durable + * @param autoDelete boolean if the queue is an autoDelete queue + * + * @throws JMException if there is a problem with the JMX validatation + * @throws IOException if there is a problem with the JMX connection + */ + private void createViaJMXandValidateViaJMX(String queueName, String owner, + boolean durable, boolean autoDelete) + throws JMException, IOException + { + _jmxUtils.createQueue(VIRTUALHOST_NAME, queueName, owner, durable); + + validateQueueViaJMX(queueName, owner, durable, autoDelete); + } + + /** + * Validate that a queue with the given properties exists on the broker + * + * @param queueName String the desired QueueName + * @param owner String the owner value that should be set + * @param durable boolean if the queue should be durable + * @param autoDelete boolean if the queue is an autoDelete queue + * + * @throws JMException if there is a problem with the JMX validatation + * @throws IOException if there is a problem with the JMX connection + */ + private void validateQueueViaJMX(String queueName, String owner, boolean durable, boolean autoDelete) + throws JMException, IOException + { + ManagedQueue managedQueue = _jmxUtils. + getManagedObject(ManagedQueue.class, + _jmxUtils.getQueueObjectName(VIRTUALHOST_NAME, + queueName)); + + assertEquals(queueName, managedQueue.getName()); + assertEquals(String.valueOf(owner), managedQueue.getOwner()); + assertEquals(durable, managedQueue.isDurable()); + assertEquals(autoDelete, managedQueue.isAutoDelete()); + } + +} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java index f402522a19..bb7b5efc75 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java @@ -21,6 +21,7 @@ package org.apache.qpid.server.security.acl; + import junit.framework.TestCase; import org.apache.log4j.BasicConfigurator; @@ -30,6 +31,7 @@ import org.apache.qpid.client.*; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; +import org.apache.qpid.AMQConnectionFailureException; import org.apache.qpid.AMQException; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.jms.ConnectionListener; @@ -37,6 +39,7 @@ import org.apache.qpid.url.URLSyntaxException; import javax.jms.*; import javax.jms.IllegalStateException; +import javax.naming.NamingException; import java.io.File; import java.util.ArrayList; @@ -51,46 +54,30 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E public void setUp() throws Exception { - //Shutdown the QTC broker - stopBroker(); - - // Initialise ACLs. - final String QpidExampleHome = System.getProperty("QPID_EXAMPLE_HOME"); - final File defaultaclConfigFile = new File(QpidExampleHome, "etc/acl.config.xml"); - - if (!defaultaclConfigFile.exists()) - { - System.err.println("Configuration file not found:" + defaultaclConfigFile); - fail("Configuration file not found:" + defaultaclConfigFile); - } + final String QPID_HOME = System.getProperty("QPID_HOME"); - if (System.getProperty("QPID_HOME") == null) + if (QPID_HOME == null) { fail("QPID_HOME not set"); } - ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(defaultaclConfigFile); - ApplicationRegistry.initialise(config, ApplicationRegistry.DEFAULT_INSTANCE); - TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE); - } + // Initialise ACLs. + _configFile = new File(QPID_HOME, "etc/config-systests-acl.xml"); - public void tearDown() - { - TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE); - ApplicationRegistry.remove(ApplicationRegistry.DEFAULT_INSTANCE); + super.setUp(); } - public String createConnectionString(String username, String password, String broker) + public String createConnectionString(String username, String password) { - return "amqp://" + username + ":" + password + "@clientid/test?brokerlist='" + broker + "?retries='0''"; + return "amqp://" + username + ":" + password + "@clientid/test?brokerlist='" + getBroker() + "?retries='0''"; } public void testAccessAuthorized() throws AMQException, URLSyntaxException { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); Session sesh = conn.createSession(true, Session.SESSION_TRANSACTED); @@ -103,28 +90,32 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } catch (Exception e) { - fail("Connection was not created due to:" + e.getMessage()); + fail("Connection was not created due to:" + e); } } - public void testAccessNoRights() throws URLSyntaxException, JMSException + public void testAccessNoRights() throws Exception { try { - Connection conn = createConnection("guest", "guest"); + Connection conn = getConnection("guest", "guest"); //Attempt to do do things to test connection. Session sesh = conn.createSession(true, Session.SESSION_TRANSACTED); conn.start(); sesh.rollback(); - conn.close(); fail("Connection was created."); } - catch (AMQException amqe) + catch (JMSException jmse) { - Throwable cause = amqe.getCause(); - assertEquals("Exception was wrong type", AMQAuthenticationException.class, cause.getClass()); + Throwable linkedException = jmse.getLinkedException(); + assertNotNull("Cause was null", linkedException); + + assertEquals("Linked Exception was wrong type", AMQConnectionFailureException.class, linkedException.getClass()); + + Throwable cause = linkedException.getCause(); + assertEquals("Cause was wrong type", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); } } @@ -133,7 +124,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -149,11 +140,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testClientConsumeFromNamedQueueInvalid() throws AMQException, URLSyntaxException + public void testClientConsumeFromNamedQueueInvalid() throws NamingException, Exception { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); //Prevent Failover ((AMQConnection) conn).setConnectionListener(this); @@ -180,7 +171,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -198,11 +189,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testClientCreateNamedQueue() throws JMSException, URLSyntaxException, AMQException + public void testClientCreateNamedQueue() throws NamingException, JMSException, AMQException, Exception { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -216,6 +207,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } catch (AMQAuthenticationException amqe) { + amqe.printStackTrace(); assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) amqe).getErrorCode().getCode()); } } @@ -224,7 +216,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); ((AMQConnection) conn).setConnectionListener(this); @@ -251,7 +243,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); ((AMQConnection) conn).setConnectionListener(this); @@ -277,11 +269,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testClientPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException, InterruptedException + public void testClientPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException, NamingException, Exception { try { - Connection conn = createConnection("client", "guest"); + Connection conn = getConnection("client", "guest"); ((AMQConnection) conn).setConnectionListener(this); @@ -323,7 +315,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E { try { - Connection conn = createConnection("server", "guest"); + Connection conn = getConnection("server", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -339,11 +331,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testServerConsumeFromNamedQueueInvalid() throws AMQException, URLSyntaxException + public void testServerConsumeFromNamedQueueInvalid() throws AMQException, URLSyntaxException, NamingException, Exception { try - { - Connection conn = createConnection("client", "guest"); + { + Connection conn = getConnection("client", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -364,11 +356,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testServerConsumeFromTemporaryQueue() throws AMQException, URLSyntaxException + public void testServerConsumeFromTemporaryQueue() throws AMQException, URLSyntaxException, NamingException, Exception { try { - Connection conn = createConnection("server","guest"); + Connection conn = getConnection("server", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -388,30 +380,22 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - private Connection createConnection(String username, String password) throws AMQException + @Override + public Connection getConnection(String username, String password) throws NamingException, JMSException { - AMQConnection connection = null; - try - { - connection = new AMQConnection(createConnectionString(username, password, BROKER)); - } - catch (URLSyntaxException e) - { - // This should never happen as we generate the URLs. - fail(e.getMessage()); - } + AMQConnection connection = (AMQConnection) super.getConnection(username, password); //Prevent Failover connection.setConnectionListener(this); - return (Connection)connection; + return (Connection) connection; } public void testServerCreateNamedQueueValid() throws JMSException, URLSyntaxException { try { - Connection conn = createConnection("server", "guest"); + Connection conn = getConnection("server", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -428,11 +412,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testServerCreateNamedQueueInvalid() throws JMSException, URLSyntaxException, AMQException + public void testServerCreateNamedQueueInvalid() throws JMSException, URLSyntaxException, AMQException, NamingException, Exception { try { - Connection conn = createConnection("server", "guest"); + Connection conn = getConnection("server", "guest"); Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -450,18 +434,18 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testServerCreateTemporaryQueueInvalid() throws JMSException, URLSyntaxException, AMQException + public void testServerCreateTemporaryQueueInvalid() throws NamingException, Exception { try { - Connection conn = createConnection("server", "guest"); + Connection conn = getConnection("server", "guest"); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); session.createTemporaryQueue(); - + fail("Test failed as creation succeded."); //conn will be automatically closed } @@ -475,19 +459,19 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testServerCreateAutoDeleteQueueInvalid() throws JMSException, URLSyntaxException, AMQException + public void testServerCreateAutoDeleteQueueInvalid() throws NamingException, JMSException, AMQException, Exception { Connection connection = null; try { - connection = createConnection("server", "guest"); + connection = getConnection("server", "guest"); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); ((AMQSession) session).createQueue(new AMQShortString("again_ensure_auto_delete_queue_for_temporary"), - true, false, false); + true, false, false); fail("Test failed as creation succeded."); //connection will be automatically closed @@ -495,7 +479,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E catch (AMQAuthenticationException amqe) { assertEquals("Incorrect error code thrown", 403, amqe.getErrorCode().getCode()); - } + } } /** @@ -506,10 +490,10 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E * @throws URLSyntaxException * @throws JMSException */ - public void testServerPublishUsingTransactionSuccess() throws AMQException, URLSyntaxException, JMSException + public void testServerPublishUsingTransactionSuccess() throws AMQException, URLSyntaxException, JMSException, NamingException, Exception { //Set up the Server - Connection serverConnection = createConnection("server", "guest"); + Connection serverConnection = getConnection("server", "guest"); ((AMQConnection) serverConnection).setConnectionListener(this); @@ -522,7 +506,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E serverConnection.start(); //Set up the consumer - Connection clientConnection = createConnection("client", "guest"); + Connection clientConnection = getConnection("client", "guest"); //Send a test mesage Session clientSession = clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -563,8 +547,6 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E //Send the message using a transaction as this will allow us to retrieve any errors that occur on the broker. serverSession.commit(); - - //Ensure Response is received. Message clientResponseMsg = clientResponse.receive(2000); assertNotNull("Client did not receive response message,", clientResponseMsg); @@ -588,11 +570,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E } } - public void testServerPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException + public void testServerPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException, NamingException, Exception { try { - Connection conn = createConnection("server", "guest"); + Connection conn = getConnection("server", "guest"); ((AMQConnection) conn).setConnectionListener(this); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java index b13170efc9..a123fb290c 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java @@ -57,26 +57,13 @@ public class SyncWaitDelayTest extends QpidTestCase public void setUp() throws Exception { - super.setUp(); - stopBroker(); - if (!_configFile.exists()) - { - fail("Unable to test without config file:" + _configFile); - } - XMLConfiguration configuration = new XMLConfiguration(_configFile); - configuration.setProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.class", "org.apache.qpid.server.store.SlowMessageStore"); - configuration.setProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.delays.commitTran.post", POST_COMMIT_DELAY); - configuration.setProperty("management.enabled", "false"); + setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.class", "org.apache.qpid.server.store.SlowMessageStore"); + setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.delays.commitTran.post", String.valueOf(POST_COMMIT_DELAY)); + setConfigurationProperty("management.enabled", "false"); - File tmpFile = File.createTempFile("configFile", "test"); - tmpFile.deleteOnExit(); - configuration.save(tmpFile); - - _configFile = tmpFile; - - startBroker(1); + super.setUp(); //Set the syncWrite timeout to be just larger than the delay on the commitTran. setSystemProperty("amqj.default_syncwrite_timeout", String.valueOf(SYNC_WRITE_TIMEOUT)); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java index 1bef07fcd5..64bd1503ba 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java @@ -21,6 +21,8 @@ package org.apache.qpid.test.utils; import javax.jms.Connection; +import javax.jms.JMSException; +import javax.naming.NamingException; import org.apache.qpid.util.FileUtils; @@ -64,7 +66,7 @@ public class FailoverBaseCase extends QpidTestCase * @return a connection * @throws Exception */ - public Connection getConnection() throws Exception + public Connection getConnection() throws JMSException, NamingException { Connection conn = (Boolean.getBoolean("profile.use_ssl"))? diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java new file mode 100644 index 0000000000..3f8cdb9c25 --- /dev/null +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java @@ -0,0 +1,208 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.test.utils; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.qpid.commands.objects.AllObjects; +import org.apache.qpid.management.common.JMXConnnectionFactory; +import org.apache.qpid.management.common.mbeans.ManagedBroker; +import org.apache.qpid.management.common.mbeans.ManagedExchange; + +import javax.management.JMException; +import javax.management.MBeanException; +import javax.management.MBeanServerConnection; +import javax.management.MBeanServerInvocationHandler; +import javax.management.ObjectName; +import javax.management.remote.JMXConnector; +import java.io.IOException; +import java.util.Set; + +/** + * + */ +public class JMXTestUtils +{ + QpidTestCase _test; + MBeanServerConnection _mbsc; + JMXConnector _jmxc; + + private String USER; + private String PASSWORD; + + public JMXTestUtils(QpidTestCase test, String user, String password) + { + _test = test; + USER = user; + PASSWORD = password; + } + + public void setUp() throws IOException, ConfigurationException, Exception + { + _test.setConfigurationProperty("management.enabled", "true"); + } + + public void open() throws Exception + { + _jmxc = JMXConnnectionFactory.getJMXConnection( + 5000, "127.0.0.1", + _test.getManagementPort(_test.getPort()), USER, PASSWORD); + + _mbsc = _jmxc.getMBeanServerConnection(); + } + + public void close() throws IOException + { + _jmxc.close(); + } + + /** + * Create a non-durable test exchange with the current test name + * + * @throws javax.management.JMException - is thrown if a exchange with this testName already exists + * @throws java.io.IOException - if there is a problem with the JMX Connection + * @throws javax.management.MBeanException + * - if there is another problem creating the exchange + */ + public void createExchange(String virtualHostName, String name, String type, boolean durable) + throws JMException, IOException, MBeanException + { + ManagedBroker managedBroker = getManagedBroker(virtualHostName); + + managedBroker.createNewExchange(name, type, durable); + } + + /** + * Create a non-durable queue (with no owner) that is named after the + * creating test. + * + * @throws JMException - is thrown if a queue with this testName already exists + * @throws IOException - if there is a problem with the JMX Connection + */ + public void createQueue(String virtualHostName, String name, String owner, boolean durable) + throws JMException, IOException + { + ManagedBroker managedBroker = getManagedBroker(virtualHostName); + + managedBroker.createNewQueue(name, owner, durable); + } + + /** + * Retrive the ObjectName for the test Virtualhost. + * + * This is then use to create aproxy to the ManagedBroker MBean. + * + * @return the ObjectName for the 'test' VirtualHost. + */ + public ObjectName getVirtualHostManagerObjectName(String vhostName) + { + // Get the name of the test manager + AllObjects allObject = new AllObjects(_mbsc); + allObject.querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhostName + ",*"; + + Set objectNames = allObject.returnObjects(); + + _test.assertEquals("Incorrect number test vhosts returned", 1, objectNames.size()); + + // We have verified we have only one value in objectNames so return it + return objectNames.iterator().next(); + } + + /** + * Retrive the ObjectName for the given Exchange on the test Virtualhost. + * + * This is then use to create aproxy to the ManagedExchange MBean. + * + * @param queue The exchange to retireve e.g. 'direct' + * + * @return the ObjectName for the given exchange on the test VirtualHost. + */ + public ObjectName getQueueObjectName(String virtualHostName, String queue) + { + // Get the name of the test manager + AllObjects allObject = new AllObjects(_mbsc); + allObject.querystring = "org.apache.qpid:type=VirtualHost.Queue,VirtualHost=" + virtualHostName + ",name=" + queue + ",*"; + + Set objectNames = allObject.returnObjects(); + + _test.assertEquals("Incorrect number of exchange with name '" + queue + + "' returned", 1, objectNames.size()); + + // We have verified we have only one value in objectNames so return it + return objectNames.iterator().next(); + } + + /** + * Retrive the ObjectName for the given Exchange on the test Virtualhost. + * + * This is then use to create aproxy to the ManagedExchange MBean. + * + * @param virtualHostName + * @param exchange The exchange to retireve e.g. 'direct' + * + * @return the ObjectName for the given exchange on the test VirtualHost. + */ + public ObjectName getExchangeObjectName(String virtualHostName, String exchange) + { + // Get the name of the test manager + AllObjects allObject = new AllObjects(_mbsc); + allObject.querystring = "org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=" + virtualHostName + ",name=" + exchange + ",*"; + + Set objectNames = allObject.returnObjects(); + + _test.assertEquals("Incorrect number of exchange with name '" + exchange + + "' returned", 1, objectNames.size()); + + // We have verified we have only one value in objectNames so return it + return objectNames.iterator().next(); + } + + public T getManagedObject(Class managedClass, String queryString) + { + AllObjects allObject = new AllObjects(_mbsc); + allObject.querystring = queryString; + + Set objectNames = allObject.returnObjects(); + + _test.assertEquals("More than one " + managedClass + " returned", 1, objectNames.size()); + + ObjectName objectName = objectNames.iterator().next(); + + return getManagedObject(managedClass, objectName); + } + + public T getManagedObject(Class managedClass, ObjectName objectName) + { + return MBeanServerInvocationHandler. + newProxyInstance(_mbsc, objectName, managedClass, false); + } + + public ManagedBroker getManagedBroker(String virtualHost) + { + return getManagedObject(ManagedBroker.class, getVirtualHostManagerObjectName(virtualHost).toString()); + } + + public ManagedExchange getManagedExchange(String exchangeName) + { + return MBeanServerInvocationHandler. + newProxyInstance(_mbsc, getExchangeObjectName("test", exchangeName), + ManagedExchange.class, false); + } +} 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 db096710dc..76e4118c96 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 @@ -21,6 +21,7 @@ import junit.framework.TestCase; import junit.framework.TestResult; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.XMLConfiguration; +import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionFactory; import org.apache.qpid.client.transport.TransportConnection; @@ -30,6 +31,7 @@ import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; import org.apache.qpid.server.store.DerbyMessageStore; +import org.apache.qpid.url.URLSyntaxException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,6 +75,7 @@ public class QpidTestCase extends TestCase protected long RECEIVE_TIMEOUT = 1000l; private Map _setProperties = new HashMap(); + private XMLConfiguration _testConfiguration = new XMLConfiguration(); /** * Some tests are excluded when the property test.excludes is set to true. @@ -183,8 +186,7 @@ public class QpidTestCase extends TestCase public static final String QUEUE = "queue"; public static final String TOPIC = "topic"; /** Map to hold test defined environment properties */ - private Map _env; - + private Map _env; public QpidTestCase(String name) { @@ -335,7 +337,7 @@ public class QpidTestCase extends TestCase latch.countDown(); } - if (latch != null && line.contains(stopped)) + if (!seenReady && line.contains(stopped)) { stopLine = line; } @@ -368,7 +370,9 @@ public class QpidTestCase extends TestCase /** * Return the management portin use by the broker on this main port + * * @param mainPort the broker's main port. + * * @return the management port that corresponds to the broker on the given port */ protected int getManagementPort(int mainPort) @@ -415,9 +419,14 @@ public class QpidTestCase extends TestCase { port = getPort(port); + // Save any configuratio changes that have been made + saveTestConfiguration(); + Process process = null; if (_broker.equals(VM)) { + setConfigurationProperty("management.jmxport", String.valueOf(getManagementPort(port))); + saveTestConfiguration(); // create an in_VM broker ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(_configFile), port); TransportConnection.createVMBroker(port); @@ -438,15 +447,35 @@ public class QpidTestCase extends TestCase env.put("PATH", env.get("PATH").concat(File.pathSeparator + qpidHome + "/bin")); //Add the test name to the broker run. - env.put("QPID_PNAME", "-DPNAME=\"" + _testName + "\""); + // DON'T change PNAME, qpid.stop needs this value. + env.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + _testName + "\""); env.put("QPID_WORK", System.getProperty("QPID_WORK")); // Add all the environment settings the test requested if (!_env.isEmpty()) { - for(Map.Entry entry : _env.entrySet()) + for (Map.Entry entry : _env.entrySet()) + { + env.put(entry.getKey(), entry.getValue()); + } + } + + String QPID_OPTS = " "; + // Add all the specified system properties to QPID_OPTS + if (!_setProperties.isEmpty()) + { + for (String key : _setProperties.keySet()) + { + QPID_OPTS += "-D" + key + "=" + System.getProperty(key) + " "; + } + + if (env.containsKey("QPID_OPTS")) { - env.put(entry.getKey() ,entry.getValue()); + env.put("QPID_OPTS", env.get("QPID_OPTS") + QPID_OPTS); + } + else + { + env.put("QPID_OPTS", QPID_OPTS); } } @@ -484,6 +513,27 @@ public class QpidTestCase extends TestCase _brokers.put(port, process); } + public String getTestConfigFile() + { + String path = _output == null ? System.getProperty("java.io.tmpdir") : _output; + return path + "/" + getTestQueueName() + ".xml"; + } + + protected void saveTestConfiguration() throws ConfigurationException + { + String testConfig = getTestConfigFile(); + //Specifiy the test configuration + setSystemProperty("test.config", testConfig); + + // This is a work + if (_testConfiguration.isEmpty()) + { + _testConfiguration.addProperty("test", getTestQueueName()); + } + + _testConfiguration.save(getTestConfigFile()); + } + public void cleanBroker() { if (_brokerClean != null) @@ -565,18 +615,12 @@ public class QpidTestCase extends TestCase storeClass = bdb; } - // First we munge the config file and, if we're in a VM, set up an additional logfile - XMLConfiguration configuration = new XMLConfiguration(_configFile); - configuration.setProperty("virtualhosts.virtualhost." + virtualhost + + + _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost + ".store.class", storeClass.getName()); - configuration.setProperty("virtualhosts.virtualhost." + virtualhost + + _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost + ".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY, - "${work}/" + virtualhost); - - File tmpFile = File.createTempFile("configFile", "test"); - tmpFile.deleteOnExit(); - configuration.save(tmpFile); - _configFile = tmpFile; + "${QPID_WORK}/" + virtualhost); } /** @@ -591,6 +635,10 @@ public class QpidTestCase extends TestCase */ protected String getConfigurationStringProperty(String property) throws ConfigurationException { + // Call save Configuration to be sure we have saved the test specific + // file. As the optional status + saveTestConfiguration(); + ServerConfiguration configuration = new ServerConfiguration(_configFile); return configuration.getConfig().getString(property); } @@ -613,48 +661,9 @@ public class QpidTestCase extends TestCase protected void setConfigurationProperty(String property, String value) throws ConfigurationException, IOException { - XMLConfiguration configuration = new XMLConfiguration(_configFile); - - // If we are modifying a virtualhost value then we need to do so in - // the virtualhost.xml file as these values overwrite the values in - // the main config.xml file - if (property.startsWith("virtualhosts")) - { - // So locate the virtualhost.xml file and use the ServerConfiguration - // flatConfig method to get the interpolated value. - String vhostConfigFile = ServerConfiguration. - flatConfig(_configFile).getString("virtualhosts"); - - // Load the vhostConfigFile - XMLConfiguration vhostConfiguration = new XMLConfiguration(vhostConfigFile); - - // Set the value specified in to the vhostConfig. - // Remembering that property will be 'virtualhosts.virtulhost....' - // so we need to take off the 'virtualhosts.' from the start. - vhostConfiguration.setProperty(property.substring(property.indexOf(".") + 1), value); - - // Write out the new virtualhost config file - File tmpFile = File.createTempFile("virtualhost-configFile", ".xml"); - tmpFile.deleteOnExit(); - vhostConfiguration.save(tmpFile); - - // Change the property and value to be the new virtualhosts file - // so that then update the value in the main config file. - property = "virtualhosts"; - value = tmpFile.getAbsolutePath(); - } - - configuration.setProperty(property, value); - - // Write the new server config file - File tmpFile = File.createTempFile("configFile", ".xml"); - tmpFile.deleteOnExit(); - configuration.save(tmpFile); - - _logger.info("Qpid Test Case now using configuration File:" - + tmpFile.getAbsolutePath()); - - _configFile = tmpFile; + //Write the value in to this configuration file which will override the + // defaults. + _testConfiguration.setProperty(property, value); } /** @@ -695,14 +704,13 @@ public class QpidTestCase extends TestCase * Add an environtmen variable for the external broker environment * * @param property the property to set - * @param value the value to set it to + * @param value the value to set it to */ protected void setBrokerEnvironment(String property, String value) { - _env.put(property,value); + _env.put(property, value); } - /** * Check whether the broker is an 0.8 * @@ -720,7 +728,7 @@ public class QpidTestCase extends TestCase protected boolean isJavaBroker() { - return _brokerLanguage.equals("java"); + return _brokerLanguage.equals("java") || _broker.equals("vm"); } protected boolean isCppBroker() @@ -807,7 +815,7 @@ public class QpidTestCase extends TestCase return (AMQConnectionFactory) getInitialContext().lookup(factoryName); } - public Connection getConnection() throws Exception + public Connection getConnection() throws JMSException, NamingException { return getConnection("guest", "guest"); } @@ -831,7 +839,7 @@ public class QpidTestCase extends TestCase * * @throws Exception if there is an error getting the connection */ - public Connection getConnection(String username, String password) throws Exception + public Connection getConnection(String username, String password) throws JMSException, NamingException { _logger.info("get Connection"); Connection con = getConnectionFactory().createConnection(username, password); @@ -840,7 +848,7 @@ public class QpidTestCase extends TestCase return con; } - public Connection getConnection(String username, String password, String id) throws Exception + public Connection getConnection(String username, String password, String id) throws JMSException, URLSyntaxException, AMQException, NamingException { _logger.info("get Connection"); Connection con; @@ -860,6 +868,7 @@ public class QpidTestCase extends TestCase /** * Return a uniqueName for this test. * In this case it returns a queue Named by the TestCase and TestName + * * @return String name for a queue */ protected String getTestQueueName() diff --git a/qpid/java/test-profiles/010Excludes b/qpid/java/test-profiles/010Excludes index 36e7317e31..f03d62667d 100644 --- a/qpid/java/test-profiles/010Excludes +++ b/qpid/java/test-profiles/010Excludes @@ -83,6 +83,9 @@ org.apache.qpid.server.logging.* // CPP Broker does not have a JMX interface to test org.apache.qpid.management.jmx.* +// JMX is used in this test for validation +org.apache.qpid.server.queue.ModelTest#* + // 0-10 is not supported by the MethodRegistry org.apache.qpid.test.unit.close.JavaServerCloseRaceConditionTest#* diff --git a/qpid/java/test-profiles/08Excludes b/qpid/java/test-profiles/08Excludes index 0866694854..b277c6d929 100644 --- a/qpid/java/test-profiles/08Excludes +++ b/qpid/java/test-profiles/08Excludes @@ -15,3 +15,8 @@ org.apache.qpid.server.persistent.NoLocalAfterRecoveryTest#* org.apache.qpid.client.SessionCreateTest#* org.apache.qpid.test.client.RollbackOrderTest#* + +// QPID-2097 exclude it from the InVM test runs until InVM JMX Interface is reliable +org.apache.qpid.management.jmx.ManagementActorLoggingTest#* +org.apache.qpid.server.queue.ModelTest#* + diff --git a/qpid/java/test-profiles/Excludes b/qpid/java/test-profiles/Excludes index 7ef2a15e51..a72d3bc86c 100644 --- a/qpid/java/test-profiles/Excludes +++ b/qpid/java/test-profiles/Excludes @@ -13,5 +13,9 @@ org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownListeningTCPS org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownStopped org.apache.qpid.server.logging.VirtualHostLoggingTest#testVirtualhostClosure org.apache.qpid.server.logging.MemoryMessageStoreLoggingTest#testMessageStoreClose -org.apache.qpid.server.logging.DerbyMessageStoreLoggingTest#testMessageStoreClose +// QPID-XXX : Test fails to start external broker due to Derby Exception. +org.apache.qpid.server.logging.DerbyMessageStoreLoggingTest#* + +// QPID-2081 :The configuration changes are now highlighting the close race condition +org.apache.qpid.server.security.acl.SimpleACLTest#* diff --git a/qpid/java/test-profiles/cpp.testprofile b/qpid/java/test-profiles/cpp.testprofile index 1d5416fe19..b3b979c786 100644 --- a/qpid/java/test-profiles/cpp.testprofile +++ b/qpid/java/test-profiles/cpp.testprofile @@ -8,6 +8,7 @@ broker.executable=${broker.dir}/qpidd broker.module.ssl=${module.dir}/ssl.so broker.module.cluster=${module.dir}/cluster.so broker.module.store=${store.module.dir}/msgstore.so +broker.stopped=Exception constructed broker.modules= broker.args= diff --git a/qpid/java/test-profiles/default.testprofile b/qpid/java/test-profiles/default.testprofile index 49d4a25b82..86a5b2efb3 100644 --- a/qpid/java/test-profiles/default.testprofile +++ b/qpid/java/test-profiles/default.testprofile @@ -18,9 +18,10 @@ log4j.debug=false test.port=15672 test.mport=18999 +#Note : Management will start open second port on: mport + 100 : 19099 test.port.ssl=15671 -test.port.alt=15772 -test.port.alt.ssl=15771 +test.port.alt=25672 +test.port.alt.ssl=25671 test.exclude=true profile.excludes=08TransientExcludes -- cgit v1.2.1