qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r747363 - in /qpid/trunk/qpid/java: ./ broker/src/main/java/org/apache/qpid/server/configuration/ broker/src/test/java/org/apache/qpid/server/configuration/ lib/
Date Tue, 24 Feb 2009 13:02:31 GMT
Author: aidan
Date: Tue Feb 24 13:02:30 2009
New Revision: 747363

URL: http://svn.apache.org/viewvc?rev=747363&view=rev
Log:
Merge branch 'QPID-1612'

Added:
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
    qpid/trunk/qpid/java/lib/commons-beanutils-core-1.8.0.jar
    qpid/trunk/qpid/java/lib/commons-configuration-1.6.jar
    qpid/trunk/qpid/java/lib/commons-digester-1.8.1.jar
Removed:
    qpid/trunk/qpid/java/lib/commons-configuration-1.2.jar
Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
    qpid/trunk/qpid/java/build.deps

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java?rev=747363&r1=747362&r2=747363&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
Tue Feb 24 13:02:30 2009
@@ -25,12 +25,18 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
+import org.apache.commons.configuration.CombinedConfiguration;
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.ConfigurationFactory;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.SystemConfiguration;
 import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.configuration.ConfigurationFactory.DigesterConfigurationFactory;
+import org.apache.commons.configuration.tree.ExpressionEngine;
 
 public class ServerConfiguration
 {
@@ -45,24 +51,57 @@
     private static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
     private static final int DEFAULT_JMXPORT = 8999;
 
-    private long _housekeepingExpiredMessageCheckPeriod = DEFAULT_HOUSEKEEPING_PERIOD;
     private static int _jmxPort = DEFAULT_JMXPORT;
 
     private Map<String, VirtualHostConfiguration> _virtualHosts = new HashMap<String,
VirtualHostConfiguration>();
     private SecurityConfiguration _securityConfiguration = null;
+
+    // Map of environment variables to config items
+    private static final Map<String, String> envVarMap = new HashMap<String, String>();
+    
+    {
+        envVarMap.put("QPID_PORT", "connector.port");
+        envVarMap.put("QPID_ENABLEDIRECTBUFFERS", "advanced.enableDirectBuffers");
+        envVarMap.put("QPID_SSLPORT", "connector.ssl.port");
+        envVarMap.put("QPID_NIO", "connector.qpidnio");
+        envVarMap.put("QPID_WRITEBIASED", "advanced.useWriteBiasedPool");
+        envVarMap.put("QPID_JMXPORT", "management.jmxport");
+        envVarMap.put("QPID_FRAMESIZE", "advanced.framesize");
+        envVarMap.put("QPID_MSGAUTH", "security.msg-auth");
+        envVarMap.put("QPID_AUTOREGISTER", "auto_register");
+        envVarMap.put("QPID_MANAGEMENTENABLED", "management.enabled");
+        envVarMap.put("QPID_HEARTBEATDELAY", "heartbeat.delay");
+        envVarMap.put("QPID_HEARTBEATTIMEOUTFACTOR", "heartbeat.timeoutFactor");
+        envVarMap.put("QPID_MAXIMUMMESSAGEAGE", "maximumMessageAge");
+        envVarMap.put("QPID_MAXIMUMMESSAGECOUNT", "maximumMessageCount");
+        envVarMap.put("QPID_MAXIMUMQUEUEDEPTH", "maximumQueueDepth");
+        envVarMap.put("QPID_MAXIMUMMESSAGESIZE", "maximumMessageSize");
+        envVarMap.put("QPID_MINIMUMALERTREPEATGAP", "minimumAlertRepeatGap");
+        envVarMap.put("QPID_SOCKETRECEIVEBUFFER", "connector.socketReceiveBuffer");
+        envVarMap.put("QPID_SOCKETWRITEBUFFER", "connector.socketWriteBuffer");
+        envVarMap.put("QPID_TCPNODELAY", "connector.tcpNoDelay");
+        envVarMap.put("QPID_ENABLEPOOLEDALLOCATOR", "advanced.enablePooledAllocator");
+    }
     
     public ServerConfiguration(File configurationURL) throws ConfigurationException
     {
-        this(config(configurationURL));
+        this(parseConfig(configurationURL));
     }
 
     public ServerConfiguration(Configuration conf) throws ConfigurationException
     {
         _config = conf;
+        
+        substituteEnvironmentVariables();
+        
         _jmxPort = _config.getInt("management.jmxport", 8999);
-
         _securityConfiguration = new SecurityConfiguration(conf.subset("security"));
 
+        setupVirtualHosts(conf);
+    }
+
+    private void setupVirtualHosts(Configuration conf) throws ConfigurationException
+    {
         List vhosts = conf.getList("virtualhosts");
         Iterator i = vhosts.iterator();
         while (i.hasNext())
@@ -85,17 +124,32 @@
         }
     }
 
