[jboss-cvs] JBoss Messaging SVN: r3512 - in trunk: src/main/org/jboss/jms/server and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 17 09:07:32 EST 2007


Author: ataylor
Date: 2007-12-17 09:07:31 -0500 (Mon, 17 Dec 2007)
New Revision: 3512

Added:
   trunk/tests/src/org/jboss/jms/
   trunk/tests/src/org/jboss/jms/server/
   trunk/tests/src/org/jboss/jms/server/test/
   trunk/tests/src/org/jboss/jms/server/test/unit/
   trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java
Modified:
   trunk/src/etc/server/default/deploy/jbm-configuration.xml
   trunk/src/main/org/jboss/jms/server/Configuration.java
Log:
configuration test and fixes

Modified: trunk/src/etc/server/default/deploy/jbm-configuration.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-configuration.xml	2007-12-17 09:45:46 UTC (rev 3511)
+++ trunk/src/etc/server/default/deploy/jbm-configuration.xml	2007-12-17 14:07:31 UTC (rev 3512)
@@ -13,7 +13,7 @@
          <role name="guest" read="true" write="true" create="true"/>
       </default-security-config>
       <!-- The default Dead Letter Queue (DLQ) to use for destinations. This can be overridden on a per destinatin basis -->
-      <defaul-dlq>DLQ</defaul-dlq>
+      <default-dlq>DLQ</default-dlq>
       <!-- The default maximum number of times to attempt delivery of a message before sending to the DLQ (if configured).
 This can be overridden on a per destinatin basis -->
       <default-max-delivery-attempts>10</default-max-delivery-attempts>
@@ -47,7 +47,7 @@
 
       <!-- The password used by the message sucker connections to create connections.
            THIS SHOULD ALWAYS BE CHANGED AT INSTALL TIME TO SECURE SYSTEM
-      <suckerPassword></suckerPassword>
+      <sucker-password></sucker-password>
       -->
       <strict-tck>false</strict-tck>
       <post-office-name>JMS post office</post-office-name>

Modified: trunk/src/main/org/jboss/jms/server/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/Configuration.java	2007-12-17 09:45:46 UTC (rev 3511)
+++ trunk/src/main/org/jboss/jms/server/Configuration.java	2007-12-17 14:07:31 UTC (rev 3512)
@@ -107,6 +107,9 @@
 
    private Integer _remotingBindAddress;
 
+   //default confog file location
+   private String configurationUrl = "jbm-configuration.xml";
+
    public void start() throws Exception
    {
       propertyChangeSupport = new PropertyChangeSupport(this);
@@ -114,7 +117,7 @@
       _strictTckProperty = "true".equalsIgnoreCase(System.getProperty("jboss.messaging.stricttck"));
       _useJGroupsWorkaround = "true".equals(System.getProperty("jboss.messaging.usejgroupsworkaround"));
 
-      URL url = getClass().getClassLoader().getResource("jbm-configuration.xml");
+      URL url = getClass().getClassLoader().getResource(configurationUrl);
       Element e = XMLUtil.urlToElement(url);
       _serverPeerID = getInteger(e, "server-peer-id", _serverPeerID);
       _defaultQueueJNDIContext = getString(e, "default-queue-jndi-context", _defaultQueueJNDIContext);
@@ -552,4 +555,15 @@
    {
       this._remotingBindAddress = remotingBindAddress;
    }
+
+
+   public String getConfigurationUrl()
+   {
+      return configurationUrl;
+   }
+
+   public void setConfigurationUrl(String configurationUrl)
+   {
+      this.configurationUrl = configurationUrl;
+   }
 }

