diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-09-10 14:38:25 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-09-10 14:38:25 +0000 |
| commit | 04804de5a167a6addeff6c1c874bd06ef84e1330 (patch) | |
| tree | 01ae35a3ca529179b55bf86384113a909e8b20be /java | |
| parent | 53aea55135201b2099f2a5b472fb271db1359858 (diff) | |
| download | qpid-python-04804de5a167a6addeff6c1c874bd06ef84e1330.tar.gz | |
QPID-2091 : Updated ServerConfiguration and added test to ServerConfigurationTest. Merged virtualhost.xml with config.xml
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@813459 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
4 files changed, 170 insertions, 175 deletions
diff --git a/java/broker/etc/config.xml b/java/broker/etc/config.xml index 928b773606..8fb3a8cf5a 100644 --- a/java/broker/etc/config.xml +++ b/java/broker/etc/config.xml @@ -24,17 +24,20 @@ <work>${QPID_WORK}</work> <conf>${prefix}/etc</conf> <connector> - <!-- Uncomment out this block and edit the keystorePath and keystorePassword - to enable SSL support + <!-- To enable SSL edit the keystorePath and keystorePassword + and set enabled to true. + To disasble Non-SSL port set sslOnly to true --> <ssl> - <enabled>true</enabled> - <sslOnly>true</sslOnly> + <enabled>false</enabled> + <sslOnly>false</sslOnly> <keystorePath>/path/to/keystore.ks</keystorePath> <keystorePassword>keystorepass</keystorePassword> - </ssl>--> + </ssl> <qpidnio>false</qpidnio> <protectio> <enabled>false</enabled> + <readBufferLimitSize>262144</readBufferLimitSize> + <writeBufferLimitSize>262144</writeBufferLimitSize> </protectio> <transport>nio</transport> <port>5672</port> @@ -59,6 +62,7 @@ <framesize>65535</framesize> <compressBufferOnQueue>false</compressBufferOnQueue> <enableJMSXUserID>false</enableJMSXUserID> + <locale>en_US</locale> </advanced> <security> @@ -89,40 +93,143 @@ </security> <virtualhosts> - <directory>${conf}/virtualhosts</directory> + <default>test</default> <virtualhost> <name>localhost</name> <localhost> <store> - <class>org.apache.qpid.server.store.MemoryMessageStore</class> + <class>org.apache.qpid.server.store.MemoryMessageStore + </class> </store> <housekeeping> <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod> </housekeeping> + <exchanges> + <exchange> + <type>direct</type> + <name>test.direct</name> + <durable>true</durable> + </exchange> + <exchange> + <type>topic</type> + <name>test.topic</name> + </exchange> + </exchanges> + <queues> + <exchange>amq.direct</exchange> + <maximumQueueDepth>4235264</maximumQueueDepth> + <!-- 4Mb --> + <maximumMessageSize>2117632</maximumMessageSize> + <!-- 2Mb --> + <maximumMessageAge>600000</maximumMessageAge> + <!-- 10 mins --> + <maximumMessageCount>50</maximumMessageCount> + <!-- 50 messages --> + + <queue> + <name>queue</name> + </queue> + <queue> + <name>ping</name> + </queue> + <queue> + <name>test-queue</name> + <test-queue> + <exchange>test.direct</exchange> + <durable>true</durable> + </test-queue> + </queue> + <queue> + <name>test-ping</name> + <test-ping> + <exchange>test.direct</exchange> + </test-ping> + </queue> + + </queues> </localhost> </virtualhost> + <virtualhost> <name>development</name> <development> <store> - <class>org.apache.qpid.server.store.MemoryMessageStore</class> + <class>org.apache.qpid.server.store.MemoryMessageStore + </class> </store> + + <queues> + <minimumAlertRepeatGap>30000</minimumAlertRepeatGap> + <maximumMessageCount>50</maximumMessageCount> + <queue> + <name>queue</name> + <queue> + <exchange>amq.direct</exchange> + <maximumQueueDepth>4235264</maximumQueueDepth> + <!-- 4Mb --> + <maximumMessageSize>2117632</maximumMessageSize> + <!-- 2Mb --> + <maximumMessageAge>600000</maximumMessageAge> + <!-- 10 mins --> + </queue> + </queue> + <queue> + <name>ping</name> + <ping> + <exchange>amq.direct</exchange> + <maximumQueueDepth>4235264</maximumQueueDepth> + <!-- 4Mb --> + <maximumMessageSize>2117632</maximumMessageSize> + <!-- 2Mb --> + <maximumMessageAge>600000</maximumMessageAge> + <!-- 10 mins --> + </ping> + </queue> + </queues> </development> </virtualhost> - <virtualhost> <name>test</name> <test> <store> - <class>org.apache.qpid.server.store.MemoryMessageStore</class> + <class>org.apache.qpid.server.store.MemoryMessageStore + </class> </store> + + <queues> + <minimumAlertRepeatGap>30000</minimumAlertRepeatGap> + <maximumMessageCount>50</maximumMessageCount> + <queue> + <name>queue</name> + <queue> + <exchange>amq.direct</exchange> + <maximumQueueDepth>4235264</maximumQueueDepth> + <!-- 4Mb --> + <maximumMessageSize>2117632</maximumMessageSize> + <!-- 2Mb --> + <maximumMessageAge>600000</maximumMessageAge> + <!-- 10 mins --> + </queue> + </queue> + <queue> + <name>ping</name> + <ping> + <exchange>amq.direct</exchange> + <maximumQueueDepth>4235264</maximumQueueDepth> + <!-- 4Mb --> + <maximumMessageSize>2117632</maximumMessageSize> + <!-- 2Mb --> + <maximumMessageAge>600000</maximumMessageAge> + <!-- 10 mins --> + </ping> + </queue> + </queues> </test> </virtualhost> - </virtualhosts> <heartbeat> <delay>0</delay> @@ -132,7 +239,8 @@ <auto_register>true</auto_register> </queue> - <virtualhosts>${conf}/virtualhosts.xml</virtualhosts> + <status-updates>ON</status-updates> + </broker> diff --git a/java/broker/etc/virtualhosts.xml b/java/broker/etc/virtualhosts.xml deleted file mode 100644 index f62ec3f5d7..0000000000 --- a/java/broker/etc/virtualhosts.xml +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - - - - Licensed to the Apache Software Foundation (ASF) under one - - or more contributor license agreements. See the NOTICE file - - distributed with this work for additional information - - regarding copyright ownership. The ASF licenses this file - - to you under the Apache License, Version 2.0 (the - - "License"); you may not use this file except in compliance - - with the License. You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, - - software distributed under the License is distributed on an - - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - - KIND, either express or implied. See the License for the - - specific language governing permissions and limitations - - under the License. - - - --> -<virtualhosts> - <default>test</default> - <virtualhost> - <name>localhost</name> - <localhost> - <exchanges> - <exchange> - <type>direct</type> - <name>test.direct</name> - <durable>true</durable> - </exchange> - <exchange> - <type>topic</type> - <name>test.topic</name> - </exchange> - </exchanges> - <queues> - <exchange>amq.direct</exchange> - <maximumQueueDepth>4235264</maximumQueueDepth> <!-- 4Mb --> - <maximumMessageSize>2117632</maximumMessageSize> <!-- 2Mb --> - <maximumMessageAge>600000</maximumMessageAge> <!-- 10 mins --> - - <queue> - <name>queue</name> - </queue> - <queue> - <name>ping</name> - </queue> - <queue> - <name>test-queue</name> - <test-queue> - <exchange>test.direct</exchange> - <durable>true</durable> - </test-queue> - </queue> - <queue> - <name>test-ping</name> - <test-ping> - <exchange>test.direct</exchange> - </test-ping> - </queue> - - </queues> - </localhost> - </virtualhost> - - - <virtualhost> - <name>development</name> - <development> - <queues> - <minimumAlertRepeatGap>30000</minimumAlertRepeatGap> - <maximumMessageCount>5000</maximumMessageCount> - <queue> - <name>queue</name> - <queue> - <exchange>amq.direct</exchange> - <maximumQueueDepth>4235264</maximumQueueDepth> <!-- 4Mb --> - <maximumMessageSize>2117632</maximumMessageSize> <!-- 2Mb --> - <maximumMessageAge>600000</maximumMessageAge> <!-- 10 mins --> - </queue> - </queue> - <queue> - <name>ping</name> - <ping> - <exchange>amq.direct</exchange> - <maximumQueueDepth>4235264</maximumQueueDepth> <!-- 4Mb --> - <maximumMessageSize>2117632</maximumMessageSize> <!-- 2Mb --> - <maximumMessageAge>600000</maximumMessageAge> <!-- 10 mins --> - </ping> - </queue> - </queues> - </development> - </virtualhost> - <virtualhost> - <name>test</name> - <test> - <queues> - <minimumAlertRepeatGap>30000</minimumAlertRepeatGap> - <maximumMessageCount>5000</maximumMessageCount> - <queue> - <name>queue</name> - <queue> - <exchange>amq.direct</exchange> - <maximumQueueDepth>4235264</maximumQueueDepth> <!-- 4Mb --> - <maximumMessageSize>2117632</maximumMessageSize> <!-- 2Mb --> - <maximumMessageAge>600000</maximumMessageAge> <!-- 10 mins --> - </queue> - </queue> - <queue> - <name>ping</name> - <ping> - <exchange>amq.direct</exchange> - <maximumQueueDepth>4235264</maximumQueueDepth> <!-- 4Mb --> - <maximumMessageSize>2117632</maximumMessageSize> <!-- 2Mb --> - <maximumMessageAge>600000</maximumMessageAge> <!-- 10 mins --> - </ping> - </queue> - </queues> - </test> - </virtualhost> -</virtualhosts> diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java index 7ea7738189..ed9d8acc08 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java @@ -147,32 +147,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() @@ -202,7 +197,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() @@ -466,7 +461,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/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java index 8cb0837b39..ebfa80d139 100644 --- a/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java +++ b/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</virtualhosts>\n"); out.write("</broker>\n"); out.close(); - + // Load config ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile); ApplicationRegistry.initialise(reg, 1); @@ -795,15 +795,15 @@ public class ServerConfigurationTest extends TestCase TestIoSession iosession = new TestIoSession(); iosession.setAddress("127.0.0.1"); - + AMQProtocolSession session = new AMQMinaProtocolSession(iosession, virtualHostRegistry, codecFactory); assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost)); - + iosession.setAddress("127.1.2.3"); session = new AMQMinaProtocolSession(iosession, virtualHostRegistry, codecFactory); assertTrue(reg.getAccessManager().authoriseConnect(session, virtualHost)); } - + public void testCombinedConfigurationFirewall() throws Exception { // Write out config @@ -870,7 +870,7 @@ public class ServerConfigurationTest extends TestCase TestIoSession iosession = new TestIoSession(); iosession.setAddress("127.0.0.1"); - + AMQProtocolSession session = new AMQMinaProtocolSession(iosession, virtualHostRegistry, codecFactory); assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost)); } @@ -947,22 +947,22 @@ public class ServerConfigurationTest extends TestCase fileBRandom.setLength(0); fileBRandom.seek(0); fileBRandom.close(); - + out = new FileWriter(fileB); out.write("<firewall>\n"); out.write("\t<rule access=\"allow\" network=\"127.0.0.1\"/>"); out.write("</firewall>\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("<firewall>\n"); out.write("\t<rule access=\"deny\" network=\"127.0.0.1\"/>"); @@ -970,17 +970,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()) { @@ -988,6 +988,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()); + } + + } |