-    public static String[] objListToStringArray(List objList)
+    private void substituteEnvironmentVariables()
     {
-        String[] networkStrings = new String[objList.size()];
-        int i = 0;
-        for (Object network : objList)
+        for (Entry<String, String> var : envVarMap.entrySet())
         {
-            networkStrings[i++] = (String) network;
+            String val = System.getenv(var.getKey());
+            if (val != null)
+            {
+                _config.setProperty(var.getValue(), val); 
+            }
         }
-        return networkStrings;
     }
 
+    private final static Configuration parseConfig(File file) throws ConfigurationException
+    {      
+        ConfigurationFactory factory = new ConfigurationFactory();
+        factory.setConfigurationFileName(file.getAbsolutePath());
+        Configuration conf = factory.getConfiguration();
+        Iterator keys = conf.getKeys();
+        if (!keys.hasNext())
+        {
+            keys = null;
+            conf = flatConfig(file);
+        }
+        return conf;
+    }
+    
     // Our configuration class needs to make the interpolate method
     // public so it can be called below from the config method.
     private static class MyConfiguration extends CompositeConfiguration
@@ -105,8 +159,8 @@
             return super.interpolate(obj);
         }
     }
-
-    private final static Configuration config(File url) throws ConfigurationException
+    
+    private final static Configuration flatConfig(File file) throws ConfigurationException
     {
         // We have to override the interpolate methods so that
         // interpolation takes place accross the entirety of the
@@ -121,7 +175,7 @@
                 return conf.interpolate(o);
             }
         });