Added: trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java
===================================================================
--- trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java	2007-12-17 14:07:31 UTC (rev 3512)
@@ -0,0 +1,248 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.jms.server.test.unit;
+
+import junit.framework.TestCase;
+import org.jboss.jms.server.Configuration;
+import org.jboss.jms.server.security.Role;
+
+import java.util.HashSet;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeEvent;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class ConfigurationTest extends TestCase
+{
+   private Configuration configuration;
+
+   protected void setUp() throws Exception
+   {
+      configuration = new Configuration();
+      configuration.setConfigurationUrl("ConfigurationTest-config.xml");
+      configuration.start();
+   }
+
+
+   protected void tearDown() throws Exception
+   {
+      configuration = null;
+   }
+
+   public void testSetServerPeerId() throws Exception
+   {
+      assertEquals("failed to set ServerPeerId", new Integer(10), configuration.getServerPeerID());
+   }
+
+   public void testSetDefaultQueueJndiContext() throws Exception
+   {
+      assertEquals("failed to set default queue jndi context", "/queuetest", configuration.getDefaultQueueJNDIContext());
+   }
+
+   public void testSetDefaultTopicJndiContext() throws Exception
+   {
+      assertEquals("failed to set default topic jndi context", "/topictest", configuration.getDefaultTopicJNDIContext());
+   }
+
+   public void testSetSecurityDomain() throws Exception
+   {
+      assertEquals("failed to set security domain", "java:/jaas/messagingtest", configuration.getSecurityDomain());
+   }
+
+   public void testSetDefaultSecurity() throws Exception
+   {
+      assertEquals("not enough entries should be 4", 4, configuration.getSecurityConfig().size());
+      HashSet<Role> roles = configuration.getSecurityConfig();
+      for (Role role : roles)
+      {
+         if ("guest1".equals(role.getName()))
+         {
+            assertEquals("read configured incorrectly", true, role.isRead());
+            assertEquals("write configured incorrectl", true, role.isWrite());
+            assertEquals("create configured incorrectl", true, role.isCreate());
+         }
+         else if ("guest2".equals(role.getName()))
+         {
+            assertEquals("read configured incorrectly", true, role.isRead());
+            assertEquals("write configured incorrectl", true, role.isWrite());
+            assertEquals("create configured incorrectl", false, role.isCreate());
+         }
+         else if ("guest3".equals(role.getName()))
+         {
+            assertEquals("read configured incorrectly", true, role.isRead());
+            assertEquals("write configured incorrectl", false, role.isWrite());
+            assertEquals("create configured incorrectl", false, role.isCreate());
+         }
+         else if ("guest4".equals(role.getName()))
+         {
+            assertEquals("read configured incorrectly", false, role.isRead());
+            assertEquals("write configured incorrectl", false, role.isWrite());
+            assertEquals("create configured incorrectl", false, role.isCreate());
+         }
+         else
+         {
+            fail("not all roles names configured properly:" + role);
+         }
+      }
+   }
+
+   public void testSetDLQ() throws Exception
+   {
+      assertEquals("failed to set DLQ", "DLQtest", configuration.getDefaultDLQ());
+   }
+
+   public void testSetDefMaxDelAtt() throws Exception
+   {
+      assertEquals("failed to set Default max delivery attempts", new Integer(100), configuration.getDefaultMaxDeliveryAttempts());
+   }
+
+   public void testSetExpiryQueue() throws Exception
+   {
+      assertEquals("failed to set DLQ", "ExpiryQueuetest", configuration.getDefaultExpiryQueue());
+   }
+
+   public void testSetDefaultRedeliveryDelay() throws Exception
+   {
+      assertEquals("failed to set Default redeliver delay", 10, configuration.getDefaultRedeliveryDelay());
+   }
+
+   public void testSetMessageCounterSamplePeriod() throws Exception
+   {
+      assertEquals("failed to set Message Counter sample period", 50000, configuration.getMessageCounterSamplePeriod());
+   }
+
+   public void testSetFailoverStartTimeout() throws Exception
+   {
+      assertEquals("failed to set failover start timeout", new Long(600000), configuration.getFailoverStartTimeout());
+   }
+
+   public void testSetFailoverCompleteTimeout() throws Exception
+   {
+      assertEquals("failed to set failover complete timeout", new Long(900000), configuration.getFailoverCompleteTimeout());
+   }
+
+   public void testSetDefaultMessageCounterHistory() throws Exception
+   {
+      assertEquals("failed to set default message counter history", new Integer(21), configuration.getDefaultMessageCounterHistoryDayLimit());
+   }
+
+   public void testSetClusterPollCFName() throws Exception
+   {
+      assertEquals("failed to set Cluster pull cf name", "jboss.messaging.connectionfactory:service=ClusterPullConnectionFactorytest", configuration.getClusterPullConnectionFactoryName());
+   }
+
+   public void testSetUseXAForMessagePull() throws Exception
+   {
+      assertEquals("failed to set use xa for message pull", Boolean.FALSE, configuration.isUseXAForMessagePull());
+   }
+
+   public void testSetPreserveOrdering() throws Exception
+   {
+      assertEquals("failed to set use preserve ordering", Boolean.TRUE, configuration.isDefaultPreserveOrdering());
+   }
+
+   public void testSetRecoveryDelTimeout() throws Exception
+   {
+      assertEquals("failed to set recovery deliveries timeout", new Long(600000), configuration.getRecoverDeliveriesTimeout());
+   }
+
+   public void testSetSuckerPassword() throws Exception
+   {
+      assertEquals("failed to set sucker password", "suckaaa", configuration.getSuckerPassword());
+   }
+
+   public void testSetStrictTck() throws Exception
+   {
+      assertEquals("failed to set strict tck", Boolean.TRUE, configuration.isStrictTck());
+   }
+
+   public void testSetClustered() throws Exception
+   {
+      assertEquals("failed to set clustered", Boolean.TRUE, configuration.isClustered());
+   }
+
+   public void testSetGroupName() throws Exception
+   {
+      assertEquals("failed to set group name", "MessagingPostOfficetest", configuration.getGroupName());
+   }
+
+   public void testSetStateTimeout() throws Exception
+   {
+      assertEquals("failed to set state timeout", new Long(10000), configuration.getStateTimeout());
+   }
+
+   public void testSetCastTimeout() throws Exception
+   {
+      assertEquals("failed to set cast timeout", new Long(10000), configuration.getCastTimeout());
+   }
+
+   public void testSetControlChannelName() throws Exception
+   {
+      assertEquals("failed to set control channel name", "udp-synctest", configuration.getControlChannelName());
+   }
+
+   public void testSetDateChannelName() throws Exception
+   {
+      assertEquals("failed to set data channel name", "udptest", configuration.getDataChannelName());
+   }
+
+   public void testSetChannelPartitionName() throws Exception
+   {
+      assertEquals("failed to set channel partition name", "JMStest", configuration.getChannelPartitionName());
+   }
+
+   public void testSetRemoteBindAddress() throws Exception
+   {
+      assertEquals("failed to set bin address", new Integer(10000), configuration.getRemotingBindAddress());
+   }
+
+   public void testPropertyChangeListener() throws Exception
+   {
+      MyListener listener = new MyListener();
+      configuration.addPropertyChangeListener(listener);
+      configuration.setSecurityConfig(null);
+      assertTrue("property change listener not fired", listener.isCalled());
+      listener.setCalled(false);
+      configuration.setMessageCounterSamplePeriod(1000000);
+      assertTrue("property change listener not fired", listener.isCalled());
+   }
+   class MyListener implements PropertyChangeListener
+   {
+      boolean called = false;
+
+      public boolean isCalled()
+      {
+         return called;
+      }
+
+      public void setCalled(boolean called)
+      {
+         this.called = called;
+      }
+
+      public void propertyChange(PropertyChangeEvent evt)
+      {
+         called = true;
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list