qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1485163 - in /qpid/trunk/qpid/java: broker/src/main/java/org/apache/qpid/server/configuration/ broker/src/test/java/org/apache/qpid/server/model/ broker/src/test/java/org/apache/qpid/server/virtualhost/ systests/src/main/java/org/apache/qp...
Date Wed, 22 May 2013 11:41:53 GMT
Author: orudyy
Date: Wed May 22 11:41:53 2013
New Revision: 1485163

URL: http://svn.apache.org/r1485163
Log:
QPID-4876: Throw an exception when virtual host configuration is not found in virtual host
file

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java?rev=1485163&r1=1485162&r2=1485163&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
Wed May 22 11:41:53 2013
@@ -68,12 +68,11 @@ public class VirtualHostConfiguration ex
         {
             Configuration virtualHostConfig = XmlConfigurationUtilities.parseConfig(configurationFile);
 
-            // check if it is an old virtual host configuration file which has an element
of the same name as virtual host
+            // check for the element with the same name as virtual host
             Configuration config = virtualHostConfig.subset("virtualhost." + XmlConfigurationUtilities.escapeTagName(name));
             if (config.isEmpty())
             {
-                // assume it is a new configuration which does not have an element of the
same name as the virtual host
-                configuration = virtualHostConfig;
+                throw new IllegalConfigurationException("No configuration found for virtual
host '" + name + "' in " + configurationFile.getAbsolutePath());
             }
             else
             {

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java?rev=1485163&r1=1485162&r2=1485163&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
(original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
Wed May 22 11:41:53 2013
@@ -132,12 +132,14 @@ public class VirtualHostTest extends Tes
 
     public void testReplicaState()
     {
-        File configPath = TestFileUtils.createTempFile(this, ".xml",
-                "<virtualhost><store><class>" + ReplicaMessageStore.class.getName()
+ "</class></store></virtualhost>");
+        String hostName = getName();
+        File configPath = TestFileUtils.createTempFile(this, ".xml", "<virtualhosts><virtualhost><"
+ hostName
+                + "><store><class>" + ReplicaMessageStore.class.getName()
+ "</class></store></" + hostName
+                + "></virtualhost></virtualhosts>");
         try
         {
             Map<String, Object> attributes = new HashMap<String, Object>();
-            attributes.put(VirtualHost.NAME, getName());
+            attributes.put(VirtualHost.NAME, hostName);
             attributes.put(VirtualHost.CONFIG_PATH, configPath.getAbsolutePath());
 
             VirtualHost host = createHost(attributes);

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java?rev=1485163&r1=1485162&r2=1485163&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
(original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
Wed May 22 11:41:53 2013
@@ -179,6 +179,21 @@ public class VirtualHostImplTest extends
         }
     }
 
+    public void testCreateVirtualHostWithoutConfigurationInConfigFile() throws Exception
+    {
+        File config = writeConfigFile(getName(), getName(), getName() +".direct", false,
new String[0]);
+        String hostName = getName() + "-not-existing";
+        try
+        {
+            createVirtualHost(hostName, config);
+            fail("virtualhost creation should have failed due to illegal configuration");
+        }
+        catch (RuntimeException e)
+        {
+            assertEquals("No configuration found for virtual host '" + hostName + "' in "
+ config.getAbsolutePath(), e.getMessage());
+        }
+    }
+
     private void customBindingTestImpl(final String[] routingKeys) throws Exception
     {
         String exchangeName = getName() +".direct";

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java?rev=1485163&r1=1485162&r2=1485163&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
Wed May 22 11:41:53 2013
@@ -128,7 +128,7 @@ public class VirtualHostRestTest extends
 
     public void testPutCreateVirtualHostUsingConfigPath() throws Exception
     {
-        String hostName = getTestName();
+        String hostName = getName();
         File configFile = TestFileUtils.createTempFile(this, hostName + "-config.xml");
         String configPath = configFile.getAbsolutePath();
         String storeLocation = getStoreLocation(hostName);
@@ -575,9 +575,9 @@ public class VirtualHostRestTest extends
             throws ConfigurationException
     {
         XMLConfiguration testConfiguration = new XMLConfiguration();
-        testConfiguration.setProperty("virtualhosts.virtualhost." + hostName + ".store.class",
+        testConfiguration.setProperty("virtualhost." + hostName + ".store.class",
                 getTestProfileMessageStoreClassName());
-        testConfiguration.setProperty("virtualhosts.virtualhost." + hostName + ".store.environment-path",
storeLocation);
+        testConfiguration.setProperty("virtualhost." + hostName + ".store.environment-path",
storeLocation);
         testConfiguration.save(configFile);
         return testConfiguration;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message