-        conf.addConfiguration(new XMLConfiguration(url)
+        conf.addConfiguration(new XMLConfiguration(file)
         {
             protected String interpolate(String o)
             {
@@ -399,13 +453,13 @@
         return _config.getString("virtualhosts.default");
     }
 
-    public void setHousekeepingExpiredMessageCheckPeriod(long _housekeepingExpiredMessageCheckPeriod)
+    public void setHousekeepingExpiredMessageCheckPeriod(long value)
     {
-        this._housekeepingExpiredMessageCheckPeriod = _housekeepingExpiredMessageCheckPeriod;
+        _config.setProperty("housekeeping.expiredMessageCheckPeriod", value);
     }
 
     public long getHousekeepingExpiredMessageCheckPeriod()
     {
-        return _housekeepingExpiredMessageCheckPeriod;
+        return _config.getLong("housekeeping.expiredMessageCheckPeriod", DEFAULT_HOUSEKEEPING_PERIOD);
     }
 }

Added: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java?rev=747363&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
(added)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
Tue Feb 24 13:02:30 2009
@@ -0,0 +1,672 @@
+/*
+ *
+ * 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.configuration;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.SystemConfiguration;
+import org.apache.commons.configuration.XMLConfiguration;
+
+import junit.framework.TestCase;
+
+public class ServerConfigurationTest extends TestCase
+{
+
+    private XMLConfiguration _config;
+
+    @Override
+    public void setUp()
+    {
+        _config = new XMLConfiguration();
+    }
+    
+    public void testSetJMXManagementPort() throws ConfigurationException
+    {
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        serverConfig.setJMXManagementPort(23);
+        assertEquals(23, serverConfig.getJMXManagementPort());
+    }
+
+    public void testGetJMXManagementPort() throws ConfigurationException
+    {
+        _config.setProperty("management.jmxport", 42);
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(42, serverConfig.getJMXManagementPort());
+    }
+
+    public void testGetPlatformMbeanserver() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getPlatformMbeanserver());
+
+        // Check value we set 
+        _config.setProperty("management.platform-mbeanserver", false);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getPlatformMbeanserver());
+    }
+
+    public void testGetPluginDirectory() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(null, serverConfig.getPluginDirectory());
+
+        // Check value we set 
+        _config.setProperty("plugin-directory", "/path/to/plugins");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("/path/to/plugins", serverConfig.getPluginDirectory());
+    }
+
+    public void testGetPrincipalDatabaseNames() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getPrincipalDatabaseNames().size());
+
+        // Check value we set 
+        _config.setProperty("security.principal-databases.principal-database(0).name", "a");
+        _config.setProperty("security.principal-databases.principal-database(1).name", "b");
+        serverConfig = new ServerConfiguration(_config);
+        List<String> dbs = serverConfig.getPrincipalDatabaseNames();
+        assertEquals(2, dbs.size());
+        assertEquals("a", dbs.get(0));
+        assertEquals("b", dbs.get(1));
+    }
+    
+    public void testGetPrincipalDatabaseClass() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getPrincipalDatabaseClass().size());
+
+        // Check value we set 
+        _config.setProperty("security.principal-databases.principal-database(0).class", "a");
+        _config.setProperty("security.principal-databases.principal-database(1).class", "b");
+        serverConfig = new ServerConfiguration(_config);
+        List<String> dbs = serverConfig.getPrincipalDatabaseClass();
+        assertEquals(2, dbs.size());
+        assertEquals("a", dbs.get(0));
+        assertEquals("b", dbs.get(1));
+    }
+
+    public void testGetPrincipalDatabaseAttributeNames() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getPrincipalDatabaseAttributeNames(1).size());
+
+        // Check value we set 
+        _config.setProperty("security.principal-databases.principal-database(0).attributes(0).attribute.name",
"a");
+        _config.setProperty("security.principal-databases.principal-database(0).attributes(1).attribute.name",
"b");
+        serverConfig = new ServerConfiguration(_config);
+        List<String> dbs = serverConfig.getPrincipalDatabaseAttributeNames(0);
+        assertEquals(2, dbs.size());
+        assertEquals("a", dbs.get(0));
+        assertEquals("b", dbs.get(1));
+    }
+
+
+    public void testGetPrincipalDatabaseAttributeValues() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getPrincipalDatabaseAttributeValues(1).size());
+
+        // Check value we set 
+        _config.setProperty("security.principal-databases.principal-database(0).attributes(0).attribute.value",
"a");
+        _config.setProperty("security.principal-databases.principal-database(0).attributes(1).attribute.value",
"b");
+        serverConfig = new ServerConfiguration(_config);
+        List<String> dbs = serverConfig.getPrincipalDatabaseAttributeValues(0);
+        assertEquals(2, dbs.size());
+        assertEquals("a", dbs.get(0));
+        assertEquals("b", dbs.get(1));
+    }
+
+    public void testGetManagementAccessList() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getManagementAccessList().size());
+
+        // Check value we set 
+        _config.setProperty("security.jmx.access(0)", "a");
+        _config.setProperty("security.jmx.access(1)", "b");
+        serverConfig = new ServerConfiguration(_config);
+        List<String> dbs = serverConfig.getManagementAccessList();
+        assertEquals(2, dbs.size());
+        assertEquals("a", dbs.get(0));
+        assertEquals("b", dbs.get(1));
+    }
+
+    public void testGetFrameSize() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(65536, serverConfig.getFrameSize());
+
+        // Check value we set 
+        _config.setProperty("advanced.framesize", "23");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getFrameSize());
+    }
+
+    public void testGetManagementSecurityEnabled() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getManagementSecurityEnabled());
+
+        // Check value we set 
+        _config.setProperty("management.security-enabled", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getManagementSecurityEnabled());
+    }
+
+    public void testGetProtectIOEnabled() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getProtectIOEnabled());
+
+        // Check value we set 
+        _config.setProperty("broker.connector.protectio.enabled", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getProtectIOEnabled());
+    }
+
+    public void testGetBufferReadLimit() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(262144, serverConfig.getBufferReadLimit());
+
+        // Check value we set 
+        _config.setProperty("broker.connector.protectio.readBufferLimitSize", 23);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getBufferReadLimit());
+    }
+
+    public void testGetBufferWriteLimit() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(262144, serverConfig.getBufferWriteLimit());
+
+        // Check value we set 
+        _config.setProperty("broker.connector.protectio.writeBufferLimitSize", 23);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getBufferWriteLimit());
+    }
+
+    public void testGetSynchedClocks() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getSynchedClocks());
+
+        // Check value we set 
+        _config.setProperty("advanced.synced-clocks", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getSynchedClocks());
+    }
+
+    public void testGetMsgAuth() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getMsgAuth());
+
+        // Check value we set 
+        _config.setProperty("security.msg-auth", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getMsgAuth());
+    }
+
+    public void testGetJMXPrincipalDatabase() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(null, serverConfig.getJMXPrincipalDatabase());
+
+        // Check value we set 
+        _config.setProperty("security.jmx.principal-database", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getJMXPrincipalDatabase());
+    }
+
+    public void testGetManagementKeyStorePath() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(null, serverConfig.getManagementKeyStorePath());
+
+        // Check value we set 
+        _config.setProperty("management.ssl.keyStorePath", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getManagementKeyStorePath());
+    }
+
+    public void testGetManagementSSLEnabled() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getManagementSSLEnabled());
+
+        // Check value we set 
+        _config.setProperty("management.ssl.enabled", false);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getManagementSSLEnabled());
+    }
+
+    public void testGetManagementKeyStorePassword() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(null, serverConfig.getManagementKeyStorePassword());
+
+        // Check value we set 
+        _config.setProperty("management.ssl.keyStorePassword", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getManagementKeyStorePassword());
+    }
+
+    public void testGetQueueAutoRegister() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getQueueAutoRegister());
+
+        // Check value we set 
+        _config.setProperty("queue.auto_register", false);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getQueueAutoRegister());
+    }
+
+    public void testGetManagementEnabled() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getManagementEnabled());
+
+        // Check value we set 
+        _config.setProperty("management.enabled", false);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getManagementEnabled());
+    }
+
+    public void testSetManagementEnabled() throws ConfigurationException
+    {
+        // Check value we set 
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        serverConfig.setManagementEnabled(false);
+        assertEquals(false, serverConfig.getManagementEnabled());
+    }
+
+    public void testGetHeartBeatDelay() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(5, serverConfig.getHeartBeatDelay());
+
+        // Check value we set 
+        _config.setProperty("heartbeat.delay", 23);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getHeartBeatDelay());
+    }
+
+    public void testGetHeartBeatTimeout() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(2.0, serverConfig.getHeartBeatTimeout());
+
+        // Check value we set 
+        _config.setProperty("heartbeat.timeoutFactor", 2.3);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(2.3, serverConfig.getHeartBeatTimeout());
+    }
+
+    public void testGetMaximumMessageAge() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getMaximumMessageAge());
+
+        // Check value we set 
+        _config.setProperty("maximumMessageAge", 10L);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getMaximumMessageAge());
+    }
+
+    public void testGetMaximumMessageCount() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getMaximumMessageCount());
+
+        // Check value we set 
+        _config.setProperty("maximumMessageCount", 10L);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getMaximumMessageCount());
+    }
+
+    public void testGetMaximumQueueDepth() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getMaximumQueueDepth());
+
+        // Check value we set 
+        _config.setProperty("maximumQueueDepth", 10L);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getMaximumQueueDepth());
+    }
+
+    public void testGetMaximumMessageSize() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getMaximumMessageSize());
+
+        // Check value we set 
+        _config.setProperty("maximumMessageSize", 10L);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getMaximumMessageSize());
+    }
+
+    public void testGetMinimumAlertRepeatGap() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(0, serverConfig.getMinimumAlertRepeatGap());
+
+        // Check value we set 
+        _config.setProperty("minimumAlertRepeatGap", 10L);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getMinimumAlertRepeatGap());
+    }
+
+    public void testGetProcessors() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(4, serverConfig.getProcessors());
+
+        // Check value we set 
+        _config.setProperty("connector.processors", 10);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getProcessors());
+    }
+
+    public void testGetPort() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(5672, serverConfig.getPort());
+
+        // Check value we set 
+        _config.setProperty("connector.port", 10);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(10, serverConfig.getPort());
+    }
+
+    public void testGetBind() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals("wildcard", serverConfig.getBind());
+
+        // Check value we set 
+        _config.setProperty("connector.bind", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getBind());
+    }
+
+    public void testGetReceiveBufferSize() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(32767, serverConfig.getReceiveBufferSize());
+
+        // Check value we set 
+        _config.setProperty("connector.socketReceiveBuffer", "23");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getReceiveBufferSize());
+    }
+
+    public void testGetWriteBufferSize() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(32767, serverConfig.getWriteBufferSize());
+
+        // Check value we set 
+        _config.setProperty("connector.socketWriteBuffer", "23");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getWriteBufferSize());
+    }
+
+    public void testGetTcpNoDelay() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getTcpNoDelay());
+
+        // Check value we set 
+        _config.setProperty("connector.tcpNoDelay", false);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getTcpNoDelay());
+    }
+
+    public void testGetEnableExecutorPool() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getEnableExecutorPool());
+
+        // Check value we set 
+        _config.setProperty("advanced.filterchain[@enableExecutorPool]", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getEnableExecutorPool());
+    }
+
+    public void testGetEnablePooledAllocator() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getEnablePooledAllocator());
+
+        // Check value we set 
+        _config.setProperty("advanced.enablePooledAllocator", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getEnablePooledAllocator());
+    }
+
+    public void testGetEnableDirectBuffers() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getEnableDirectBuffers());
+
+        // Check value we set 
+        _config.setProperty("advanced.enableDirectBuffers", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getEnableDirectBuffers());
+    }
+
+    public void testGetEnableSSL() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getEnableSSL());
+
+        // Check value we set 
+        _config.setProperty("connector.ssl.enabled", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getEnableSSL());
+    }
+
+    public void testGetSSLOnly() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getSSLOnly());
+
+        // Check value we set 
+        _config.setProperty("connector.ssl.sslOnly", false);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getSSLOnly());
+    }
+    
+    public void testGetSSLPort() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(8672, serverConfig.getSSLPort());
+
+        // Check value we set 
+        _config.setProperty("connector.ssl.port", 23);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getSSLPort());
+    }
+
+    public void testGetKeystorePath() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals("none", serverConfig.getKeystorePath());
+
+        // Check value we set 
+        _config.setProperty("connector.ssl.keystorePath", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getKeystorePath());
+    }
+    
+    public void testGetKeystorePassword() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals("none", serverConfig.getKeystorePassword());
+
+        // Check value we set 
+        _config.setProperty("connector.ssl.keystorePassword", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getKeystorePassword());
+    }
+
+    public void testGetCertType() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals("SunX509", serverConfig.getCertType());
+
+        // Check value we set 
+        _config.setProperty("connector.ssl.certType", "a");
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals("a", serverConfig.getCertType());
+    }
+
+    public void testGetQpidNIO() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getQpidNIO());
+
+        // Check value we set 
+        _config.setProperty("connector.qpidnio", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getQpidNIO());
+    }
+
+    public void testGetUseBiasedWrites() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(false, serverConfig.getUseBiasedWrites());
+
+        // Check value we set 
+        _config.setProperty("advanced.useWriteBiasedPool", true);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(true, serverConfig.getUseBiasedWrites());
+    }
+
+    public void testGetHousekeepingExpiredMessageCheckPeriod() throws ConfigurationException
+    {
+        // Check default
+        ServerConfiguration serverConfig = new ServerConfiguration(_config);
+        assertEquals(30000, serverConfig.getHousekeepingExpiredMessageCheckPeriod());
+
+        // Check value we set 
+        _config.setProperty("housekeeping.expiredMessageCheckPeriod", 23L);
+        serverConfig = new ServerConfiguration(_config);
+        assertEquals(23, serverConfig.getHousekeepingExpiredMessageCheckPeriod());
+        serverConfig.setHousekeepingExpiredMessageCheckPeriod(42L);
+        assertEquals(42, serverConfig.getHousekeepingExpiredMessageCheckPeriod());
+    }
+
+    public void testSingleConfiguration() throws IOException, ConfigurationException 
+    {
+        File fileA = File.createTempFile(getClass().getName(), null);
+        fileA.deleteOnExit();
+        FileWriter out = new FileWriter(fileA);
+        out.write("<broker><connector><port>2342</port><ssl><port>4235</port></ssl></connector></broker>");
+        out.close();
+        ServerConfiguration conf = new ServerConfiguration(fileA);
+        assertEquals(4235, conf.getSSLPort());
+    }
+    
+    public void testCombinedConfiguration() throws IOException, ConfigurationException
+    {
+        File mainFile = File.createTempFile(getClass().getName(), null);
+        File fileA = File.createTempFile(getClass().getName(), null);
+        File fileB = File.createTempFile(getClass().getName(), null);
+        
+        mainFile.deleteOnExit();
+        fileA.deleteOnExit();
+        fileB.deleteOnExit();
+        
+        FileWriter out = new FileWriter(mainFile);
+        out.write("<configuration><system/>");
+        out.write("<xml fileName=\""+fileA.getAbsolutePath()+"\"/>");
+        out.write("<xml fileName=\""+fileB.getAbsolutePath()+"\"/>");
+        out.write("</configuration>");
+        out.close();
+        
+        out = new FileWriter(fileA);
+        out.write("<broker><connector><port>2342</port><ssl><port>4235</port></ssl></connector></broker>");
+        out.close();
+        
+        out = new FileWriter(fileB);
+        out.write("<broker><connector><ssl><port>2345</port></ssl><qpidnio>true</qpidnio></connector></broker>");
+        out.close();
+        
+        ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+        assertEquals(4235, config.getSSLPort()); // From first file, not overriden by second
+        assertEquals(2342, config.getPort()); // From the first file, not present in the
second
+        assertEquals(true, config.getQpidNIO()); // From the second file, not present in
the first
+    }
+    
+}

Modified: qpid/trunk/qpid/java/build.deps
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/build.deps?rev=747363&r1=747362&r2=747363&view=diff
==============================================================================
--- qpid/trunk/qpid/java/build.deps (original)
+++ qpid/trunk/qpid/java/build.deps Tue Feb 24 13:02:30 2009
@@ -1,9 +1,11 @@
 backport-util-concurrent=lib/backport-util-concurrent-2.2.jar
 
+commons-beanutils-core=lib/commons-beanutils-core-1.8.0.jar
 commons-cli=lib/commons-cli-1.0.jar
 commons-codec=lib/commons-codec-1.3.jar
 commons-collections=lib/commons-collections-3.2.jar
-commons-configuration=lib/commons-configuration-1.2.jar
+commons-configuration=lib/commons-configuration-1.6.jar
+commons-digester=lib/commons-digester-1.8.1.jar
 commons-lang=lib/commons-lang-2.2.jar
 commons-logging=lib/commons-logging-1.0.4.jar
 commons-pool=lib/commons-pool-1.4.jar
@@ -71,8 +73,9 @@
 felix.libs=${osgi-core} ${felix-framework}
 
 common.libs=${slf4j-api} ${backport-util-concurrent} ${mina-core} \
-    ${mina-filter-ssl} ${commons-codec} ${commons-lang} ${commons-collections} \
-    ${commons-configuration}
+    ${mina-filter-ssl} ${commons-beanutils-core} ${commons-codec} \ 
+    ${commons-lang} ${commons-collections} ${commons-configuration} \
+    ${commons-digester}
 client.libs=${common.libs}  ${geronimo-jms}
 tools.libs=${client.libs}
 broker.libs=${common.libs} ${commons-cli} ${commons-logging} ${log4j} \

Added: qpid/trunk/qpid/java/lib/commons-beanutils-core-1.8.0.jar
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/lib/commons-beanutils-core-1.8.0.jar?rev=747363&view=auto
==============================================================================
Files qpid/trunk/qpid/java/lib/commons-beanutils-core-1.8.0.jar (added) and qpid/trunk/qpid/java/lib/commons-beanutils-core-1.8.0.jar
Tue Feb 24 13:02:30 2009 differ

Added: qpid/trunk/qpid/java/lib/commons-configuration-1.6.jar
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/lib/commons-configuration-1.6.jar?rev=747363&view=auto
==============================================================================
Files qpid/trunk/qpid/java/lib/commons-configuration-1.6.jar (added) and qpid/trunk/qpid/java/lib/commons-configuration-1.6.jar
Tue Feb 24 13:02:30 2009 differ

Added: qpid/trunk/qpid/java/lib/commons-digester-1.8.1.jar
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/lib/commons-digester-1.8.1.jar?rev=747363&view=auto
==============================================================================
Files qpid/trunk/qpid/java/lib/commons-digester-1.8.1.jar (added) and qpid/trunk/qpid/java/lib/commons-digester-1.8.1.jar
Tue Feb 24 13:02:30 2009 differ



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message