Author: borges
Date: 2011-10-21 11:34:53 -0400 (Fri, 21 Oct 2011)
New Revision: 11577
Added:
trunk/hornetq-core/src/test/java/org/hornetq/core/config/
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/ConfigurationImplTest.java
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/DefaultsFileConfigurationTest.java
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/FileConfigurationTest.java
Removed:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java
Modified:
trunk/hornetq-core/src/main/resources/schema/hornetq-configuration.xsd
trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml
Log:
Add "call-timeout" to cluster-configuration element to Configuration schema, and
fix test.
Also move files to hornet-core project.
Modified: trunk/hornetq-core/src/main/resources/schema/hornetq-configuration.xsd
===================================================================
--- trunk/hornetq-core/src/main/resources/schema/hornetq-configuration.xsd 2011-10-21
15:34:20 UTC (rev 11576)
+++ trunk/hornetq-core/src/main/resources/schema/hornetq-configuration.xsd 2011-10-21
15:34:53 UTC (rev 11577)
@@ -364,6 +364,7 @@
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0"
name="confirmation-window-size" type="xsd:int">
</xsd:element>
+ <xsd:element maxOccurs="1" minOccurs="0"
name="call-timeout" type="xsd:long"/>
<xsd:choice>
<xsd:element maxOccurs="1" minOccurs="0"
name="static-connectors">
<xsd:complexType>
Copied:
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/ConfigurationImplTest.java
(from rev 11576,
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java)
===================================================================
---
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/ConfigurationImplTest.java
(rev 0)
+++
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/ConfigurationImplTest.java 2011-10-21
15:34:53 UTC (rev 11577)
@@ -0,0 +1,560 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.config.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import junit.framework.Assert;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.journal.impl.JournalConstants;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.tests.util.RandomUtil;
+import org.hornetq.tests.util.UnitTestCase;
+
+/**
+ *
+ * A ConfigurationImplTest
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ *
+ */
+public class ConfigurationImplTest extends UnitTestCase
+{
+ protected Configuration conf;
+
+ public void testDefaults()
+ {
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTERED, conf.isClustered());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SHARED_STORE, conf.isSharedStore());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ conf.getScheduledThreadPoolMaxSize());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_INVALIDATION_INTERVAL,
+ conf.getSecurityInvalidationInterval());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED,
conf.isSecurityEnabled());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_LOG_DELEGATE_FACTORY_CLASS_NAME,
+ conf.getLogDelegateFactoryClassName());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_BINDINGS_DIRECTORY,
conf.getBindingsDirectory());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_BINDINGS_DIR,
conf.isCreateBindingsDir());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_DIR,
conf.getJournalDirectory());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_JOURNAL_DIR,
conf.isCreateJournalDir());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_TYPE,
conf.getJournalType());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_TRANSACTIONAL,
conf.isJournalSyncTransactional());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL,
+ conf.isJournalSyncNonTransactional());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE,
conf.getJournalFileSize());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES,
conf.getJournalMinFiles());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_AIO,
conf.getJournalMaxIO_AIO());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_NIO,
conf.getJournalMaxIO_NIO());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_WILDCARD_ROUTING_ENABLED,
conf.isWildcardRoutingEnabled());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT,
conf.getTransactionTimeout());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD,
conf.getMessageExpiryScanPeriod()); // OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY,
+ conf.getMessageExpiryThreadPriority()); // OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD,
+ conf.getTransactionTimeoutScanPeriod()); // OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS,
conf.getManagementAddress()); // OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS,
+ conf.getManagementNotificationAddress()); // OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_USER, conf.getClusterUser());
// OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD,
conf.getClusterPassword()); // OK
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSISTENCE_ENABLED,
conf.isPersistenceEnabled());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_FILE_DEPLOYMENT_ENABLED,
conf.isFileDeploymentEnabled());
+
Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
+ conf.isPersistDeliveryCountBeforeDelivery());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_FILE_DEPLOYER_SCAN_PERIOD,
conf.getFileDeployerScanPeriod());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
conf.getThreadPoolMaxSize());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JMX_MANAGEMENT_ENABLED,
conf.isJMXManagementEnabled());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CONNECTION_TTL_OVERRIDE,
conf.getConnectionTTLOverride());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_ASYNC_CONNECTION_EXECUTION_ENABLED,
+ conf.isAsyncConnectionExecutionEnabled());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_PAGING_DIR,
conf.getPagingDirectory());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_LARGE_MESSAGES_DIR,
conf.getLargeMessagesDirectory());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE,
conf.getJournalCompactPercentage());
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO,
conf.getJournalBufferTimeout_AIO());
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO,
conf.getJournalBufferTimeout_NIO());
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
conf.getJournalBufferSize_AIO());
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO,
conf.getJournalBufferSize_NIO());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_LOG_WRITE_RATE,
conf.isLogJournalWriteRate());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_PERF_BLAST_PAGES,
conf.getJournalPerfBlastPages());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_ENABLED,
conf.isMessageCounterEnabled());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_MAX_DAY_HISTORY,
+ conf.getMessageCounterMaxDayHistory());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_SAMPLE_PERIOD,
conf.getMessageCounterSamplePeriod());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_ID_CACHE_SIZE,
conf.getIDCacheSize());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSIST_ID_CACHE,
conf.isPersistIDCache());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SERVER_DUMP_INTERVAL,
conf.getServerDumpInterval());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MEMORY_WARNING_THRESHOLD,
conf.getMemoryWarningThreshold());
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MEMORY_MEASURE_INTERVAL,
conf.getMemoryMeasureInterval());
+ }
+
+ public void testSetGetAttributes()
+ {
+ for (int j = 0; j < 100; j++)
+ {
+ boolean b = RandomUtil.randomBoolean();
+ conf.setClustered(b);
+ Assert.assertEquals(b, conf.isClustered());
+
+ b = RandomUtil.randomBoolean();
+ conf.setBackup(b);
+ Assert.assertEquals(b, conf.isBackup());
+
+ b = RandomUtil.randomBoolean();
+ conf.setSharedStore(b);
+ Assert.assertEquals(b, conf.isSharedStore());
+
+ int i = RandomUtil.randomInt();
+ conf.setScheduledThreadPoolMaxSize(i);
+ Assert.assertEquals(i, conf.getScheduledThreadPoolMaxSize());
+
+ long l = RandomUtil.randomLong();
+ conf.setSecurityInvalidationInterval(l);
+ Assert.assertEquals(l, conf.getSecurityInvalidationInterval());
+
+ b = RandomUtil.randomBoolean();
+ conf.setSecurityEnabled(b);
+ Assert.assertEquals(b, conf.isSecurityEnabled());
+
+ String s = RandomUtil.randomString();
+ conf.setBindingsDirectory(s);
+ Assert.assertEquals(s, conf.getBindingsDirectory());
+
+ b = RandomUtil.randomBoolean();
+ conf.setCreateBindingsDir(b);
+ Assert.assertEquals(b, conf.isCreateBindingsDir());
+
+ s = RandomUtil.randomString();
+ conf.setJournalDirectory(s);
+ Assert.assertEquals(s, conf.getJournalDirectory());
+
+ b = RandomUtil.randomBoolean();
+ conf.setCreateJournalDir(b);
+ Assert.assertEquals(b, conf.isCreateJournalDir());
+
+ i = RandomUtil.randomInt() % 2;
+ JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
+ conf.setJournalType(journal);
+ Assert.assertEquals(journal, conf.getJournalType());
+
+ b = RandomUtil.randomBoolean();
+ conf.setJournalSyncTransactional(b);
+ Assert.assertEquals(b, conf.isJournalSyncTransactional());
+
+ b = RandomUtil.randomBoolean();
+ conf.setJournalSyncNonTransactional(b);
+ Assert.assertEquals(b, conf.isJournalSyncNonTransactional());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalFileSize(i);
+ Assert.assertEquals(i, conf.getJournalFileSize());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalMinFiles(i);
+ Assert.assertEquals(i, conf.getJournalMinFiles());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalMaxIO_AIO(i);
+ Assert.assertEquals(i, conf.getJournalMaxIO_AIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalMaxIO_NIO(i);
+ Assert.assertEquals(i, conf.getJournalMaxIO_NIO());
+
+ s = RandomUtil.randomString();
+ conf.setManagementAddress(new SimpleString(s));
+ Assert.assertEquals(s, conf.getManagementAddress().toString());
+
+ i = RandomUtil.randomInt();
+ conf.setMessageExpiryThreadPriority(i);
+ Assert.assertEquals(i, conf.getMessageExpiryThreadPriority());
+
+ l = RandomUtil.randomLong();
+ conf.setMessageExpiryScanPeriod(l);
+ Assert.assertEquals(l, conf.getMessageExpiryScanPeriod());
+
+ b = RandomUtil.randomBoolean();
+ conf.setPersistDeliveryCountBeforeDelivery(b);
+ Assert.assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
+
+ b = RandomUtil.randomBoolean();
+ conf.setEnabledAsyncConnectionExecution(b);
+ Assert.assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
+
+ b = RandomUtil.randomBoolean();
+ conf.setFileDeploymentEnabled(b);
+ Assert.assertEquals(b, conf.isFileDeploymentEnabled());
+
+ b = RandomUtil.randomBoolean();
+ conf.setPersistenceEnabled(b);
+ Assert.assertEquals(b, conf.isPersistenceEnabled());
+
+ b = RandomUtil.randomBoolean();
+ conf.setJMXManagementEnabled(b);
+ Assert.assertEquals(b, conf.isJMXManagementEnabled());
+
+ l = RandomUtil.randomLong();
+ conf.setFileDeployerScanPeriod(l);
+ Assert.assertEquals(l, conf.getFileDeployerScanPeriod());
+
+ l = RandomUtil.randomLong();
+ conf.setConnectionTTLOverride(l);
+ Assert.assertEquals(l, conf.getConnectionTTLOverride());
+
+ i = RandomUtil.randomInt();
+ conf.setThreadPoolMaxSize(i);
+ Assert.assertEquals(i, conf.getThreadPoolMaxSize());
+
+ SimpleString ss = RandomUtil.randomSimpleString();
+ conf.setManagementNotificationAddress(ss);
+ Assert.assertEquals(ss, conf.getManagementNotificationAddress());
+
+ s = RandomUtil.randomString();
+ conf.setClusterUser(s);
+ Assert.assertEquals(s, conf.getClusterUser());
+
+ i = RandomUtil.randomInt();
+ conf.setIDCacheSize(i);
+ Assert.assertEquals(i, conf.getIDCacheSize());
+
+ b = RandomUtil.randomBoolean();
+ conf.setPersistIDCache(b);
+ Assert.assertEquals(b, conf.isPersistIDCache());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalCompactMinFiles(i);
+ Assert.assertEquals(i, conf.getJournalCompactMinFiles());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalCompactPercentage(i);
+ Assert.assertEquals(i, conf.getJournalCompactPercentage());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferSize_AIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferSize_AIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferTimeout_AIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferTimeout_AIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferSize_NIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferSize_NIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferTimeout_NIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferTimeout_NIO());
+
+ b = RandomUtil.randomBoolean();
+ conf.setLogJournalWriteRate(b);
+ Assert.assertEquals(b, conf.isLogJournalWriteRate());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalPerfBlastPages(i);
+ Assert.assertEquals(i, conf.getJournalPerfBlastPages());
+
+ l = RandomUtil.randomLong();
+ conf.setServerDumpInterval(l);
+ Assert.assertEquals(l, conf.getServerDumpInterval());
+
+ s = RandomUtil.randomString();
+ conf.setPagingDirectory(s);
+ Assert.assertEquals(s, conf.getPagingDirectory());
+
+ s = RandomUtil.randomString();
+ conf.setLargeMessagesDirectory(s);
+ Assert.assertEquals(s, conf.getLargeMessagesDirectory());
+
+ b = RandomUtil.randomBoolean();
+ conf.setWildcardRoutingEnabled(b);
+ Assert.assertEquals(b, conf.isWildcardRoutingEnabled());
+
+ l = RandomUtil.randomLong();
+ conf.setTransactionTimeout(l);
+ Assert.assertEquals(l, conf.getTransactionTimeout());
+
+ b = RandomUtil.randomBoolean();
+ conf.setMessageCounterEnabled(b);
+ Assert.assertEquals(b, conf.isMessageCounterEnabled());
+
+ l = RandomUtil.randomPositiveLong();
+ conf.setMessageCounterSamplePeriod(l);
+ Assert.assertEquals(l, conf.getMessageCounterSamplePeriod());
+
+ i = RandomUtil.randomInt();
+ conf.setMessageCounterMaxDayHistory(i);
+ Assert.assertEquals(i, conf.getMessageCounterMaxDayHistory());
+
+ l = RandomUtil.randomLong();
+ conf.setTransactionTimeoutScanPeriod(l);
+ Assert.assertEquals(l, conf.getTransactionTimeoutScanPeriod());
+
+ s = RandomUtil.randomString();
+ conf.setClusterPassword(s);
+ Assert.assertEquals(s, conf.getClusterPassword());
+ }
+ }
+
+ public void testGetSetInterceptors()
+ {
+ final String name1 = "uqwyuqywuy";
+ final String name2 = "yugyugyguyg";
+
+ conf.getInterceptorClassNames().add(name1);
+ conf.getInterceptorClassNames().add(name2);
+
+ Assert.assertTrue(conf.getInterceptorClassNames().contains(name1));
+ Assert.assertTrue(conf.getInterceptorClassNames().contains(name2));
+ Assert.assertFalse(conf.getInterceptorClassNames().contains("iijij"));
+ }
+
+ public void testSerialize() throws Exception
+ {
+ boolean b = RandomUtil.randomBoolean();
+ conf.setClustered(b);
+ Assert.assertEquals(b, conf.isClustered());
+
+ b = RandomUtil.randomBoolean();
+ conf.setBackup(b);
+ Assert.assertEquals(b, conf.isBackup());
+
+ b = RandomUtil.randomBoolean();
+ conf.setSharedStore(b);
+
+ int i = RandomUtil.randomInt();
+ conf.setScheduledThreadPoolMaxSize(i);
+ Assert.assertEquals(i, conf.getScheduledThreadPoolMaxSize());
+
+ long l = RandomUtil.randomLong();
+ conf.setSecurityInvalidationInterval(l);
+ Assert.assertEquals(l, conf.getSecurityInvalidationInterval());
+
+ b = RandomUtil.randomBoolean();
+ conf.setSecurityEnabled(b);
+ Assert.assertEquals(b, conf.isSecurityEnabled());
+
+ String s = RandomUtil.randomString();
+ conf.setBindingsDirectory(s);
+ Assert.assertEquals(s, conf.getBindingsDirectory());
+
+ b = RandomUtil.randomBoolean();
+ conf.setCreateBindingsDir(b);
+ Assert.assertEquals(b, conf.isCreateBindingsDir());
+
+ s = RandomUtil.randomString();
+ conf.setJournalDirectory(s);
+ Assert.assertEquals(s, conf.getJournalDirectory());
+
+ b = RandomUtil.randomBoolean();
+ conf.setCreateJournalDir(b);
+ Assert.assertEquals(b, conf.isCreateJournalDir());
+
+ i = RandomUtil.randomInt() % 2;
+ JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
+ conf.setJournalType(journal);
+ Assert.assertEquals(journal, conf.getJournalType());
+
+ b = RandomUtil.randomBoolean();
+ conf.setJournalSyncTransactional(b);
+ Assert.assertEquals(b, conf.isJournalSyncTransactional());
+
+ b = RandomUtil.randomBoolean();
+ conf.setJournalSyncNonTransactional(b);
+ Assert.assertEquals(b, conf.isJournalSyncNonTransactional());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalFileSize(i);
+ Assert.assertEquals(i, conf.getJournalFileSize());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalMinFiles(i);
+ Assert.assertEquals(i, conf.getJournalMinFiles());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalMaxIO_AIO(i);
+ Assert.assertEquals(i, conf.getJournalMaxIO_AIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalMaxIO_NIO(i);
+ Assert.assertEquals(i, conf.getJournalMaxIO_NIO());
+
+ s = RandomUtil.randomString();
+ conf.setManagementAddress(new SimpleString(s));
+ Assert.assertEquals(s, conf.getManagementAddress().toString());
+
+ i = RandomUtil.randomInt();
+ conf.setMessageExpiryThreadPriority(i);
+ Assert.assertEquals(i, conf.getMessageExpiryThreadPriority());
+
+ l = RandomUtil.randomLong();
+ conf.setMessageExpiryScanPeriod(l);
+ Assert.assertEquals(l, conf.getMessageExpiryScanPeriod());
+
+ b = RandomUtil.randomBoolean();
+ conf.setPersistDeliveryCountBeforeDelivery(b);
+ Assert.assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
+
+ b = RandomUtil.randomBoolean();
+ conf.setEnabledAsyncConnectionExecution(b);
+ Assert.assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
+
+ b = RandomUtil.randomBoolean();
+ conf.setFileDeploymentEnabled(b);
+ Assert.assertEquals(b, conf.isFileDeploymentEnabled());
+
+ b = RandomUtil.randomBoolean();
+ conf.setPersistenceEnabled(b);
+ Assert.assertEquals(b, conf.isPersistenceEnabled());
+
+ b = RandomUtil.randomBoolean();
+ conf.setJMXManagementEnabled(b);
+ Assert.assertEquals(b, conf.isJMXManagementEnabled());
+
+ l = RandomUtil.randomLong();
+ conf.setFileDeployerScanPeriod(l);
+ Assert.assertEquals(l, conf.getFileDeployerScanPeriod());
+
+ l = RandomUtil.randomLong();
+ conf.setConnectionTTLOverride(l);
+ Assert.assertEquals(l, conf.getConnectionTTLOverride());
+
+ i = RandomUtil.randomInt();
+ conf.setThreadPoolMaxSize(i);
+ Assert.assertEquals(i, conf.getThreadPoolMaxSize());
+
+
+ SimpleString ss = RandomUtil.randomSimpleString();
+ conf.setManagementNotificationAddress(ss);
+ Assert.assertEquals(ss, conf.getManagementNotificationAddress());
+
+ s = RandomUtil.randomString();
+ conf.setClusterUser(s);
+ Assert.assertEquals(s, conf.getClusterUser());
+
+ i = RandomUtil.randomInt();
+ conf.setIDCacheSize(i);
+ Assert.assertEquals(i, conf.getIDCacheSize());
+
+ b = RandomUtil.randomBoolean();
+ conf.setPersistIDCache(b);
+ Assert.assertEquals(b, conf.isPersistIDCache());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalCompactMinFiles(i);
+ Assert.assertEquals(i, conf.getJournalCompactMinFiles());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalCompactPercentage(i);
+ Assert.assertEquals(i, conf.getJournalCompactPercentage());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferSize_AIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferSize_AIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferTimeout_AIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferTimeout_AIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferSize_NIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferSize_NIO());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalBufferTimeout_NIO(i);
+ Assert.assertEquals(i, conf.getJournalBufferTimeout_NIO());
+
+ b = RandomUtil.randomBoolean();
+ conf.setLogJournalWriteRate(b);
+ Assert.assertEquals(b, conf.isLogJournalWriteRate());
+
+ i = RandomUtil.randomInt();
+ conf.setJournalPerfBlastPages(i);
+ Assert.assertEquals(i, conf.getJournalPerfBlastPages());
+
+ l = RandomUtil.randomLong();
+ conf.setServerDumpInterval(l);
+ Assert.assertEquals(l, conf.getServerDumpInterval());
+
+ s = RandomUtil.randomString();
+ conf.setPagingDirectory(s);
+ Assert.assertEquals(s, conf.getPagingDirectory());
+
+ s = RandomUtil.randomString();
+ conf.setLargeMessagesDirectory(s);
+ Assert.assertEquals(s, conf.getLargeMessagesDirectory());
+
+ b = RandomUtil.randomBoolean();
+ conf.setWildcardRoutingEnabled(b);
+ Assert.assertEquals(b, conf.isWildcardRoutingEnabled());
+
+ l = RandomUtil.randomLong();
+ conf.setTransactionTimeout(l);
+ Assert.assertEquals(l, conf.getTransactionTimeout());
+
+ b = RandomUtil.randomBoolean();
+ conf.setMessageCounterEnabled(b);
+ Assert.assertEquals(b, conf.isMessageCounterEnabled());
+
+ l = RandomUtil.randomPositiveLong();
+ conf.setMessageCounterSamplePeriod(l);
+ Assert.assertEquals(l, conf.getMessageCounterSamplePeriod());
+
+ i = RandomUtil.randomInt();
+ conf.setMessageCounterMaxDayHistory(i);
+ Assert.assertEquals(i, conf.getMessageCounterMaxDayHistory());
+
+ l = RandomUtil.randomLong();
+ conf.setTransactionTimeoutScanPeriod(l);
+ Assert.assertEquals(l, conf.getTransactionTimeoutScanPeriod());
+
+ s = RandomUtil.randomString();
+ conf.setClusterPassword(s);
+ Assert.assertEquals(s, conf.getClusterPassword());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(conf);
+ oos.flush();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ Configuration conf2 = (Configuration)ois.readObject();
+
+ Assert.assertTrue(conf.equals(conf2));
+ }
+
+ // Protected
----------------------------------------------------------------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ conf = createConfiguration();
+ }
+
+ protected Configuration createConfiguration() throws Exception
+ {
+ return new ConfigurationImpl();
+ }
+
+ // Private
--------------------------------------------------------------------------------------------
+
+}
Copied:
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/DefaultsFileConfigurationTest.java
(from rev 11576,
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java)
===================================================================
---
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/DefaultsFileConfigurationTest.java
(rev 0)
+++
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/DefaultsFileConfigurationTest.java 2011-10-21
15:34:53 UTC (rev 11577)
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.config.impl;
+
+import java.util.Collections;
+
+import junit.framework.Assert;
+
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.journal.impl.JournalConstants;
+
+/**
+ *
+ * A DefaultsFileConfigurationTest
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ * @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
+ *
+ */
+public class DefaultsFileConfigurationTest extends ConfigurationImplTest
+{
+ @Override
+ public void testDefaults()
+ {
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTERED, conf.isClustered());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SHARED_STORE, conf.isSharedStore());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ conf.getScheduledThreadPoolMaxSize());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
conf.getThreadPoolMaxSize());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_INVALIDATION_INTERVAL,
+ conf.getSecurityInvalidationInterval());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED,
conf.isSecurityEnabled());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JMX_MANAGEMENT_ENABLED,
conf.isJMXManagementEnabled());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JMX_DOMAIN, conf.getJMXDomain());
+
+ Assert.assertEquals(0, conf.getInterceptorClassNames().size());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CONNECTION_TTL_OVERRIDE,
conf.getConnectionTTLOverride());
+
+ Assert.assertEquals(0, conf.getAcceptorConfigurations().size());
+
+ Assert.assertEquals(Collections.emptyMap(), conf.getConnectorConfigurations());
+
+ Assert.assertEquals(Collections.emptyList(),
conf.getBroadcastGroupConfigurations());
+
+ Assert.assertEquals(Collections.emptyMap(),
conf.getDiscoveryGroupConfigurations());
+
+ Assert.assertEquals(Collections.emptyList(), conf.getBridgeConfigurations());
+
+ Assert.assertEquals(Collections.emptyList(), conf.getDivertConfigurations());
+
+ Assert.assertEquals(Collections.emptyList(), conf.getClusterConfigurations());
+
+ Assert.assertEquals(Collections.emptyList(), conf.getQueueConfigurations());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS,
conf.getManagementAddress());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS,
+ conf.getManagementNotificationAddress());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_USER,
conf.getClusterUser());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD,
conf.getClusterPassword());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_ID_CACHE_SIZE,
conf.getIDCacheSize());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSIST_ID_CACHE,
conf.isPersistIDCache());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_BINDINGS_DIRECTORY,
conf.getBindingsDirectory());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_DIR,
conf.getJournalDirectory());
+
+ Assert.assertEquals(getDefaultJournalType(), conf.getJournalType());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_TRANSACTIONAL,
conf.isJournalSyncTransactional());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL,
+ conf.isJournalSyncNonTransactional());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE,
conf.getJournalFileSize());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_MIN_FILES,
conf.getJournalCompactMinFiles());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE,
conf.getJournalCompactPercentage());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES,
conf.getJournalMinFiles());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_AIO,
conf.getJournalMaxIO_AIO());
+
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO,
conf.getJournalBufferTimeout_AIO());
+
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
conf.getJournalBufferSize_AIO());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_NIO,
conf.getJournalMaxIO_NIO());
+
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO,
conf.getJournalBufferTimeout_NIO());
+
+ Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO,
conf.getJournalBufferSize_NIO());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_BINDINGS_DIR,
conf.isCreateBindingsDir());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_JOURNAL_DIR,
conf.isCreateJournalDir());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_PAGING_DIR,
conf.getPagingDirectory());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_LARGE_MESSAGES_DIR,
conf.getLargeMessagesDirectory());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_WILDCARD_ROUTING_ENABLED,
conf.isWildcardRoutingEnabled());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT,
conf.getTransactionTimeout());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_ENABLED,
conf.isMessageCounterEnabled());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD,
+ conf.getTransactionTimeoutScanPeriod());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD,
conf.getMessageExpiryScanPeriod());
+
+ Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY,
+ conf.getMessageExpiryThreadPriority());
+ }
+
+ // Protected
---------------------------------------------------------------------------------------------
+
+ @Override
+ protected Configuration createConfiguration() throws Exception
+ {
+ FileConfiguration fc = new FileConfiguration();
+
+ fc.setConfigurationUrl("ConfigurationTest-defaults.xml");
+
+ fc.start();
+
+ return fc;
+ }
+
+}
Copied:
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/FileConfigurationTest.java
(from rev 11576,
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java)
===================================================================
---
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/FileConfigurationTest.java
(rev 0)
+++
trunk/hornetq-core/src/test/java/org/hornetq/core/config/impl/FileConfigurationTest.java 2011-10-21
15:34:53 UTC (rev 11577)
@@ -0,0 +1,344 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.config.impl;
+
+import junit.framework.Assert;
+
+import org.hornetq.api.core.DiscoveryGroupConfiguration;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.config.BridgeConfiguration;
+import org.hornetq.core.config.BroadcastGroupConfiguration;
+import org.hornetq.core.config.ClusterConnectionConfiguration;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.DivertConfiguration;
+import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.security.Role;
+import org.hornetq.core.server.JournalType;
+
+/**
+ * @author <a href="ataylor(a)redhat.com">Andy Taylor</a>
+ * @author <a href="tim.fox(a)jboss.com">Tim Fox</a>
+ */
+public class FileConfigurationTest extends ConfigurationImplTest
+{
+ @Override
+ public void testDefaults()
+ {
+ // Check they match the values from the test file
+ Assert.assertEquals("SomeNameForUseOnTheApplicationServer",
conf.getName());
+ Assert.assertEquals(false, conf.isPersistenceEnabled());
+ Assert.assertEquals(true, conf.isFileDeploymentEnabled());
+ Assert.assertEquals(true, conf.isClustered());
+ Assert.assertEquals(true, conf.isFileDeploymentEnabled());
+ Assert.assertEquals(12345, conf.getScheduledThreadPoolMaxSize());
+ Assert.assertEquals(54321, conf.getThreadPoolMaxSize());
+ Assert.assertEquals(false, conf.isSecurityEnabled());
+ Assert.assertEquals(5423, conf.getSecurityInvalidationInterval());
+ Assert.assertEquals(true, conf.isWildcardRoutingEnabled());
+ Assert.assertEquals(new SimpleString("Giraffe"),
conf.getManagementAddress());
+ Assert.assertEquals(new SimpleString("Whatever"),
conf.getManagementNotificationAddress());
+ Assert.assertEquals("Frog", conf.getClusterUser());
+ Assert.assertEquals("Wombat", conf.getClusterPassword());
+ Assert.assertEquals(false, conf.isJMXManagementEnabled());
+ Assert.assertEquals("gro.qtenroh", conf.getJMXDomain());
+ Assert.assertEquals(true, conf.isMessageCounterEnabled());
+ Assert.assertEquals(5, conf.getMessageCounterMaxDayHistory());
+ Assert.assertEquals(123456, conf.getMessageCounterSamplePeriod());
+ Assert.assertEquals(12345, conf.getConnectionTTLOverride());
+ Assert.assertEquals(98765, conf.getTransactionTimeout());
+ Assert.assertEquals(56789, conf.getTransactionTimeoutScanPeriod());
+ Assert.assertEquals(10111213, conf.getMessageExpiryScanPeriod());
+ Assert.assertEquals("ocelot", conf.getLogDelegateFactoryClassName());
+ Assert.assertEquals(8, conf.getMessageExpiryThreadPriority());
+ Assert.assertEquals(127, conf.getIDCacheSize());
+ Assert.assertEquals(true, conf.isPersistIDCache());
+ Assert.assertEquals(true, conf.isBackup());
+ Assert.assertEquals(true, conf.isSharedStore());
+ Assert.assertEquals(true, conf.isPersistDeliveryCountBeforeDelivery());
+ Assert.assertEquals("pagingdir", conf.getPagingDirectory());
+ Assert.assertEquals("somedir", conf.getBindingsDirectory());
+ Assert.assertEquals(false, conf.isCreateBindingsDir());
+ Assert.assertEquals("somedir2", conf.getJournalDirectory());
+ Assert.assertEquals(false, conf.isCreateJournalDir());
+ Assert.assertEquals(JournalType.NIO, conf.getJournalType());
+ Assert.assertEquals(10000, conf.getJournalBufferSize_NIO());
+ Assert.assertEquals(1000, conf.getJournalBufferTimeout_NIO());
+ Assert.assertEquals(56546, conf.getJournalMaxIO_NIO());
+
+ Assert.assertEquals(false, conf.isJournalSyncTransactional());
+ Assert.assertEquals(true, conf.isJournalSyncNonTransactional());
+ Assert.assertEquals(12345678, conf.getJournalFileSize());
+ Assert.assertEquals(100, conf.getJournalMinFiles());
+ Assert.assertEquals(123, conf.getJournalCompactMinFiles());
+ Assert.assertEquals(33, conf.getJournalCompactPercentage());
+
+ Assert.assertEquals("largemessagesdir",
conf.getLargeMessagesDirectory());
+ Assert.assertEquals(95, conf.getMemoryWarningThreshold());
+
+ Assert.assertEquals(2, conf.getInterceptorClassNames().size());
+ Assert.assertTrue(conf.getInterceptorClassNames()
+
.contains("org.hornetq.tests.unit.core.config.impl.TestInterceptor1"));
+ Assert.assertTrue(conf.getInterceptorClassNames()
+
.contains("org.hornetq.tests.unit.core.config.impl.TestInterceptor2"));
+
+
+ Assert.assertEquals(2, conf.getConnectorConfigurations().size());
+
+ TransportConfiguration tc =
conf.getConnectorConfigurations().get("connector1");
+ Assert.assertNotNull(tc);
+
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestConnectorFactory1",
tc.getFactoryClassName());
+ Assert.assertEquals("v1", tc.getParams().get("a1"));
+ Assert.assertEquals("123", tc.getParams().get("a2"));
+ Assert.assertEquals("345", tc.getParams().get("a3"));
+ Assert.assertEquals("v4", tc.getParams().get("a4"));
+
+ tc = conf.getConnectorConfigurations().get("connector2");
+ Assert.assertNotNull(tc);
+
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestConnectorFactory2",
tc.getFactoryClassName());
+ Assert.assertEquals("w1", tc.getParams().get("b1"));
+ Assert.assertEquals("234", tc.getParams().get("b2"));
+
+ Assert.assertEquals(2, conf.getAcceptorConfigurations().size());
+ for (TransportConfiguration ac : conf.getAcceptorConfigurations())
+ {
+ if
(ac.getFactoryClassName().equals("org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory1"))
+ {
+
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory1",
+ ac.getFactoryClassName());
+ Assert.assertEquals("y1", ac.getParams().get("d1"));
+ Assert.assertEquals("456", ac.getParams().get("d2"));
+ }
+ else
+ {
+
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory2",
+ ac.getFactoryClassName());
+ Assert.assertEquals("z1", ac.getParams().get("e1"));
+ Assert.assertEquals("567", ac.getParams().get("e2"));
+ }
+ }
+
+ Assert.assertEquals(2, conf.getBroadcastGroupConfigurations().size());
+ for (BroadcastGroupConfiguration bc : conf.getBroadcastGroupConfigurations())
+ {
+ if (bc.getName().equals("bg1"))
+ {
+ Assert.assertEquals("bg1", bc.getName());
+ Assert.assertEquals(10999, bc.getLocalBindPort());
+ Assert.assertEquals("192.168.0.120", bc.getGroupAddress());
+ Assert.assertEquals(11999, bc.getGroupPort());
+ Assert.assertEquals(12345, bc.getBroadcastPeriod());
+ Assert.assertEquals("connector1", bc.getConnectorInfos().get(0));
+ }
+ else
+ {
+ Assert.assertEquals("bg2", bc.getName());
+ Assert.assertEquals(12999, bc.getLocalBindPort());
+ Assert.assertEquals("192.168.0.121", bc.getGroupAddress());
+ Assert.assertEquals(13999, bc.getGroupPort());
+ Assert.assertEquals(23456, bc.getBroadcastPeriod());
+ Assert.assertEquals("connector2", bc.getConnectorInfos().get(0));
+ }
+ }
+
+ Assert.assertEquals(2, conf.getDiscoveryGroupConfigurations().size());
+ DiscoveryGroupConfiguration dc =
conf.getDiscoveryGroupConfigurations().get("dg1");
+ Assert.assertEquals("dg1", dc.getName());
+ Assert.assertEquals("192.168.0.120", dc.getGroupAddress());
+ assertEquals("172.16.8.10", dc.getLocalBindAddress());
+ Assert.assertEquals(11999, dc.getGroupPort());
+ Assert.assertEquals(12345, dc.getRefreshTimeout());
+
+ dc = conf.getDiscoveryGroupConfigurations().get("dg2");
+ Assert.assertEquals("dg2", dc.getName());
+ Assert.assertEquals("192.168.0.121", dc.getGroupAddress());
+ assertEquals("172.16.8.11", dc.getLocalBindAddress());
+ Assert.assertEquals(12999, dc.getGroupPort());
+ Assert.assertEquals(23456, dc.getRefreshTimeout());
+
+ Assert.assertEquals(2, conf.getDivertConfigurations().size());
+ for (DivertConfiguration dic : conf.getDivertConfigurations())
+ {
+ if (dic.getName().equals("divert1"))
+ {
+ Assert.assertEquals("divert1", dic.getName());
+ Assert.assertEquals("routing-name1", dic.getRoutingName());
+ Assert.assertEquals("address1", dic.getAddress());
+ Assert.assertEquals("forwarding-address1",
dic.getForwardingAddress());
+ Assert.assertEquals("speed > 88", dic.getFilterString());
+ Assert.assertEquals("org.foo.Transformer",
dic.getTransformerClassName());
+ Assert.assertEquals(true, dic.isExclusive());
+ }
+ else
+ {
+ Assert.assertEquals("divert2", dic.getName());
+ Assert.assertEquals("routing-name2", dic.getRoutingName());
+ Assert.assertEquals("address2", dic.getAddress());
+ Assert.assertEquals("forwarding-address2",
dic.getForwardingAddress());
+ Assert.assertEquals("speed < 88", dic.getFilterString());
+ Assert.assertEquals("org.foo.Transformer2",
dic.getTransformerClassName());
+ Assert.assertEquals(false, dic.isExclusive());
+ }
+ }
+
+ Assert.assertEquals(2, conf.getBridgeConfigurations().size());
+ for (BridgeConfiguration bc : conf.getBridgeConfigurations())
+ {
+ if (bc.getName().equals("bridge1"))
+ {
+ Assert.assertEquals("bridge1", bc.getName());
+ Assert.assertEquals("queue1", bc.getQueueName());
+ Assert.assertEquals("bridge-forwarding-address1",
bc.getForwardingAddress());
+ Assert.assertEquals("sku > 1", bc.getFilterString());
+ Assert.assertEquals("org.foo.BridgeTransformer",
bc.getTransformerClassName());
+ Assert.assertEquals(3, bc.getRetryInterval());
+ Assert.assertEquals(0.2, bc.getRetryIntervalMultiplier());
+ Assert.assertEquals(2, bc.getReconnectAttempts());
+ Assert.assertEquals(true, bc.isUseDuplicateDetection());
+ Assert.assertEquals("connector1",
bc.getStaticConnectors().get(0));
+ Assert.assertEquals(null, bc.getDiscoveryGroupName());
+ }
+ else
+ {
+ Assert.assertEquals("bridge2", bc.getName());
+ Assert.assertEquals("queue2", bc.getQueueName());
+ Assert.assertEquals("bridge-forwarding-address2",
bc.getForwardingAddress());
+ Assert.assertEquals(null, bc.getFilterString());
+ Assert.assertEquals(null, bc.getTransformerClassName());
+ Assert.assertEquals(null, bc.getStaticConnectors());
+ Assert.assertEquals("dg1", bc.getDiscoveryGroupName());
+ }
+ }
+
+ Assert.assertEquals(2, conf.getClusterConfigurations().size());
+ for (ClusterConnectionConfiguration ccc : conf.getClusterConfigurations())
+ {
+ if (ccc.getName().equals("cluster-connection1"))
+ {
+ Assert.assertEquals("cluster-connection1", ccc.getName());
+ Assert.assertEquals("queues1", ccc.getAddress());
+ Assert.assertEquals(3, ccc.getRetryInterval());
+ Assert.assertEquals(true, ccc.isDuplicateDetection());
+ Assert.assertEquals(false, ccc.isForwardWhenNoConsumers());
+ Assert.assertEquals(1, ccc.getMaxHops());
+ Assert.assertEquals(123, ccc.getCallTimeout());
+ Assert.assertEquals("connector1",
ccc.getStaticConnectors().get(0));
+ Assert.assertEquals("connector2",
ccc.getStaticConnectors().get(1));
+ Assert.assertEquals(null, ccc.getDiscoveryGroupName());
+ }
+ else
+ {
+ Assert.assertEquals("cluster-connection2", ccc.getName());
+ Assert.assertEquals("queues2", ccc.getAddress());
+ Assert.assertEquals(4, ccc.getRetryInterval());
+ Assert.assertEquals(456, ccc.getCallTimeout());
+ Assert.assertEquals(false, ccc.isDuplicateDetection());
+ Assert.assertEquals(true, ccc.isForwardWhenNoConsumers());
+ Assert.assertEquals(2, ccc.getMaxHops());
+ Assert.assertEquals(null, ccc.getStaticConnectors());
+ Assert.assertEquals("dg1", ccc.getDiscoveryGroupName());
+ }
+ }
+
+
+ assertEquals(2, conf.getAddressesSettings().size());
+
+ assertTrue(conf.getAddressesSettings().get("a1") != null);
+ assertTrue(conf.getAddressesSettings().get("a2") != null);
+
+ assertEquals("a1.1",
conf.getAddressesSettings().get("a1").getDeadLetterAddress().toString());
+ assertEquals("a1.2",
conf.getAddressesSettings().get("a1").getExpiryAddress().toString());
+ assertEquals(1,
conf.getAddressesSettings().get("a1").getRedeliveryDelay());
+ assertEquals(81781728121878l,
conf.getAddressesSettings().get("a1").getMaxSizeBytes());
+ assertEquals(81738173872337l,
conf.getAddressesSettings().get("a1").getPageSizeBytes());
+ assertEquals(10,
conf.getAddressesSettings().get("a1").getPageCacheMaxSize());
+ assertEquals(4,
conf.getAddressesSettings().get("a1").getMessageCounterHistoryDayLimit());
+
+ assertEquals("a2.1",
conf.getAddressesSettings().get("a2").getDeadLetterAddress().toString());
+ assertEquals("a2.2",
conf.getAddressesSettings().get("a2").getExpiryAddress().toString());
+ assertEquals(5,
conf.getAddressesSettings().get("a2").getRedeliveryDelay());
+ assertEquals(932489234928324l,
conf.getAddressesSettings().get("a2").getMaxSizeBytes());
+ assertEquals(7126716262626l,
conf.getAddressesSettings().get("a2").getPageSizeBytes());
+ assertEquals(20,
conf.getAddressesSettings().get("a2").getPageCacheMaxSize());
+ assertEquals(8,
conf.getAddressesSettings().get("a2").getMessageCounterHistoryDayLimit());
+
+
+ assertEquals(2, conf.getQueueConfigurations().size());
+
+ assertEquals("queue1", conf.getQueueConfigurations().get(0).getName());
+ assertEquals("address1",
conf.getQueueConfigurations().get(0).getAddress());
+ assertEquals("color='red'",
conf.getQueueConfigurations().get(0).getFilterString());
+ assertEquals(false, conf.getQueueConfigurations().get(0).isDurable());
+
+ assertEquals("queue2", conf.getQueueConfigurations().get(1).getName());
+ assertEquals("address2",
conf.getQueueConfigurations().get(1).getAddress());
+ assertEquals("color='blue'",
conf.getQueueConfigurations().get(1).getFilterString());
+ assertEquals(false, conf.getQueueConfigurations().get(1).isDurable());
+
+ assertEquals(2, conf.getSecurityRoles().size());
+
+ assertTrue(conf.getSecurityRoles().containsKey("a1"));
+
+ assertTrue(conf.getSecurityRoles().containsKey("a2"));
+
+ Role a1Role = conf.getSecurityRoles().get("a1").toArray(new Role[1])[0];
+
+ assertFalse(a1Role.isSend());
+ assertFalse(a1Role.isConsume());
+ assertFalse(a1Role.isCreateDurableQueue());
+ assertFalse(a1Role.isDeleteDurableQueue());
+ assertTrue(a1Role.isCreateNonDurableQueue());
+ assertFalse(a1Role.isDeleteNonDurableQueue());
+ assertFalse(a1Role.isManage());
+
+ Role a2Role = conf.getSecurityRoles().get("a2").toArray(new Role[1])[0];
+
+ assertFalse(a2Role.isSend());
+ assertFalse(a2Role.isConsume());
+ assertFalse(a2Role.isCreateDurableQueue());
+ assertFalse(a2Role.isDeleteDurableQueue());
+ assertFalse(a2Role.isCreateNonDurableQueue());
+ assertTrue(a2Role.isDeleteNonDurableQueue());
+ assertFalse(a2Role.isManage());
+
+
+ }
+
+ public void testSetGetConfigurationURL()
+ {
+ final String file = "ghuuhhu";
+
+ FileConfiguration fc = new FileConfiguration();
+
+ fc.setConfigurationUrl(file);
+
+ Assert.assertEquals(file, fc.getConfigurationUrl());
+
+ }
+
+ // Protected
---------------------------------------------------------------------------------------------
+
+ @Override
+ protected Configuration createConfiguration() throws Exception
+ {
+ FileConfiguration fc = new FileConfiguration();
+
+ fc.setConfigurationUrl("ConfigurationTest-full-config.xml");
+
+ fc.start();
+
+ return fc;
+ }
+
+}
Deleted:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java
===================================================================
---
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java 2011-10-21
15:34:20 UTC (rev 11576)
+++
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java 2011-10-21
15:34:53 UTC (rev 11577)
@@ -1,560 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.config.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import junit.framework.Assert;
-
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.journal.impl.JournalConstants;
-import org.hornetq.core.server.JournalType;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- *
- * A ConfigurationImplTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class ConfigurationImplTest extends UnitTestCase
-{
- protected Configuration conf;
-
- public void testDefaults()
- {
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTERED, conf.isClustered());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SHARED_STORE, conf.isSharedStore());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
- conf.getScheduledThreadPoolMaxSize());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_INVALIDATION_INTERVAL,
- conf.getSecurityInvalidationInterval());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED,
conf.isSecurityEnabled());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_LOG_DELEGATE_FACTORY_CLASS_NAME,
- conf.getLogDelegateFactoryClassName());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_BINDINGS_DIRECTORY,
conf.getBindingsDirectory());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_BINDINGS_DIR,
conf.isCreateBindingsDir());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_DIR,
conf.getJournalDirectory());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_JOURNAL_DIR,
conf.isCreateJournalDir());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_TYPE,
conf.getJournalType());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_TRANSACTIONAL,
conf.isJournalSyncTransactional());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL,
- conf.isJournalSyncNonTransactional());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE,
conf.getJournalFileSize());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES,
conf.getJournalMinFiles());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_AIO,
conf.getJournalMaxIO_AIO());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_NIO,
conf.getJournalMaxIO_NIO());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_WILDCARD_ROUTING_ENABLED,
conf.isWildcardRoutingEnabled());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT,
conf.getTransactionTimeout());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD,
conf.getMessageExpiryScanPeriod()); // OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY,
- conf.getMessageExpiryThreadPriority()); // OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD,
- conf.getTransactionTimeoutScanPeriod()); // OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS,
conf.getManagementAddress()); // OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS,
- conf.getManagementNotificationAddress()); // OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_USER, conf.getClusterUser());
// OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD,
conf.getClusterPassword()); // OK
- Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSISTENCE_ENABLED,
conf.isPersistenceEnabled());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_FILE_DEPLOYMENT_ENABLED,
conf.isFileDeploymentEnabled());
-
Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
- conf.isPersistDeliveryCountBeforeDelivery());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_FILE_DEPLOYER_SCAN_PERIOD,
conf.getFileDeployerScanPeriod());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
conf.getThreadPoolMaxSize());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JMX_MANAGEMENT_ENABLED,
conf.isJMXManagementEnabled());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CONNECTION_TTL_OVERRIDE,
conf.getConnectionTTLOverride());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_ASYNC_CONNECTION_EXECUTION_ENABLED,
- conf.isAsyncConnectionExecutionEnabled());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_PAGING_DIR,
conf.getPagingDirectory());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_LARGE_MESSAGES_DIR,
conf.getLargeMessagesDirectory());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE,
conf.getJournalCompactPercentage());
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO,
conf.getJournalBufferTimeout_AIO());
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO,
conf.getJournalBufferTimeout_NIO());
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
conf.getJournalBufferSize_AIO());
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO,
conf.getJournalBufferSize_NIO());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_LOG_WRITE_RATE,
conf.isLogJournalWriteRate());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_PERF_BLAST_PAGES,
conf.getJournalPerfBlastPages());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_ENABLED,
conf.isMessageCounterEnabled());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_MAX_DAY_HISTORY,
- conf.getMessageCounterMaxDayHistory());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_SAMPLE_PERIOD,
conf.getMessageCounterSamplePeriod());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_ID_CACHE_SIZE,
conf.getIDCacheSize());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSIST_ID_CACHE,
conf.isPersistIDCache());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SERVER_DUMP_INTERVAL,
conf.getServerDumpInterval());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MEMORY_WARNING_THRESHOLD,
conf.getMemoryWarningThreshold());
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MEMORY_MEASURE_INTERVAL,
conf.getMemoryMeasureInterval());
- }
-
- public void testSetGetAttributes()
- {
- for (int j = 0; j < 100; j++)
- {
- boolean b = RandomUtil.randomBoolean();
- conf.setClustered(b);
- Assert.assertEquals(b, conf.isClustered());
-
- b = RandomUtil.randomBoolean();
- conf.setBackup(b);
- Assert.assertEquals(b, conf.isBackup());
-
- b = RandomUtil.randomBoolean();
- conf.setSharedStore(b);
- Assert.assertEquals(b, conf.isSharedStore());
-
- int i = RandomUtil.randomInt();
- conf.setScheduledThreadPoolMaxSize(i);
- Assert.assertEquals(i, conf.getScheduledThreadPoolMaxSize());
-
- long l = RandomUtil.randomLong();
- conf.setSecurityInvalidationInterval(l);
- Assert.assertEquals(l, conf.getSecurityInvalidationInterval());
-
- b = RandomUtil.randomBoolean();
- conf.setSecurityEnabled(b);
- Assert.assertEquals(b, conf.isSecurityEnabled());
-
- String s = RandomUtil.randomString();
- conf.setBindingsDirectory(s);
- Assert.assertEquals(s, conf.getBindingsDirectory());
-
- b = RandomUtil.randomBoolean();
- conf.setCreateBindingsDir(b);
- Assert.assertEquals(b, conf.isCreateBindingsDir());
-
- s = RandomUtil.randomString();
- conf.setJournalDirectory(s);
- Assert.assertEquals(s, conf.getJournalDirectory());
-
- b = RandomUtil.randomBoolean();
- conf.setCreateJournalDir(b);
- Assert.assertEquals(b, conf.isCreateJournalDir());
-
- i = RandomUtil.randomInt() % 2;
- JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
- conf.setJournalType(journal);
- Assert.assertEquals(journal, conf.getJournalType());
-
- b = RandomUtil.randomBoolean();
- conf.setJournalSyncTransactional(b);
- Assert.assertEquals(b, conf.isJournalSyncTransactional());
-
- b = RandomUtil.randomBoolean();
- conf.setJournalSyncNonTransactional(b);
- Assert.assertEquals(b, conf.isJournalSyncNonTransactional());
-
- i = RandomUtil.randomInt();
- conf.setJournalFileSize(i);
- Assert.assertEquals(i, conf.getJournalFileSize());
-
- i = RandomUtil.randomInt();
- conf.setJournalMinFiles(i);
- Assert.assertEquals(i, conf.getJournalMinFiles());
-
- i = RandomUtil.randomInt();
- conf.setJournalMaxIO_AIO(i);
- Assert.assertEquals(i, conf.getJournalMaxIO_AIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalMaxIO_NIO(i);
- Assert.assertEquals(i, conf.getJournalMaxIO_NIO());
-
- s = RandomUtil.randomString();
- conf.setManagementAddress(new SimpleString(s));
- Assert.assertEquals(s, conf.getManagementAddress().toString());
-
- i = RandomUtil.randomInt();
- conf.setMessageExpiryThreadPriority(i);
- Assert.assertEquals(i, conf.getMessageExpiryThreadPriority());
-
- l = RandomUtil.randomLong();
- conf.setMessageExpiryScanPeriod(l);
- Assert.assertEquals(l, conf.getMessageExpiryScanPeriod());
-
- b = RandomUtil.randomBoolean();
- conf.setPersistDeliveryCountBeforeDelivery(b);
- Assert.assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
-
- b = RandomUtil.randomBoolean();
- conf.setEnabledAsyncConnectionExecution(b);
- Assert.assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
-
- b = RandomUtil.randomBoolean();
- conf.setFileDeploymentEnabled(b);
- Assert.assertEquals(b, conf.isFileDeploymentEnabled());
-
- b = RandomUtil.randomBoolean();
- conf.setPersistenceEnabled(b);
- Assert.assertEquals(b, conf.isPersistenceEnabled());
-
- b = RandomUtil.randomBoolean();
- conf.setJMXManagementEnabled(b);
- Assert.assertEquals(b, conf.isJMXManagementEnabled());
-
- l = RandomUtil.randomLong();
- conf.setFileDeployerScanPeriod(l);
- Assert.assertEquals(l, conf.getFileDeployerScanPeriod());
-
- l = RandomUtil.randomLong();
- conf.setConnectionTTLOverride(l);
- Assert.assertEquals(l, conf.getConnectionTTLOverride());
-
- i = RandomUtil.randomInt();
- conf.setThreadPoolMaxSize(i);
- Assert.assertEquals(i, conf.getThreadPoolMaxSize());
-
- SimpleString ss = RandomUtil.randomSimpleString();
- conf.setManagementNotificationAddress(ss);
- Assert.assertEquals(ss, conf.getManagementNotificationAddress());
-
- s = RandomUtil.randomString();
- conf.setClusterUser(s);
- Assert.assertEquals(s, conf.getClusterUser());
-
- i = RandomUtil.randomInt();
- conf.setIDCacheSize(i);
- Assert.assertEquals(i, conf.getIDCacheSize());
-
- b = RandomUtil.randomBoolean();
- conf.setPersistIDCache(b);
- Assert.assertEquals(b, conf.isPersistIDCache());
-
- i = RandomUtil.randomInt();
- conf.setJournalCompactMinFiles(i);
- Assert.assertEquals(i, conf.getJournalCompactMinFiles());
-
- i = RandomUtil.randomInt();
- conf.setJournalCompactPercentage(i);
- Assert.assertEquals(i, conf.getJournalCompactPercentage());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferSize_AIO(i);
- Assert.assertEquals(i, conf.getJournalBufferSize_AIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferTimeout_AIO(i);
- Assert.assertEquals(i, conf.getJournalBufferTimeout_AIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferSize_NIO(i);
- Assert.assertEquals(i, conf.getJournalBufferSize_NIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferTimeout_NIO(i);
- Assert.assertEquals(i, conf.getJournalBufferTimeout_NIO());
-
- b = RandomUtil.randomBoolean();
- conf.setLogJournalWriteRate(b);
- Assert.assertEquals(b, conf.isLogJournalWriteRate());
-
- i = RandomUtil.randomInt();
- conf.setJournalPerfBlastPages(i);
- Assert.assertEquals(i, conf.getJournalPerfBlastPages());
-
- l = RandomUtil.randomLong();
- conf.setServerDumpInterval(l);
- Assert.assertEquals(l, conf.getServerDumpInterval());
-
- s = RandomUtil.randomString();
- conf.setPagingDirectory(s);
- Assert.assertEquals(s, conf.getPagingDirectory());
-
- s = RandomUtil.randomString();
- conf.setLargeMessagesDirectory(s);
- Assert.assertEquals(s, conf.getLargeMessagesDirectory());
-
- b = RandomUtil.randomBoolean();
- conf.setWildcardRoutingEnabled(b);
- Assert.assertEquals(b, conf.isWildcardRoutingEnabled());
-
- l = RandomUtil.randomLong();
- conf.setTransactionTimeout(l);
- Assert.assertEquals(l, conf.getTransactionTimeout());
-
- b = RandomUtil.randomBoolean();
- conf.setMessageCounterEnabled(b);
- Assert.assertEquals(b, conf.isMessageCounterEnabled());
-
- l = RandomUtil.randomPositiveLong();
- conf.setMessageCounterSamplePeriod(l);
- Assert.assertEquals(l, conf.getMessageCounterSamplePeriod());
-
- i = RandomUtil.randomInt();
- conf.setMessageCounterMaxDayHistory(i);
- Assert.assertEquals(i, conf.getMessageCounterMaxDayHistory());
-
- l = RandomUtil.randomLong();
- conf.setTransactionTimeoutScanPeriod(l);
- Assert.assertEquals(l, conf.getTransactionTimeoutScanPeriod());
-
- s = RandomUtil.randomString();
- conf.setClusterPassword(s);
- Assert.assertEquals(s, conf.getClusterPassword());
- }
- }
-
- public void testGetSetInterceptors()
- {
- final String name1 = "uqwyuqywuy";
- final String name2 = "yugyugyguyg";
-
- conf.getInterceptorClassNames().add(name1);
- conf.getInterceptorClassNames().add(name2);
-
- Assert.assertTrue(conf.getInterceptorClassNames().contains(name1));
- Assert.assertTrue(conf.getInterceptorClassNames().contains(name2));
- Assert.assertFalse(conf.getInterceptorClassNames().contains("iijij"));
- }
-
- public void testSerialize() throws Exception
- {
- boolean b = RandomUtil.randomBoolean();
- conf.setClustered(b);
- Assert.assertEquals(b, conf.isClustered());
-
- b = RandomUtil.randomBoolean();
- conf.setBackup(b);
- Assert.assertEquals(b, conf.isBackup());
-
- b = RandomUtil.randomBoolean();
- conf.setSharedStore(b);
-
- int i = RandomUtil.randomInt();
- conf.setScheduledThreadPoolMaxSize(i);
- Assert.assertEquals(i, conf.getScheduledThreadPoolMaxSize());
-
- long l = RandomUtil.randomLong();
- conf.setSecurityInvalidationInterval(l);
- Assert.assertEquals(l, conf.getSecurityInvalidationInterval());
-
- b = RandomUtil.randomBoolean();
- conf.setSecurityEnabled(b);
- Assert.assertEquals(b, conf.isSecurityEnabled());
-
- String s = RandomUtil.randomString();
- conf.setBindingsDirectory(s);
- Assert.assertEquals(s, conf.getBindingsDirectory());
-
- b = RandomUtil.randomBoolean();
- conf.setCreateBindingsDir(b);
- Assert.assertEquals(b, conf.isCreateBindingsDir());
-
- s = RandomUtil.randomString();
- conf.setJournalDirectory(s);
- Assert.assertEquals(s, conf.getJournalDirectory());
-
- b = RandomUtil.randomBoolean();
- conf.setCreateJournalDir(b);
- Assert.assertEquals(b, conf.isCreateJournalDir());
-
- i = RandomUtil.randomInt() % 2;
- JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
- conf.setJournalType(journal);
- Assert.assertEquals(journal, conf.getJournalType());
-
- b = RandomUtil.randomBoolean();
- conf.setJournalSyncTransactional(b);
- Assert.assertEquals(b, conf.isJournalSyncTransactional());
-
- b = RandomUtil.randomBoolean();
- conf.setJournalSyncNonTransactional(b);
- Assert.assertEquals(b, conf.isJournalSyncNonTransactional());
-
- i = RandomUtil.randomInt();
- conf.setJournalFileSize(i);
- Assert.assertEquals(i, conf.getJournalFileSize());
-
- i = RandomUtil.randomInt();
- conf.setJournalMinFiles(i);
- Assert.assertEquals(i, conf.getJournalMinFiles());
-
- i = RandomUtil.randomInt();
- conf.setJournalMaxIO_AIO(i);
- Assert.assertEquals(i, conf.getJournalMaxIO_AIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalMaxIO_NIO(i);
- Assert.assertEquals(i, conf.getJournalMaxIO_NIO());
-
- s = RandomUtil.randomString();
- conf.setManagementAddress(new SimpleString(s));
- Assert.assertEquals(s, conf.getManagementAddress().toString());
-
- i = RandomUtil.randomInt();
- conf.setMessageExpiryThreadPriority(i);
- Assert.assertEquals(i, conf.getMessageExpiryThreadPriority());
-
- l = RandomUtil.randomLong();
- conf.setMessageExpiryScanPeriod(l);
- Assert.assertEquals(l, conf.getMessageExpiryScanPeriod());
-
- b = RandomUtil.randomBoolean();
- conf.setPersistDeliveryCountBeforeDelivery(b);
- Assert.assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
-
- b = RandomUtil.randomBoolean();
- conf.setEnabledAsyncConnectionExecution(b);
- Assert.assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
-
- b = RandomUtil.randomBoolean();
- conf.setFileDeploymentEnabled(b);
- Assert.assertEquals(b, conf.isFileDeploymentEnabled());
-
- b = RandomUtil.randomBoolean();
- conf.setPersistenceEnabled(b);
- Assert.assertEquals(b, conf.isPersistenceEnabled());
-
- b = RandomUtil.randomBoolean();
- conf.setJMXManagementEnabled(b);
- Assert.assertEquals(b, conf.isJMXManagementEnabled());
-
- l = RandomUtil.randomLong();
- conf.setFileDeployerScanPeriod(l);
- Assert.assertEquals(l, conf.getFileDeployerScanPeriod());
-
- l = RandomUtil.randomLong();
- conf.setConnectionTTLOverride(l);
- Assert.assertEquals(l, conf.getConnectionTTLOverride());
-
- i = RandomUtil.randomInt();
- conf.setThreadPoolMaxSize(i);
- Assert.assertEquals(i, conf.getThreadPoolMaxSize());
-
-
- SimpleString ss = RandomUtil.randomSimpleString();
- conf.setManagementNotificationAddress(ss);
- Assert.assertEquals(ss, conf.getManagementNotificationAddress());
-
- s = RandomUtil.randomString();
- conf.setClusterUser(s);
- Assert.assertEquals(s, conf.getClusterUser());
-
- i = RandomUtil.randomInt();
- conf.setIDCacheSize(i);
- Assert.assertEquals(i, conf.getIDCacheSize());
-
- b = RandomUtil.randomBoolean();
- conf.setPersistIDCache(b);
- Assert.assertEquals(b, conf.isPersistIDCache());
-
- i = RandomUtil.randomInt();
- conf.setJournalCompactMinFiles(i);
- Assert.assertEquals(i, conf.getJournalCompactMinFiles());
-
- i = RandomUtil.randomInt();
- conf.setJournalCompactPercentage(i);
- Assert.assertEquals(i, conf.getJournalCompactPercentage());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferSize_AIO(i);
- Assert.assertEquals(i, conf.getJournalBufferSize_AIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferTimeout_AIO(i);
- Assert.assertEquals(i, conf.getJournalBufferTimeout_AIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferSize_NIO(i);
- Assert.assertEquals(i, conf.getJournalBufferSize_NIO());
-
- i = RandomUtil.randomInt();
- conf.setJournalBufferTimeout_NIO(i);
- Assert.assertEquals(i, conf.getJournalBufferTimeout_NIO());
-
- b = RandomUtil.randomBoolean();
- conf.setLogJournalWriteRate(b);
- Assert.assertEquals(b, conf.isLogJournalWriteRate());
-
- i = RandomUtil.randomInt();
- conf.setJournalPerfBlastPages(i);
- Assert.assertEquals(i, conf.getJournalPerfBlastPages());
-
- l = RandomUtil.randomLong();
- conf.setServerDumpInterval(l);
- Assert.assertEquals(l, conf.getServerDumpInterval());
-
- s = RandomUtil.randomString();
- conf.setPagingDirectory(s);
- Assert.assertEquals(s, conf.getPagingDirectory());
-
- s = RandomUtil.randomString();
- conf.setLargeMessagesDirectory(s);
- Assert.assertEquals(s, conf.getLargeMessagesDirectory());
-
- b = RandomUtil.randomBoolean();
- conf.setWildcardRoutingEnabled(b);
- Assert.assertEquals(b, conf.isWildcardRoutingEnabled());
-
- l = RandomUtil.randomLong();
- conf.setTransactionTimeout(l);
- Assert.assertEquals(l, conf.getTransactionTimeout());
-
- b = RandomUtil.randomBoolean();
- conf.setMessageCounterEnabled(b);
- Assert.assertEquals(b, conf.isMessageCounterEnabled());
-
- l = RandomUtil.randomPositiveLong();
- conf.setMessageCounterSamplePeriod(l);
- Assert.assertEquals(l, conf.getMessageCounterSamplePeriod());
-
- i = RandomUtil.randomInt();
- conf.setMessageCounterMaxDayHistory(i);
- Assert.assertEquals(i, conf.getMessageCounterMaxDayHistory());
-
- l = RandomUtil.randomLong();
- conf.setTransactionTimeoutScanPeriod(l);
- Assert.assertEquals(l, conf.getTransactionTimeoutScanPeriod());
-
- s = RandomUtil.randomString();
- conf.setClusterPassword(s);
- Assert.assertEquals(s, conf.getClusterPassword());
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(conf);
- oos.flush();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- Configuration conf2 = (Configuration)ois.readObject();
-
- Assert.assertTrue(conf.equals(conf2));
- }
-
- // Protected
----------------------------------------------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- conf = createConfiguration();
- }
-
- protected Configuration createConfiguration() throws Exception
- {
- return new ConfigurationImpl();
- }
-
- // Private
--------------------------------------------------------------------------------------------
-
-}
Deleted:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java
===================================================================
---
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java 2011-10-21
15:34:20 UTC (rev 11576)
+++
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java 2011-10-21
15:34:53 UTC (rev 11577)
@@ -1,160 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.config.impl;
-
-import java.util.Collections;
-
-import junit.framework.Assert;
-
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.config.impl.FileConfiguration;
-import org.hornetq.core.journal.impl.JournalConstants;
-
-/**
- *
- * A DefaultsFileConfigurationTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
- */
-public class DefaultsFileConfigurationTest extends ConfigurationImplTest
-{
- @Override
- public void testDefaults()
- {
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTERED, conf.isClustered());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SHARED_STORE, conf.isSharedStore());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
- conf.getScheduledThreadPoolMaxSize());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
conf.getThreadPoolMaxSize());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_INVALIDATION_INTERVAL,
- conf.getSecurityInvalidationInterval());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED,
conf.isSecurityEnabled());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JMX_MANAGEMENT_ENABLED,
conf.isJMXManagementEnabled());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JMX_DOMAIN, conf.getJMXDomain());
-
- Assert.assertEquals(0, conf.getInterceptorClassNames().size());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CONNECTION_TTL_OVERRIDE,
conf.getConnectionTTLOverride());
-
- Assert.assertEquals(0, conf.getAcceptorConfigurations().size());
-
- Assert.assertEquals(Collections.emptyMap(), conf.getConnectorConfigurations());
-
- Assert.assertEquals(Collections.emptyList(),
conf.getBroadcastGroupConfigurations());
-
- Assert.assertEquals(Collections.emptyMap(),
conf.getDiscoveryGroupConfigurations());
-
- Assert.assertEquals(Collections.emptyList(), conf.getBridgeConfigurations());
-
- Assert.assertEquals(Collections.emptyList(), conf.getDivertConfigurations());
-
- Assert.assertEquals(Collections.emptyList(), conf.getClusterConfigurations());
-
- Assert.assertEquals(Collections.emptyList(), conf.getQueueConfigurations());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS,
conf.getManagementAddress());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS,
- conf.getManagementNotificationAddress());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_USER,
conf.getClusterUser());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD,
conf.getClusterPassword());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_ID_CACHE_SIZE,
conf.getIDCacheSize());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_PERSIST_ID_CACHE,
conf.isPersistIDCache());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_BINDINGS_DIRECTORY,
conf.getBindingsDirectory());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_DIR,
conf.getJournalDirectory());
-
- Assert.assertEquals(getDefaultJournalType(), conf.getJournalType());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_TRANSACTIONAL,
conf.isJournalSyncTransactional());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL,
- conf.isJournalSyncNonTransactional());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE,
conf.getJournalFileSize());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_MIN_FILES,
conf.getJournalCompactMinFiles());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE,
conf.getJournalCompactPercentage());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES,
conf.getJournalMinFiles());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_AIO,
conf.getJournalMaxIO_AIO());
-
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO,
conf.getJournalBufferTimeout_AIO());
-
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
conf.getJournalBufferSize_AIO());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_NIO,
conf.getJournalMaxIO_NIO());
-
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO,
conf.getJournalBufferTimeout_NIO());
-
- Assert.assertEquals(JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO,
conf.getJournalBufferSize_NIO());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_BINDINGS_DIR,
conf.isCreateBindingsDir());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_CREATE_JOURNAL_DIR,
conf.isCreateJournalDir());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_PAGING_DIR,
conf.getPagingDirectory());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_LARGE_MESSAGES_DIR,
conf.getLargeMessagesDirectory());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_WILDCARD_ROUTING_ENABLED,
conf.isWildcardRoutingEnabled());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT,
conf.getTransactionTimeout());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_ENABLED,
conf.isMessageCounterEnabled());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD,
- conf.getTransactionTimeoutScanPeriod());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD,
conf.getMessageExpiryScanPeriod());
-
- Assert.assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY,
- conf.getMessageExpiryThreadPriority());
- }
-
- // Protected
---------------------------------------------------------------------------------------------
-
- @Override
- protected Configuration createConfiguration() throws Exception
- {
- FileConfiguration fc = new FileConfiguration();
-
- fc.setConfigurationUrl("ConfigurationTest-defaults.xml");
-
- fc.start();
-
- return fc;
- }
-
-}
Deleted:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java
===================================================================
---
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java 2011-10-21
15:34:20 UTC (rev 11576)
+++
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java 2011-10-21
15:34:53 UTC (rev 11577)
@@ -1,344 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.config.impl;
-
-import junit.framework.Assert;
-
-import org.hornetq.api.core.DiscoveryGroupConfiguration;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.core.config.BridgeConfiguration;
-import org.hornetq.core.config.BroadcastGroupConfiguration;
-import org.hornetq.core.config.ClusterConnectionConfiguration;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.DivertConfiguration;
-import org.hornetq.core.config.impl.FileConfiguration;
-import org.hornetq.core.security.Role;
-import org.hornetq.core.server.JournalType;
-
-/**
- * @author <a href="ataylor(a)redhat.com">Andy Taylor</a>
- * @author <a href="tim.fox(a)jboss.com">Tim Fox</a>
- */
-public class FileConfigurationTest extends ConfigurationImplTest
-{
- @Override
- public void testDefaults()
- {
- // Check they match the values from the test file
- Assert.assertEquals("SomeNameForUseOnTheApplicationServer",
conf.getName());
- Assert.assertEquals(false, conf.isPersistenceEnabled());
- Assert.assertEquals(true, conf.isFileDeploymentEnabled());
- Assert.assertEquals(true, conf.isClustered());
- Assert.assertEquals(true, conf.isFileDeploymentEnabled());
- Assert.assertEquals(12345, conf.getScheduledThreadPoolMaxSize());
- Assert.assertEquals(54321, conf.getThreadPoolMaxSize());
- Assert.assertEquals(false, conf.isSecurityEnabled());
- Assert.assertEquals(5423, conf.getSecurityInvalidationInterval());
- Assert.assertEquals(true, conf.isWildcardRoutingEnabled());
- Assert.assertEquals(new SimpleString("Giraffe"),
conf.getManagementAddress());
- Assert.assertEquals(new SimpleString("Whatever"),
conf.getManagementNotificationAddress());
- Assert.assertEquals("Frog", conf.getClusterUser());
- Assert.assertEquals("Wombat", conf.getClusterPassword());
- Assert.assertEquals(false, conf.isJMXManagementEnabled());
- Assert.assertEquals("gro.qtenroh", conf.getJMXDomain());
- Assert.assertEquals(true, conf.isMessageCounterEnabled());
- Assert.assertEquals(5, conf.getMessageCounterMaxDayHistory());
- Assert.assertEquals(123456, conf.getMessageCounterSamplePeriod());
- Assert.assertEquals(12345, conf.getConnectionTTLOverride());
- Assert.assertEquals(98765, conf.getTransactionTimeout());
- Assert.assertEquals(56789, conf.getTransactionTimeoutScanPeriod());
- Assert.assertEquals(10111213, conf.getMessageExpiryScanPeriod());
- Assert.assertEquals("ocelot", conf.getLogDelegateFactoryClassName());
- Assert.assertEquals(8, conf.getMessageExpiryThreadPriority());
- Assert.assertEquals(127, conf.getIDCacheSize());
- Assert.assertEquals(true, conf.isPersistIDCache());
- Assert.assertEquals(true, conf.isBackup());
- Assert.assertEquals(true, conf.isSharedStore());
- Assert.assertEquals(true, conf.isPersistDeliveryCountBeforeDelivery());
- Assert.assertEquals("pagingdir", conf.getPagingDirectory());
- Assert.assertEquals("somedir", conf.getBindingsDirectory());
- Assert.assertEquals(false, conf.isCreateBindingsDir());
- Assert.assertEquals("somedir2", conf.getJournalDirectory());
- Assert.assertEquals(false, conf.isCreateJournalDir());
- Assert.assertEquals(JournalType.NIO, conf.getJournalType());
- Assert.assertEquals(10000, conf.getJournalBufferSize_NIO());
- Assert.assertEquals(1000, conf.getJournalBufferTimeout_NIO());
- Assert.assertEquals(56546, conf.getJournalMaxIO_NIO());
-
- Assert.assertEquals(false, conf.isJournalSyncTransactional());
- Assert.assertEquals(true, conf.isJournalSyncNonTransactional());
- Assert.assertEquals(12345678, conf.getJournalFileSize());
- Assert.assertEquals(100, conf.getJournalMinFiles());
- Assert.assertEquals(123, conf.getJournalCompactMinFiles());
- Assert.assertEquals(33, conf.getJournalCompactPercentage());
-
- Assert.assertEquals("largemessagesdir",
conf.getLargeMessagesDirectory());
- Assert.assertEquals(95, conf.getMemoryWarningThreshold());
-
- Assert.assertEquals(2, conf.getInterceptorClassNames().size());
- Assert.assertTrue(conf.getInterceptorClassNames()
-
.contains("org.hornetq.tests.unit.core.config.impl.TestInterceptor1"));
- Assert.assertTrue(conf.getInterceptorClassNames()
-
.contains("org.hornetq.tests.unit.core.config.impl.TestInterceptor2"));
-
-
- Assert.assertEquals(2, conf.getConnectorConfigurations().size());
-
- TransportConfiguration tc =
conf.getConnectorConfigurations().get("connector1");
- Assert.assertNotNull(tc);
-
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestConnectorFactory1",
tc.getFactoryClassName());
- Assert.assertEquals("v1", tc.getParams().get("a1"));
- Assert.assertEquals("123", tc.getParams().get("a2"));
- Assert.assertEquals("345", tc.getParams().get("a3"));
- Assert.assertEquals("v4", tc.getParams().get("a4"));
-
- tc = conf.getConnectorConfigurations().get("connector2");
- Assert.assertNotNull(tc);
-
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestConnectorFactory2",
tc.getFactoryClassName());
- Assert.assertEquals("w1", tc.getParams().get("b1"));
- Assert.assertEquals("234", tc.getParams().get("b2"));
-
- Assert.assertEquals(2, conf.getAcceptorConfigurations().size());
- for (TransportConfiguration ac : conf.getAcceptorConfigurations())
- {
- if
(ac.getFactoryClassName().equals("org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory1"))
- {
-
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory1",
- ac.getFactoryClassName());
- Assert.assertEquals("y1", ac.getParams().get("d1"));
- Assert.assertEquals("456", ac.getParams().get("d2"));
- }
- else
- {
-
Assert.assertEquals("org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory2",
- ac.getFactoryClassName());
- Assert.assertEquals("z1", ac.getParams().get("e1"));
- Assert.assertEquals("567", ac.getParams().get("e2"));
- }
- }
-
- Assert.assertEquals(2, conf.getBroadcastGroupConfigurations().size());
- for (BroadcastGroupConfiguration bc : conf.getBroadcastGroupConfigurations())
- {
- if (bc.getName().equals("bg1"))
- {
- Assert.assertEquals("bg1", bc.getName());
- Assert.assertEquals(10999, bc.getLocalBindPort());
- Assert.assertEquals("192.168.0.120", bc.getGroupAddress());
- Assert.assertEquals(11999, bc.getGroupPort());
- Assert.assertEquals(12345, bc.getBroadcastPeriod());
- Assert.assertEquals("connector1", bc.getConnectorInfos().get(0));
- }
- else
- {
- Assert.assertEquals("bg2", bc.getName());
- Assert.assertEquals(12999, bc.getLocalBindPort());
- Assert.assertEquals("192.168.0.121", bc.getGroupAddress());
- Assert.assertEquals(13999, bc.getGroupPort());
- Assert.assertEquals(23456, bc.getBroadcastPeriod());
- Assert.assertEquals("connector2", bc.getConnectorInfos().get(0));
- }
- }
-
- Assert.assertEquals(2, conf.getDiscoveryGroupConfigurations().size());
- DiscoveryGroupConfiguration dc =
conf.getDiscoveryGroupConfigurations().get("dg1");
- Assert.assertEquals("dg1", dc.getName());
- Assert.assertEquals("192.168.0.120", dc.getGroupAddress());
- assertEquals("172.16.8.10", dc.getLocalBindAddress());
- Assert.assertEquals(11999, dc.getGroupPort());
- Assert.assertEquals(12345, dc.getRefreshTimeout());
-
- dc = conf.getDiscoveryGroupConfigurations().get("dg2");
- Assert.assertEquals("dg2", dc.getName());
- Assert.assertEquals("192.168.0.121", dc.getGroupAddress());
- assertEquals("172.16.8.11", dc.getLocalBindAddress());
- Assert.assertEquals(12999, dc.getGroupPort());
- Assert.assertEquals(23456, dc.getRefreshTimeout());
-
- Assert.assertEquals(2, conf.getDivertConfigurations().size());
- for (DivertConfiguration dic : conf.getDivertConfigurations())
- {
- if (dic.getName().equals("divert1"))
- {
- Assert.assertEquals("divert1", dic.getName());
- Assert.assertEquals("routing-name1", dic.getRoutingName());
- Assert.assertEquals("address1", dic.getAddress());
- Assert.assertEquals("forwarding-address1",
dic.getForwardingAddress());
- Assert.assertEquals("speed > 88", dic.getFilterString());
- Assert.assertEquals("org.foo.Transformer",
dic.getTransformerClassName());
- Assert.assertEquals(true, dic.isExclusive());
- }
- else
- {
- Assert.assertEquals("divert2", dic.getName());
- Assert.assertEquals("routing-name2", dic.getRoutingName());
- Assert.assertEquals("address2", dic.getAddress());
- Assert.assertEquals("forwarding-address2",
dic.getForwardingAddress());
- Assert.assertEquals("speed < 88", dic.getFilterString());
- Assert.assertEquals("org.foo.Transformer2",
dic.getTransformerClassName());
- Assert.assertEquals(false, dic.isExclusive());
- }
- }
-
- Assert.assertEquals(2, conf.getBridgeConfigurations().size());
- for (BridgeConfiguration bc : conf.getBridgeConfigurations())
- {
- if (bc.getName().equals("bridge1"))
- {
- Assert.assertEquals("bridge1", bc.getName());
- Assert.assertEquals("queue1", bc.getQueueName());
- Assert.assertEquals("bridge-forwarding-address1",
bc.getForwardingAddress());
- Assert.assertEquals("sku > 1", bc.getFilterString());
- Assert.assertEquals("org.foo.BridgeTransformer",
bc.getTransformerClassName());
- Assert.assertEquals(3, bc.getRetryInterval());
- Assert.assertEquals(0.2, bc.getRetryIntervalMultiplier());
- Assert.assertEquals(2, bc.getReconnectAttempts());
- Assert.assertEquals(true, bc.isUseDuplicateDetection());
- Assert.assertEquals("connector1",
bc.getStaticConnectors().get(0));
- Assert.assertEquals(null, bc.getDiscoveryGroupName());
- }
- else
- {
- Assert.assertEquals("bridge2", bc.getName());
- Assert.assertEquals("queue2", bc.getQueueName());
- Assert.assertEquals("bridge-forwarding-address2",
bc.getForwardingAddress());
- Assert.assertEquals(null, bc.getFilterString());
- Assert.assertEquals(null, bc.getTransformerClassName());
- Assert.assertEquals(null, bc.getStaticConnectors());
- Assert.assertEquals("dg1", bc.getDiscoveryGroupName());
- }
- }
-
- Assert.assertEquals(2, conf.getClusterConfigurations().size());
- for (ClusterConnectionConfiguration ccc : conf.getClusterConfigurations())
- {
- if (ccc.getName().equals("cluster-connection1"))
- {
- Assert.assertEquals("cluster-connection1", ccc.getName());
- Assert.assertEquals("queues1", ccc.getAddress());
- Assert.assertEquals(3, ccc.getRetryInterval());
- Assert.assertEquals(true, ccc.isDuplicateDetection());
- Assert.assertEquals(false, ccc.isForwardWhenNoConsumers());
- Assert.assertEquals(1, ccc.getMaxHops());
- Assert.assertEquals(123, ccc.getCallTimeout());
- Assert.assertEquals("connector1",
ccc.getStaticConnectors().get(0));
- Assert.assertEquals("connector2",
ccc.getStaticConnectors().get(1));
- Assert.assertEquals(null, ccc.getDiscoveryGroupName());
- }
- else
- {
- Assert.assertEquals("cluster-connection2", ccc.getName());
- Assert.assertEquals("queues2", ccc.getAddress());
- Assert.assertEquals(4, ccc.getRetryInterval());
- Assert.assertEquals(456, ccc.getCallTimeout());
- Assert.assertEquals(false, ccc.isDuplicateDetection());
- Assert.assertEquals(true, ccc.isForwardWhenNoConsumers());
- Assert.assertEquals(2, ccc.getMaxHops());
- Assert.assertEquals(null, ccc.getStaticConnectors());
- Assert.assertEquals("dg1", ccc.getDiscoveryGroupName());
- }
- }
-
-
- assertEquals(2, conf.getAddressesSettings().size());
-
- assertTrue(conf.getAddressesSettings().get("a1") != null);
- assertTrue(conf.getAddressesSettings().get("a2") != null);
-
- assertEquals("a1.1",
conf.getAddressesSettings().get("a1").getDeadLetterAddress().toString());
- assertEquals("a1.2",
conf.getAddressesSettings().get("a1").getExpiryAddress().toString());
- assertEquals(1,
conf.getAddressesSettings().get("a1").getRedeliveryDelay());
- assertEquals(81781728121878l,
conf.getAddressesSettings().get("a1").getMaxSizeBytes());
- assertEquals(81738173872337l,
conf.getAddressesSettings().get("a1").getPageSizeBytes());
- assertEquals(10,
conf.getAddressesSettings().get("a1").getPageCacheMaxSize());
- assertEquals(4,
conf.getAddressesSettings().get("a1").getMessageCounterHistoryDayLimit());
-
- assertEquals("a2.1",
conf.getAddressesSettings().get("a2").getDeadLetterAddress().toString());
- assertEquals("a2.2",
conf.getAddressesSettings().get("a2").getExpiryAddress().toString());
- assertEquals(5,
conf.getAddressesSettings().get("a2").getRedeliveryDelay());
- assertEquals(932489234928324l,
conf.getAddressesSettings().get("a2").getMaxSizeBytes());
- assertEquals(7126716262626l,
conf.getAddressesSettings().get("a2").getPageSizeBytes());
- assertEquals(20,
conf.getAddressesSettings().get("a2").getPageCacheMaxSize());
- assertEquals(8,
conf.getAddressesSettings().get("a2").getMessageCounterHistoryDayLimit());
-
-
- assertEquals(2, conf.getQueueConfigurations().size());
-
- assertEquals("queue1", conf.getQueueConfigurations().get(0).getName());
- assertEquals("address1",
conf.getQueueConfigurations().get(0).getAddress());
- assertEquals("color='red'",
conf.getQueueConfigurations().get(0).getFilterString());
- assertEquals(false, conf.getQueueConfigurations().get(0).isDurable());
-
- assertEquals("queue2", conf.getQueueConfigurations().get(1).getName());
- assertEquals("address2",
conf.getQueueConfigurations().get(1).getAddress());
- assertEquals("color='blue'",
conf.getQueueConfigurations().get(1).getFilterString());
- assertEquals(false, conf.getQueueConfigurations().get(1).isDurable());
-
- assertEquals(2, conf.getSecurityRoles().size());
-
- assertTrue(conf.getSecurityRoles().containsKey("a1"));
-
- assertTrue(conf.getSecurityRoles().containsKey("a2"));
-
- Role a1Role = conf.getSecurityRoles().get("a1").toArray(new Role[1])[0];
-
- assertFalse(a1Role.isSend());
- assertFalse(a1Role.isConsume());
- assertFalse(a1Role.isCreateDurableQueue());
- assertFalse(a1Role.isDeleteDurableQueue());
- assertTrue(a1Role.isCreateNonDurableQueue());
- assertFalse(a1Role.isDeleteNonDurableQueue());
- assertFalse(a1Role.isManage());
-
- Role a2Role = conf.getSecurityRoles().get("a2").toArray(new Role[1])[0];
-
- assertFalse(a2Role.isSend());
- assertFalse(a2Role.isConsume());
- assertFalse(a2Role.isCreateDurableQueue());
- assertFalse(a2Role.isDeleteDurableQueue());
- assertFalse(a2Role.isCreateNonDurableQueue());
- assertTrue(a2Role.isDeleteNonDurableQueue());
- assertFalse(a2Role.isManage());
-
-
- }
-
- public void testSetGetConfigurationURL()
- {
- final String file = "ghuuhhu";
-
- FileConfiguration fc = new FileConfiguration();
-
- fc.setConfigurationUrl(file);
-
- Assert.assertEquals(file, fc.getConfigurationUrl());
-
- }
-
- // Protected
---------------------------------------------------------------------------------------------
-
- @Override
- protected Configuration createConfiguration() throws Exception
- {
- FileConfiguration fc = new FileConfiguration();
-
- fc.setConfigurationUrl("ConfigurationTest-full-config.xml");
-
- fc.start();
-
- return fc;
- }
-
-}
Modified: trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml
===================================================================
--- trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml 2011-10-21
15:34:20 UTC (rev 11576)
+++ trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml 2011-10-21
15:34:53 UTC (rev 11577)
@@ -1,10 +1,10 @@
-<configuration
- xmlns="urn:hornetq"
+<configuration
+ xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq
../../src/config/common/schema/hornetq-configuration.xsd">
<name>SomeNameForUseOnTheApplicationServer</name>
<clustered>true</clustered>
- <scheduled-thread-pool-max-size>12345</scheduled-thread-pool-max-size>
+ <scheduled-thread-pool-max-size>12345</scheduled-thread-pool-max-size>
<thread-pool-max-size>54321</thread-pool-max-size>
<persistence-enabled>false</persistence-enabled>
<file-deployment-enabled>true</file-deployment-enabled>
@@ -20,17 +20,17 @@
<log-delegate-factory-class-name>ocelot</log-delegate-factory-class-name>
<message-counter-enabled>true</message-counter-enabled>
<message-counter-max-day-history>5</message-counter-max-day-history>
- <message-counter-sample-period>123456</message-counter-sample-period>
+ <message-counter-sample-period>123456</message-counter-sample-period>
<connection-ttl-override>12345</connection-ttl-override>
<transaction-timeout>98765</transaction-timeout>
<transaction-timeout-scan-period>56789</transaction-timeout-scan-period>
<message-expiry-scan-period>10111213</message-expiry-scan-period>
<message-expiry-thread-priority>8</message-expiry-thread-priority>
<id-cache-size>127</id-cache-size>
- <persist-id-cache>true</persist-id-cache>
+ <persist-id-cache>true</persist-id-cache>
<backup>true</backup>
<shared-store>true</shared-store>
-
<persist-delivery-count-before-delivery>true</persist-delivery-count-before-delivery>
+
<persist-delivery-count-before-delivery>true</persist-delivery-count-before-delivery>
<paging-directory>pagingdir</paging-directory>
<bindings-directory>somedir</bindings-directory>
<create-bindings-dir>false</create-bindings-dir>
@@ -38,10 +38,10 @@
<create-journal-dir>false</create-journal-dir>
<journal-type>NIO</journal-type>
<journal-compact-min-files>123</journal-compact-min-files>
- <journal-compact-percentage>33</journal-compact-percentage>
+ <journal-compact-percentage>33</journal-compact-percentage>
<journal-buffer-timeout>1000</journal-buffer-timeout>
<journal-buffer-size>10000</journal-buffer-size>
- <journal-sync-transactional>false</journal-sync-transactional>
+ <journal-sync-transactional>false</journal-sync-transactional>
<journal-sync-non-transactional>true</journal-sync-non-transactional>
<journal-file-size>12345678</journal-file-size>
<journal-min-files>100</journal-min-files>
@@ -61,7 +61,7 @@
<param key="a1" value="v1"/>
<param key="a2" value="123"/>
<param key="a3" value="345"/>
- <param key="a4" value="v4"/>
+ <param key="a4" value="v4"/>
</connector>
<connector name="connector2">
<factory-class>org.hornetq.tests.unit.core.config.impl.TestConnectorFactory2</factory-class>
@@ -71,12 +71,12 @@
</connectors>
<acceptors>
<acceptor name="acceptor1">
-
<factory-class>org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory1</factory-class>
+
<factory-class>org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory1</factory-class>
<param key="d1" value="y1"/>
<param key="d2" value="456"/>
</acceptor>
<acceptor name="acceptor2">
-
<factory-class>org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory2</factory-class>
+
<factory-class>org.hornetq.tests.unit.core.config.impl.TestAcceptorFactory2</factory-class>
<param key="e1" value="z1"/>
<param key="e2" value="567"/>
</acceptor>
@@ -112,7 +112,7 @@
</discovery-group>
</discovery-groups>
<diverts>
- <divert name="divert1">
+ <divert name="divert1">
<routing-name>routing-name1</routing-name>
<address>address1</address>
<forwarding-address>forwarding-address1</forwarding-address>
@@ -120,7 +120,7 @@
<transformer-class-name>org.foo.Transformer</transformer-class-name>
<exclusive>true</exclusive>
</divert>
- <divert name="divert2">
+ <divert name="divert2">
<routing-name>routing-name2</routing-name>
<address>address2</address>
<forwarding-address>forwarding-address2</forwarding-address>
@@ -170,6 +170,7 @@
<use-duplicate-detection>true</use-duplicate-detection>
<forward-when-no-consumers>false</forward-when-no-consumers>
<max-hops>1</max-hops>
+ <call-timeout>123</call-timeout>
<static-connectors>
<connector-ref>connector1</connector-ref>
<connector-ref>connector2</connector-ref>
@@ -182,10 +183,11 @@
<use-duplicate-detection>false</use-duplicate-detection>
<forward-when-no-consumers>true</forward-when-no-consumers>
<max-hops>2</max-hops>
+ <call-timeout>456</call-timeout>
<discovery-group-ref discovery-group-name="dg1"/>
</cluster-connection>
</cluster-connections>
-
+
<security-settings>
<security-setting match="a1">
<permission type="createNonDurableQueue"
roles="a1.1"/>
@@ -215,5 +217,5 @@
<message-counter-history-day-limit>8</message-counter-history-day-limit>
</address-setting>
</address-settings>
-
+
</configuration>