diff options
| author | Robert Gemmell <robbie@apache.org> | 2010-05-31 16:08:02 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2010-05-31 16:08:02 +0000 |
| commit | 1b94fd6a6dec4ace311c09ee8a8ea37cd57b93ce (patch) | |
| tree | ddf9f942a8f170f0856ecccfd3d94804f167fcf8 /qpid/java | |
| parent | 6850faec84180c77821eb34b4579dc7748b1efb8 (diff) | |
| download | qpid-python-1b94fd6a6dec4ace311c09ee8a8ea37cd57b93ce.tar.gz | |
QPID-2624: Check whether virtualhosts configuration file exists
Applied patch from Andrew Kennedy <andrew.international@gmail.com>
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@949788 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
2 files changed, 33 insertions, 0 deletions
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 f8fc27e86a..7681354f19 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 @@ -244,6 +244,10 @@ public class ServerConfiguration extends ConfigurationPlugin implements SignalHa { // Open the vhosts XML file and copy values from it to our config _vhostsFile = new File(fileName); + if (!_vhostsFile.exists()) + { + throw new ConfigurationException("Virtualhosts file does not exist"); + } vhostConfiguration = parseConfig(new File(fileName)); // save the default virtualhost name 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 059ee5f54a..26f4cbf194 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 @@ -1494,4 +1494,33 @@ public class ServerConfigurationTest extends TestCase assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length); assertEquals("Incorrect virtualhost name", "test-one", oneHost.getName()); } + + /** + * Test that a non-existant virtualhost file throws a {@link ConfigurationException}. + * <p> + * Test for QPID-2624 + */ + public void testNonExistantVirtualhosts() throws Exception + { + // Write out combined config file + File mainFile = File.createTempFile(getClass().getName(), "main"); + File vhostsFile = new File("doesnotexist"); + mainFile.deleteOnExit(); + writeConfigFile(mainFile, true, false, vhostsFile, null); + + // Load config + try + { + ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile()); + config.initialise(); + } + catch (ConfigurationException ce) + { + assertEquals("Virtualhosts file does not exist", ce.getMessage()); + } + catch (Exception e) + { + fail("Should throw a ConfigurationException"); + } + } } |
