JBoss hornetq SVN: r11584 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-25 08:30:43 -0400 (Tue, 25 Oct 2011)
New Revision: 11584
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyFailoverTest.java
Log:
clean up
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyFailoverTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyFailoverTest.java 2011-10-25 12:30:28 UTC (rev 11583)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyFailoverTest.java 2011-10-25 12:30:43 UTC (rev 11584)
@@ -48,17 +48,13 @@
{
if (live)
{
- return new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory");
+ return new TransportConfiguration(NETTY_ACCEPTOR_FACTORY);
}
- else
- {
- Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT + 1);
+ Map<String, Object> server1Params = new HashMap<String, Object>();
+ server1Params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT + 1);
- return new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory",
- server1Params);
- }
+ return new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, server1Params);
}
@Override
@@ -66,17 +62,13 @@
{
if (live)
{
- return new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory");
+ return new TransportConfiguration(NETTY_CONNECTOR_FACTORY);
}
- else
- {
- Map<String, Object> server1Params = new HashMap<String, Object>();
- server1Params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT + 1);
+ Map<String, Object> server1Params = new HashMap<String, Object>();
+ server1Params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT + 1);
- return new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory",
- server1Params);
- }
+ return new TransportConfiguration(NETTY_CONNECTOR_FACTORY, server1Params);
}
// Private -------------------------------------------------------
13 years, 2 months
JBoss hornetq SVN: r11583 - trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-25 08:30:28 -0400 (Tue, 25 Oct 2011)
New Revision: 11583
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
Handle generic exception inside initialize() instead of after each call
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-24 09:17:44 UTC (rev 11582)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-25 12:30:28 UTC (rev 11583)
@@ -329,13 +329,14 @@
});
}
- private synchronized void initialise() throws Exception
+ private synchronized void initialise() throws HornetQException
{
if (readOnly)
{
return;
}
-
+ try
+ {
setThreadPools();
instantiateLoadBalancingPolicy();
@@ -369,6 +370,11 @@
readOnly = true;
}
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, "Failed to initialise session factory", e);
+ }
+ }
private ServerLocatorImpl(final Topology topology,
final boolean useHA,
@@ -604,14 +610,7 @@
{
assertOpen();
- try
- {
initialise();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, "Failed to initialise session factory", e);
- }
synchronized (this)
{
@@ -650,14 +649,7 @@
{
assertOpen();
- try
- {
- initialise();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, "Failed to initialise session factory", e);
- }
+ initialise();
if (initialConnectors == null && discoveryGroup != null)
{
@@ -1503,14 +1495,7 @@
throw new IllegalStateException("Cannot create session factory, server locator is closed (maybe it has been garbage collected)");
}
- try
- {
- initialise();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, "Failed to initialise session factory", e);
- }
+ initialise();
ClientSessionFactory csf = null;
13 years, 2 months
JBoss hornetq SVN: r11582 - in trunk: tests/unit-tests/src/test/resources and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-24 05:17:44 -0400 (Mon, 24 Oct 2011)
New Revision: 11582
Added:
trunk/hornetq-core/src/test/resources/ConfigurationTest-defaults.xml
Removed:
trunk/tests/unit-tests/src/test/resources/ConfigurationTest-defaults.xml
Log:
Move configuration file test resource from tests/unit-tests to hornet-core
Copied: trunk/hornetq-core/src/test/resources/ConfigurationTest-defaults.xml (from rev 11581, trunk/tests/unit-tests/src/test/resources/ConfigurationTest-defaults.xml)
===================================================================
--- trunk/hornetq-core/src/test/resources/ConfigurationTest-defaults.xml (rev 0)
+++ trunk/hornetq-core/src/test/resources/ConfigurationTest-defaults.xml 2011-10-24 09:17:44 UTC (rev 11582)
@@ -0,0 +1,6 @@
+<configuration
+ xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq ../../src/schemas/hornetq-configuration.xsd ">
+ <!-- just use the defaults -->
+</configuration>
Deleted: trunk/tests/unit-tests/src/test/resources/ConfigurationTest-defaults.xml
===================================================================
--- trunk/tests/unit-tests/src/test/resources/ConfigurationTest-defaults.xml 2011-10-24 09:15:20 UTC (rev 11581)
+++ trunk/tests/unit-tests/src/test/resources/ConfigurationTest-defaults.xml 2011-10-24 09:17:44 UTC (rev 11582)
@@ -1,6 +0,0 @@
-<configuration
- xmlns="urn:hornetq"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:hornetq ../../src/schemas/hornetq-configuration.xsd ">
- <!-- just use the defaults -->
-</configuration>
13 years, 2 months
JBoss hornetq SVN: r11581 - in trunk: hornetq-core/src/test/resources and 1 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-24 05:15:20 -0400 (Mon, 24 Oct 2011)
New Revision: 11581
Added:
trunk/hornetq-core/src/test/resources/
trunk/hornetq-core/src/test/resources/ConfigurationTest-full-config.xml
Removed:
trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml
Log:
Move configuration file test resource from tests/unit-tests to hornet-core
Copied: trunk/hornetq-core/src/test/resources/ConfigurationTest-full-config.xml (from rev 11577, trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml)
===================================================================
--- trunk/hornetq-core/src/test/resources/ConfigurationTest-full-config.xml (rev 0)
+++ trunk/hornetq-core/src/test/resources/ConfigurationTest-full-config.xml 2011-10-24 09:15:20 UTC (rev 11581)
@@ -0,0 +1,221 @@
+<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>
+ <thread-pool-max-size>54321</thread-pool-max-size>
+ <persistence-enabled>false</persistence-enabled>
+ <file-deployment-enabled>true</file-deployment-enabled>
+ <security-enabled>false</security-enabled>
+ <security-invalidation-interval>5423</security-invalidation-interval>
+ <wild-card-routing-enabled>true</wild-card-routing-enabled>
+ <management-address>Giraffe</management-address>
+ <management-notification-address>Whatever</management-notification-address>
+ <cluster-user>Frog</cluster-user>
+ <cluster-password>Wombat</cluster-password>
+ <jmx-management-enabled>false</jmx-management-enabled>
+ <jmx-domain>gro.qtenroh</jmx-domain>
+ <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>
+ <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>
+ <backup>true</backup>
+ <shared-store>true</shared-store>
+ <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>
+ <journal-directory>somedir2</journal-directory>
+ <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-buffer-timeout>1000</journal-buffer-timeout>
+ <journal-buffer-size>10000</journal-buffer-size>
+ <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>
+ <journal-max-io>56546</journal-max-io>
+ <large-messages-directory>largemessagesdir</large-messages-directory>
+ <memory-warning-threshold>95</memory-warning-threshold>
+ <memory-measure-interval>54321</memory-measure-interval>
+
+ <remoting-interceptors>
+ <class-name>org.hornetq.tests.unit.core.config.impl.TestInterceptor1</class-name>
+ <class-name>org.hornetq.tests.unit.core.config.impl.TestInterceptor2</class-name>
+ </remoting-interceptors>
+
+ <connectors>
+ <connector name="connector1">
+ <factory-class>org.hornetq.tests.unit.core.config.impl.TestConnectorFactory1</factory-class>
+ <param key="a1" value="v1"/>
+ <param key="a2" value="123"/>
+ <param key="a3" value="345"/>
+ <param key="a4" value="v4"/>
+ </connector>
+ <connector name="connector2">
+ <factory-class>org.hornetq.tests.unit.core.config.impl.TestConnectorFactory2</factory-class>
+ <param key="b1" value="w1"/>
+ <param key="b2" value="234"/>
+ </connector>
+ </connectors>
+ <acceptors>
+ <acceptor name="acceptor1">
+ <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>
+ <param key="e1" value="z1"/>
+ <param key="e2" value="567"/>
+ </acceptor>
+ </acceptors>
+ <broadcast-groups>
+ <broadcast-group name="bg1">
+ <local-bind-port>10999</local-bind-port>
+ <group-address>192.168.0.120</group-address>
+ <group-port>11999</group-port>
+ <broadcast-period>12345</broadcast-period>
+ <connector-ref>connector1</connector-ref>
+ </broadcast-group>
+ <broadcast-group name="bg2">
+ <local-bind-port>12999</local-bind-port>
+ <group-address>192.168.0.121</group-address>
+ <group-port>13999</group-port>
+ <broadcast-period>23456</broadcast-period>
+ <connector-ref>connector2</connector-ref>
+ </broadcast-group>
+ </broadcast-groups>
+ <discovery-groups>
+ <discovery-group name="dg1">
+ <local-bind-address>172.16.8.10</local-bind-address>
+ <group-address>192.168.0.120</group-address>
+ <group-port>11999</group-port>
+ <refresh-timeout>12345</refresh-timeout>
+ </discovery-group>
+ <discovery-group name="dg2">
+ <local-bind-address>172.16.8.11</local-bind-address>
+ <group-address>192.168.0.121</group-address>
+ <group-port>12999</group-port>
+ <refresh-timeout>23456</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+ <diverts>
+ <divert name="divert1">
+ <routing-name>routing-name1</routing-name>
+ <address>address1</address>
+ <forwarding-address>forwarding-address1</forwarding-address>
+ <filter string="speed > 88"/>
+ <transformer-class-name>org.foo.Transformer</transformer-class-name>
+ <exclusive>true</exclusive>
+ </divert>
+ <divert name="divert2">
+ <routing-name>routing-name2</routing-name>
+ <address>address2</address>
+ <forwarding-address>forwarding-address2</forwarding-address>
+ <filter string="speed < 88"/>
+ <transformer-class-name>org.foo.Transformer2</transformer-class-name>
+ <exclusive>false</exclusive>
+ </divert>
+ </diverts>
+ <queues>
+ <queue name="queue1">
+ <address>address1</address>
+ <filter string="color='red'" />
+ <durable>false</durable>
+ </queue>
+ <queue name="queue2">
+ <address>address2</address>
+ <filter string="color='blue'" />
+ <durable>false</durable>
+ </queue>
+ </queues>
+ <bridges>
+ <bridge name="bridge1">
+ <queue-name>queue1</queue-name>
+ <forwarding-address>bridge-forwarding-address1</forwarding-address>
+ <filter string="sku > 1"/>
+ <transformer-class-name>org.foo.BridgeTransformer</transformer-class-name>
+ <retry-interval>3</retry-interval>
+ <retry-interval-multiplier>0.2</retry-interval-multiplier>
+ <reconnect-attempts>2</reconnect-attempts>
+ <failover-on-server-shutdown>false</failover-on-server-shutdown>
+ <use-duplicate-detection>true</use-duplicate-detection>
+ <static-connectors>
+ <connector-ref>connector1</connector-ref>
+ </static-connectors>
+ </bridge>
+ <bridge name="bridge2">
+ <queue-name>queue2</queue-name>
+ <forwarding-address>bridge-forwarding-address2</forwarding-address>
+ <discovery-group-ref discovery-group-name="dg1"/>
+ </bridge>
+ </bridges>
+ <cluster-connections>
+ <cluster-connection name="cluster-connection1">
+ <address>queues1</address>
+ <connector-ref>connector1</connector-ref>
+ <retry-interval>3</retry-interval>
+ <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>
+ </static-connectors>
+ </cluster-connection>
+ <cluster-connection name="cluster-connection2">
+ <address>queues2</address>
+ <connector-ref>connector2</connector-ref>
+ <retry-interval>4</retry-interval>
+ <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"/>
+ </security-setting>
+ <security-setting match="a2">
+ <permission type="deleteNonDurableQueue" roles="a2.1"/>
+ </security-setting>
+ </security-settings>
+
+ <address-settings>
+ <address-setting match="a1">
+ <dead-letter-address>a1.1</dead-letter-address>
+ <expiry-address>a1.2</expiry-address>
+ <redelivery-delay>1</redelivery-delay>
+ <max-size-bytes>81781728121878</max-size-bytes>
+ <page-size-bytes>81738173872337</page-size-bytes>
+ <page-max-cache-size>10</page-max-cache-size>
+ <message-counter-history-day-limit>4</message-counter-history-day-limit>
+ </address-setting>
+ <address-setting match="a2">
+ <dead-letter-address>a2.1</dead-letter-address>
+ <expiry-address>a2.2</expiry-address>
+ <redelivery-delay>5</redelivery-delay>
+ <max-size-bytes>932489234928324</max-size-bytes>
+ <page-size-bytes>7126716262626</page-size-bytes>
+ <page-max-cache-size>20</page-max-cache-size>
+ <message-counter-history-day-limit>8</message-counter-history-day-limit>
+ </address-setting>
+ </address-settings>
+
+</configuration>
Deleted: 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 21:41:59 UTC (rev 11580)
+++ trunk/tests/unit-tests/src/test/resources/ConfigurationTest-full-config.xml 2011-10-24 09:15:20 UTC (rev 11581)
@@ -1,221 +0,0 @@
-<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>
- <thread-pool-max-size>54321</thread-pool-max-size>
- <persistence-enabled>false</persistence-enabled>
- <file-deployment-enabled>true</file-deployment-enabled>
- <security-enabled>false</security-enabled>
- <security-invalidation-interval>5423</security-invalidation-interval>
- <wild-card-routing-enabled>true</wild-card-routing-enabled>
- <management-address>Giraffe</management-address>
- <management-notification-address>Whatever</management-notification-address>
- <cluster-user>Frog</cluster-user>
- <cluster-password>Wombat</cluster-password>
- <jmx-management-enabled>false</jmx-management-enabled>
- <jmx-domain>gro.qtenroh</jmx-domain>
- <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>
- <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>
- <backup>true</backup>
- <shared-store>true</shared-store>
- <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>
- <journal-directory>somedir2</journal-directory>
- <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-buffer-timeout>1000</journal-buffer-timeout>
- <journal-buffer-size>10000</journal-buffer-size>
- <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>
- <journal-max-io>56546</journal-max-io>
- <large-messages-directory>largemessagesdir</large-messages-directory>
- <memory-warning-threshold>95</memory-warning-threshold>
- <memory-measure-interval>54321</memory-measure-interval>
-
- <remoting-interceptors>
- <class-name>org.hornetq.tests.unit.core.config.impl.TestInterceptor1</class-name>
- <class-name>org.hornetq.tests.unit.core.config.impl.TestInterceptor2</class-name>
- </remoting-interceptors>
-
- <connectors>
- <connector name="connector1">
- <factory-class>org.hornetq.tests.unit.core.config.impl.TestConnectorFactory1</factory-class>
- <param key="a1" value="v1"/>
- <param key="a2" value="123"/>
- <param key="a3" value="345"/>
- <param key="a4" value="v4"/>
- </connector>
- <connector name="connector2">
- <factory-class>org.hornetq.tests.unit.core.config.impl.TestConnectorFactory2</factory-class>
- <param key="b1" value="w1"/>
- <param key="b2" value="234"/>
- </connector>
- </connectors>
- <acceptors>
- <acceptor name="acceptor1">
- <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>
- <param key="e1" value="z1"/>
- <param key="e2" value="567"/>
- </acceptor>
- </acceptors>
- <broadcast-groups>
- <broadcast-group name="bg1">
- <local-bind-port>10999</local-bind-port>
- <group-address>192.168.0.120</group-address>
- <group-port>11999</group-port>
- <broadcast-period>12345</broadcast-period>
- <connector-ref>connector1</connector-ref>
- </broadcast-group>
- <broadcast-group name="bg2">
- <local-bind-port>12999</local-bind-port>
- <group-address>192.168.0.121</group-address>
- <group-port>13999</group-port>
- <broadcast-period>23456</broadcast-period>
- <connector-ref>connector2</connector-ref>
- </broadcast-group>
- </broadcast-groups>
- <discovery-groups>
- <discovery-group name="dg1">
- <local-bind-address>172.16.8.10</local-bind-address>
- <group-address>192.168.0.120</group-address>
- <group-port>11999</group-port>
- <refresh-timeout>12345</refresh-timeout>
- </discovery-group>
- <discovery-group name="dg2">
- <local-bind-address>172.16.8.11</local-bind-address>
- <group-address>192.168.0.121</group-address>
- <group-port>12999</group-port>
- <refresh-timeout>23456</refresh-timeout>
- </discovery-group>
- </discovery-groups>
- <diverts>
- <divert name="divert1">
- <routing-name>routing-name1</routing-name>
- <address>address1</address>
- <forwarding-address>forwarding-address1</forwarding-address>
- <filter string="speed > 88"/>
- <transformer-class-name>org.foo.Transformer</transformer-class-name>
- <exclusive>true</exclusive>
- </divert>
- <divert name="divert2">
- <routing-name>routing-name2</routing-name>
- <address>address2</address>
- <forwarding-address>forwarding-address2</forwarding-address>
- <filter string="speed < 88"/>
- <transformer-class-name>org.foo.Transformer2</transformer-class-name>
- <exclusive>false</exclusive>
- </divert>
- </diverts>
- <queues>
- <queue name="queue1">
- <address>address1</address>
- <filter string="color='red'" />
- <durable>false</durable>
- </queue>
- <queue name="queue2">
- <address>address2</address>
- <filter string="color='blue'" />
- <durable>false</durable>
- </queue>
- </queues>
- <bridges>
- <bridge name="bridge1">
- <queue-name>queue1</queue-name>
- <forwarding-address>bridge-forwarding-address1</forwarding-address>
- <filter string="sku > 1"/>
- <transformer-class-name>org.foo.BridgeTransformer</transformer-class-name>
- <retry-interval>3</retry-interval>
- <retry-interval-multiplier>0.2</retry-interval-multiplier>
- <reconnect-attempts>2</reconnect-attempts>
- <failover-on-server-shutdown>false</failover-on-server-shutdown>
- <use-duplicate-detection>true</use-duplicate-detection>
- <static-connectors>
- <connector-ref>connector1</connector-ref>
- </static-connectors>
- </bridge>
- <bridge name="bridge2">
- <queue-name>queue2</queue-name>
- <forwarding-address>bridge-forwarding-address2</forwarding-address>
- <discovery-group-ref discovery-group-name="dg1"/>
- </bridge>
- </bridges>
- <cluster-connections>
- <cluster-connection name="cluster-connection1">
- <address>queues1</address>
- <connector-ref>connector1</connector-ref>
- <retry-interval>3</retry-interval>
- <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>
- </static-connectors>
- </cluster-connection>
- <cluster-connection name="cluster-connection2">
- <address>queues2</address>
- <connector-ref>connector2</connector-ref>
- <retry-interval>4</retry-interval>
- <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"/>
- </security-setting>
- <security-setting match="a2">
- <permission type="deleteNonDurableQueue" roles="a2.1"/>
- </security-setting>
- </security-settings>
-
- <address-settings>
- <address-setting match="a1">
- <dead-letter-address>a1.1</dead-letter-address>
- <expiry-address>a1.2</expiry-address>
- <redelivery-delay>1</redelivery-delay>
- <max-size-bytes>81781728121878</max-size-bytes>
- <page-size-bytes>81738173872337</page-size-bytes>
- <page-max-cache-size>10</page-max-cache-size>
- <message-counter-history-day-limit>4</message-counter-history-day-limit>
- </address-setting>
- <address-setting match="a2">
- <dead-letter-address>a2.1</dead-letter-address>
- <expiry-address>a2.2</expiry-address>
- <redelivery-delay>5</redelivery-delay>
- <max-size-bytes>932489234928324</max-size-bytes>
- <page-size-bytes>7126716262626</page-size-bytes>
- <page-max-cache-size>20</page-max-cache-size>
- <message-counter-history-day-limit>8</message-counter-history-day-limit>
- </address-setting>
- </address-settings>
-
-</configuration>
13 years, 2 months
JBoss hornetq SVN: r11580 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-10-21 17:41:59 -0400 (Fri, 21 Oct 2011)
New Revision: 11580
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionBridge.java
Log:
fixing tests
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionBridge.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionBridge.java 2011-10-21 19:26:04 UTC (rev 11579)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionBridge.java 2011-10-21 21:41:59 UTC (rev 11580)
@@ -339,7 +339,7 @@
if (permanently)
{
log.debug("cluster node for bridge " + this.getName() + " is permanently down");
- discoveryLocator.notifyNodeDown(targetNodeEventUID+1, targetNodeID);
+ discoveryLocator.notifyNodeDown(System.currentTimeMillis(), targetNodeID);
}
}
13 years, 2 months
JBoss hornetq SVN: r11579 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty.
by do-not-reply@jboss.org
Author: clebert.suconic
Date: 2011-10-21 15:26:04 -0400 (Fri, 21 Oct 2011)
New Revision: 11579
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java
Log:
format only (no changes)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java 2011-10-21 19:24:40 UTC (rev 11578)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java 2011-10-21 19:26:04 UTC (rev 11579)
@@ -62,7 +62,7 @@
private final Semaphore writeLock = new Semaphore(1);
- private Set<ReadyListener> readyListeners = new ConcurrentHashSet<ReadyListener>();
+ private final Set<ReadyListener> readyListeners = new ConcurrentHashSet<ReadyListener>();
// Static --------------------------------------------------------
@@ -70,8 +70,8 @@
public NettyConnection(final Channel channel,
final ConnectionLifeCycleListener listener,
- boolean batchingEnabled,
- boolean directDeliver)
+ final boolean batchingEnabled,
+ final boolean directDeliver)
{
this(null, channel, listener, batchingEnabled, directDeliver);
}
@@ -79,8 +79,8 @@
public NettyConnection(final Acceptor acceptor,
final Channel channel,
final ConnectionLifeCycleListener listener,
- boolean batchingEnabled,
- boolean directDeliver)
+ final boolean batchingEnabled,
+ final boolean directDeliver)
{
this.channel = channel;
@@ -160,7 +160,7 @@
{
channel.write(batchBuffer.channelBuffer());
- batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
+ batchBuffer = HornetQBuffers.dynamicBuffer(NettyConnection.BATCHING_BUFFER_SIZE);
}
}
finally
@@ -188,14 +188,14 @@
{
// Lazily create batch buffer
- batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
+ batchBuffer = HornetQBuffers.dynamicBuffer(NettyConnection.BATCHING_BUFFER_SIZE);
}
if (batchBuffer != null)
{
batchBuffer.writeBytes(buffer, 0, buffer.writerIndex());
- if (batchBuffer.writerIndex() >= BATCHING_BUFFER_SIZE || !batched || flush)
+ if (batchBuffer.writerIndex() >= NettyConnection.BATCHING_BUFFER_SIZE || !batched || flush)
{
// If the batch buffer is full or it's flush param or not batched then flush the buffer
@@ -214,7 +214,7 @@
{
// Create a new buffer
- batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
+ batchBuffer = HornetQBuffers.dynamicBuffer(NettyConnection.BATCHING_BUFFER_SIZE);
}
}
13 years, 2 months
JBoss hornetq SVN: r11578 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty.
by do-not-reply@jboss.org
Author: clebert.suconic
Date: 2011-10-21 15:24:40 -0400 (Fri, 21 Oct 2011)
New Revision: 11578
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java
Log:
format only (no changes)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java 2011-10-21 15:34:53 UTC (rev 11577)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java 2011-10-21 19:24:40 UTC (rev 11578)
@@ -61,7 +61,7 @@
private volatile HornetQBuffer batchBuffer;
private final Semaphore writeLock = new Semaphore(1);
-
+
private Set<ReadyListener> readyListeners = new ConcurrentHashSet<ReadyListener>();
// Static --------------------------------------------------------
@@ -75,7 +75,7 @@
{
this(null, channel, listener, batchingEnabled, directDeliver);
}
-
+
public NettyConnection(final Acceptor acceptor,
final Channel channel,
final ConnectionLifeCycleListener listener,
@@ -178,68 +178,69 @@
public void write(HornetQBuffer buffer, final boolean flush, final boolean batched)
{
- try {
- writeLock.acquire();
-
try
{
- if (batchBuffer == null && batchingEnabled && batched && !flush)
- {
- // Lazily create batch buffer
+ writeLock.acquire();
- batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
- }
-
- if (batchBuffer != null)
+ try
{
- batchBuffer.writeBytes(buffer, 0, buffer.writerIndex());
-
- if (batchBuffer.writerIndex() >= BATCHING_BUFFER_SIZE || !batched || flush)
+ if (batchBuffer == null && batchingEnabled && batched && !flush)
{
- // If the batch buffer is full or it's flush param or not batched then flush the buffer
+ // Lazily create batch buffer
- buffer = batchBuffer;
+ batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
}
- else
- {
- return;
- }
- if (!batched || flush)
+ if (batchBuffer != null)
{
- batchBuffer = null;
- }
- else
- {
- // Create a new buffer
+ batchBuffer.writeBytes(buffer, 0, buffer.writerIndex());
- batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
+ if (batchBuffer.writerIndex() >= BATCHING_BUFFER_SIZE || !batched || flush)
+ {
+ // If the batch buffer is full or it's flush param or not batched then flush the buffer
+
+ buffer = batchBuffer;
+ }
+ else
+ {
+ return;
+ }
+
+ if (!batched || flush)
+ {
+ batchBuffer = null;
+ }
+ else
+ {
+ // Create a new buffer
+
+ batchBuffer = HornetQBuffers.dynamicBuffer(BATCHING_BUFFER_SIZE);
+ }
}
- }
- ChannelFuture future = channel.write(buffer.channelBuffer());
+ ChannelFuture future = channel.write(buffer.channelBuffer());
- if (flush)
- {
- while (true)
+ if (flush)
{
- try
+ while (true)
{
- boolean ok = future.await(10000);
+ try
+ {
+ boolean ok = future.await(10000);
- if (!ok)
+ if (!ok)
+ {
+ NettyConnection.log.warn("Timed out waiting for packet to be flushed");
+ }
+
+ break;
+ }
+ catch (InterruptedException ignore)
{
- NettyConnection.log.warn("Timed out waiting for packet to be flushed");
}
-
- break;
}
- catch (InterruptedException ignore)
- {
- }
}
}
- }
finally
{
writeLock.release();
@@ -260,20 +261,20 @@
{
return directDeliver;
}
-
+
public void addReadyListener(final ReadyListener listener)
{
readyListeners.add(listener);
}
-
+
public void removeReadyListener(final ReadyListener listener)
{
readyListeners.remove(listener);
}
-
+
public void fireReady(final boolean ready)
{
- for (ReadyListener listener: readyListeners)
+ for (ReadyListener listener : readyListeners)
{
listener.readyForWriting(ready);
}
13 years, 2 months
JBoss hornetq SVN: r11577 - in trunk: hornetq-core/src/test/java/org/hornetq/core and 4 other directories.
by do-not-reply@jboss.org
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>
13 years, 2 months
JBoss hornetq SVN: r11576 - in trunk: hornetq-core/src/test/java/org/hornetq/core/message and 6 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-21 11:34:20 -0400 (Fri, 21 Oct 2011)
New Revision: 11576
Added:
trunk/hornetq-core/src/test/java/org/hornetq/core/message/
trunk/hornetq-core/src/test/java/org/hornetq/core/message/impl/
trunk/hornetq-core/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
Removed:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/DeleteQueueRestartTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java
Log:
Undelete MessagePropertyTest, move ServiceTestBase to hornetq-core/src/tests
Added: trunk/hornetq-core/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java 2011-10-21 15:34:20 UTC (rev 11576)
@@ -0,0 +1,110 @@
+package org.hornetq.core.message.impl;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.ServiceTestBase;
+
+public class MessagePropertyTest extends ServiceTestBase
+{
+ private HornetQServer server;
+ private ServerLocator locator;
+ private ClientSessionFactory sf;
+ private final int numMessages = 20;
+
+ private static final String ADDRESS = "aAddress123";
+ private static final SimpleString SIMPLE_STRING_KEY = new SimpleString("StringToSimpleString");
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ server = createServer(true);
+ server.start();
+ locator = createInVMNonHALocator();
+ sf = locator.createSessionFactory();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ sf.close();
+ locator.close();
+ server.stop();
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ private void sendMessages() throws Exception
+ {
+ ClientSession session = sf.createSession(true, true);
+ session.createQueue(ADDRESS, ADDRESS, null, true);
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ setBody(i, message);
+ message.putIntProperty("int", i);
+ message.putShortProperty("short", (short)i);
+ message.putByteProperty("byte", (byte)i);
+ message.putFloatProperty("float", floatValue(i));
+ message.putStringProperty(SIMPLE_STRING_KEY, new SimpleString(Integer.toString(i)));
+ message.putBytesProperty("byte[]", byteArray(i));
+ producer.send(message);
+ }
+ session.commit();
+ }
+
+ private float floatValue(int i)
+ {
+ return (float)(i * 1.3);
+ }
+
+ private byte[] byteArray(int i)
+ {
+ return new byte[] { (byte)i, (byte)(i / 2) };
+ }
+
+ public void testProperties() throws Exception
+ {
+ sendMessages();
+ receiveMessages();
+ }
+
+
+ private void receiveMessages() throws Exception
+ {
+ ClientSession session = sf.createSession(true, true);
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = consumer.receive(100);
+ assertNotNull("Expecting a message " + i, message);
+ assertMessageBody(i, message);
+ assertEquals(i, message.getIntProperty("int").intValue());
+ assertEquals((short)i, message.getShortProperty("short").shortValue());
+ assertEquals((byte)i, message.getByteProperty("byte").byteValue());
+ assertEquals(floatValue(i), message.getFloatProperty("float").floatValue(), 0.001);
+ assertEquals(new SimpleString(Integer.toString(i)),
+ message.getSimpleStringProperty(SIMPLE_STRING_KEY.toString()));
+ assertEqualsByteArrays(byteArray(i), message.getBytesProperty("byte[]"));
+ message.acknowledge();
+ }
+ assertNull("no more messages", consumer.receive(50));
+ consumer.close();
+ session.commit();
+ }
+
+}
Copied: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java (from rev 11574, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-10-21 15:34:20 UTC (rev 11576)
@@ -0,0 +1,810 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+
+import junit.framework.Assert;
+
+import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.client.impl.Topology;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
+import org.hornetq.core.remoting.impl.invm.InVMRegistry;
+import org.hornetq.core.remoting.impl.invm.TransportConstants;
+import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
+import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
+import org.hornetq.core.server.HornetQComponent;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.HornetQServers;
+import org.hornetq.core.server.NodeManager;
+import org.hornetq.core.server.cluster.ClusterConnection;
+import org.hornetq.core.server.impl.HornetQServerImpl;
+import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
+import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.spi.core.security.HornetQSecurityManager;
+import org.hornetq.spi.core.security.HornetQSecurityManagerImpl;
+import org.hornetq.utils.UUIDGenerator;
+
+/**
+ *
+ * Base class with basic utilities on starting up a basic server
+ *
+ * @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
+ *
+ */
+public abstract class ServiceTestBase extends UnitTestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ protected static final long WAIT_TIMEOUT = 10000;
+
+
+ // Attributes ----------------------------------------------------
+
+ protected static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
+
+ public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
+
+ protected static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
+
+ protected static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
+
+ private final List<ServerLocator> locators = new ArrayList<ServerLocator>();
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ for (ServerLocator locator : locators)
+ {
+ try
+ {
+ locator.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ locators.clear();
+ super.tearDown();
+// checkFreePort(5445);
+// checkFreePort(5446);
+// checkFreePort(5447);
+ if (InVMRegistry.instance.size() > 0)
+ {
+ fail("InVMREgistry size > 0");
+ }
+ }
+
+ public static final void closeServerLocator(ServerLocator locator)
+ {
+ if (locator == null)
+ return;
+ try
+ {
+ locator.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ protected void waitForTopology(final HornetQServer server, final int nodes) throws Exception
+ {
+ waitForTopology(server, nodes, WAIT_TIMEOUT);
+ }
+
+ protected void waitForTopology(final HornetQServer server, final int nodes, final long timeout) throws Exception
+ {
+ log.debug("waiting for " + nodes + " on the topology for server = " + server);
+
+ long start = System.currentTimeMillis();
+
+ Set<ClusterConnection> ccs = server.getClusterManager().getClusterConnections();
+
+ if (ccs.size() != 1)
+ {
+ throw new IllegalStateException("You need a single cluster connection on this version of waitForTopology on ServiceTestBase");
+ }
+
+ Topology topology = ccs.iterator().next().getTopology();
+
+ do
+ {
+ if (nodes == topology.getMembers().size())
+ {
+ return;
+ }
+
+ Thread.sleep(10);
+ }
+ while (System.currentTimeMillis() - start < timeout);
+
+ String msg = "Timed out waiting for cluster topology of " + nodes +
+ " (received " +
+ topology.getMembers().size() +
+ ") topology = " +
+ topology +
+ ")";
+
+ log.error(msg);
+
+ throw new Exception(msg);
+ }
+
+
+ protected void waitForTopology(final HornetQServer server, String clusterConnectionName, final int nodes, final long timeout) throws Exception
+ {
+ log.debug("waiting for " + nodes + " on the topology for server = " + server);
+
+ long start = System.currentTimeMillis();
+
+ ClusterConnection clusterConnection = server.getClusterManager().getClusterConnection(clusterConnectionName);
+
+
+ Topology topology = clusterConnection.getTopology();
+
+ do
+ {
+ if (nodes == topology.getMembers().size())
+ {
+ return;
+ }
+
+ Thread.sleep(10);
+ }
+ while (System.currentTimeMillis() - start < timeout);
+
+ String msg = "Timed out waiting for cluster topology of " + nodes +
+ " (received " +
+ topology.getMembers().size() +
+ ") topology = " +
+ topology +
+ ")";
+
+ log.error(msg);
+
+ throw new Exception(msg);
+ }
+
+ protected final static void waitForComponent(final HornetQComponent component, final long seconds) throws Exception
+ {
+ long time = System.currentTimeMillis();
+ long toWait = seconds * 1000;
+ while (!component.isStarted())
+ {
+ try
+ {
+ Thread.sleep(50);
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ if (System.currentTimeMillis() > (time + toWait))
+ {
+ fail("component did not start within timeout of " + seconds);
+ }
+ }
+ }
+
+ protected static final void stopComponent(HornetQComponent component)
+ {
+ if (component == null)
+ return;
+ if (component.isStarted())
+ try
+ {
+ component.stop();
+ }
+ catch (Exception e)
+ {
+ // no-op
+ }
+ }
+
+ protected static Map<String, Object> generateParams(final int node, final boolean netty)
+ {
+ Map<String, Object> params = new HashMap<String, Object>();
+
+ if (netty)
+ {
+ params.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME,
+ org.hornetq.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + node);
+ }
+ else
+ {
+ params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, node);
+ }
+
+ return params;
+ }
+
+ protected static TransportConfiguration createTransportConfiguration(boolean netty,
+ boolean acceptor,
+ Map<String, Object> params)
+ {
+ String className;
+ if (netty)
+ {
+ if (acceptor)
+ {
+ className = NettyAcceptorFactory.class.getName();
+ }
+ else
+ {
+ className = NettyConnectorFactory.class.getName();
+ }
+ }
+ else
+ {
+ if (acceptor)
+ {
+ className = InVMAcceptorFactory.class.getName();
+ }
+ else
+ {
+ className = InVMConnectorFactory.class.getName();
+ }
+ }
+ return new TransportConfiguration(className, params);
+ }
+
+ // Static --------------------------------------------------------
+ private final Logger log = Logger.getLogger(this.getClass());
+
+ // Constructors --------------------------------------------------
+
+ public ServiceTestBase()
+ {
+ super();
+ }
+
+ public ServiceTestBase(final String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void waitForServer(HornetQServer server) throws InterruptedException
+ {
+ long timetowait = System.currentTimeMillis() + 5000;
+ while (!server.isStarted() && System.currentTimeMillis() < timetowait)
+ {
+ Thread.sleep(100);
+ }
+
+ if (!server.isStarted())
+ {
+ log.info(threadDump("Server didn't start"));
+ fail("server didnt start");
+ }
+
+ if (!server.getConfiguration().isBackup())
+ {
+ timetowait = System.currentTimeMillis() + 5000;
+ while (!server.isInitialised() && System.currentTimeMillis() < timetowait)
+ {
+ Thread.sleep(100);
+ }
+
+ if (!server.isInitialised())
+ {
+ fail("Server didn't initialize");
+ }
+ }
+ }
+
+
+ protected HornetQServer createServer(final boolean realFiles,
+ final Configuration configuration,
+ final int pageSize,
+ final int maxAddressSize,
+ final Map<String, AddressSettings> settings,
+ final MBeanServer mbeanServer)
+ {
+ HornetQServer server;
+
+ if (realFiles)
+ {
+ server = HornetQServers.newHornetQServer(configuration, mbeanServer, true);
+ }
+ else
+ {
+ server = HornetQServers.newHornetQServer(configuration, mbeanServer, false);
+ }
+
+ for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
+ {
+ server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
+ }
+
+ AddressSettings defaultSetting = new AddressSettings();
+ defaultSetting.setPageSizeBytes(pageSize);
+ defaultSetting.setMaxSizeBytes(maxAddressSize);
+
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+ return server;
+ }
+
+ protected HornetQServer createServer(final boolean realFiles,
+ final Configuration configuration,
+ final int pageSize,
+ final int maxAddressSize,
+ final Map<String, AddressSettings> settings)
+ {
+ return createServer(realFiles, configuration, pageSize, maxAddressSize, AddressFullMessagePolicy.PAGE, settings);
+ }
+
+ protected HornetQServer createServer(final boolean realFiles,
+ final Configuration configuration,
+ final int pageSize,
+ final int maxAddressSize,
+ final AddressFullMessagePolicy fullPolicy,
+ final Map<String, AddressSettings> settings)
+ {
+ HornetQServer server;
+
+ if (realFiles)
+ {
+ server = HornetQServers.newHornetQServer(configuration);
+ }
+ else
+ {
+ server = HornetQServers.newHornetQServer(configuration, false);
+ }
+
+ if (settings != null)
+ {
+ for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
+ {
+ server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
+ }
+ }
+
+ AddressSettings defaultSetting = new AddressSettings();
+ defaultSetting.setPageSizeBytes(pageSize);
+ defaultSetting.setMaxSizeBytes(maxAddressSize);
+ defaultSetting.setAddressFullMessagePolicy(fullPolicy);
+
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+ return server;
+ }
+
+ protected HornetQServer createServer(final boolean realFiles,
+ final Configuration configuration,
+ final MBeanServer mbeanServer,
+ final Map<String, AddressSettings> settings)
+ {
+ HornetQServer server;
+
+ if (realFiles)
+ {
+ server = HornetQServers.newHornetQServer(configuration, mbeanServer);
+ }
+ else
+ {
+ server = HornetQServers.newHornetQServer(configuration, mbeanServer, false);
+ }
+
+ for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
+ {
+ server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
+ }
+
+ AddressSettings defaultSetting = new AddressSettings();
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+ return server;
+ }
+
+ protected HornetQServer createServer(final boolean realFiles)
+ {
+ return createServer(realFiles, false);
+ }
+
+ protected HornetQServer createServer(final boolean realFiles, final boolean netty)
+ {
+ return createServer(realFiles, createDefaultConfig(netty), -1, -1, new HashMap<String, AddressSettings>());
+ }
+
+ protected HornetQServer createServer(final boolean realFiles, final Configuration configuration)
+ {
+ return createServer(realFiles, configuration, -1, -1, new HashMap<String, AddressSettings>());
+ }
+
+ protected HornetQServer createInVMFailoverServer(final boolean realFiles,
+ final Configuration configuration,
+ final NodeManager nodeManager,
+ final int id)
+ {
+ return createInVMFailoverServer(realFiles,
+ configuration,
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>(),
+ nodeManager,
+ id);
+ }
+
+ protected HornetQServer createInVMFailoverServer(final boolean realFiles,
+ final Configuration configuration,
+ final int pageSize,
+ final int maxAddressSize,
+ final Map<String, AddressSettings> settings,
+ NodeManager nodeManager,
+ final int id)
+ {
+ HornetQServer server;
+ HornetQSecurityManager securityManager = new HornetQSecurityManagerImpl();
+ configuration.setPersistenceEnabled(realFiles);
+ server = new InVMNodeManagerServer(configuration,
+ ManagementFactory.getPlatformMBeanServer(),
+ securityManager,
+ nodeManager);
+
+ server.setIdentity("Server " + id);
+
+ for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
+ {
+ server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
+ }
+
+ AddressSettings defaultSetting = new AddressSettings();
+ defaultSetting.setPageSizeBytes(pageSize);
+ defaultSetting.setMaxSizeBytes(maxAddressSize);
+
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+ return server;
+ }
+
+ protected HornetQServer createServer(final boolean realFiles,
+ final Configuration configuration,
+ final HornetQSecurityManager securityManager)
+ {
+ HornetQServer server;
+
+ if (realFiles)
+ {
+ server = HornetQServers.newHornetQServer(configuration,
+ ManagementFactory.getPlatformMBeanServer(),
+ securityManager);
+ }
+ else
+ {
+ server = HornetQServers.newHornetQServer(configuration,
+ ManagementFactory.getPlatformMBeanServer(),
+ securityManager,
+ false);
+ }
+
+ Map<String, AddressSettings> settings = new HashMap<String, AddressSettings>();
+
+ for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
+ {
+ server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
+ }
+
+ AddressSettings defaultSetting = new AddressSettings();
+
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+ return server;
+ }
+
+ protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
+ final int index,
+ final boolean realFiles,
+ final Map<String, Object> params)
+ {
+ if (isNetty)
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params, NETTY_ACCEPTOR_FACTORY),
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>());
+ }
+ else
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params, INVM_ACCEPTOR_FACTORY),
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>());
+ }
+ }
+
+ protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
+ final int index,
+ final boolean realFiles,
+ final int pageSize,
+ final int maxAddressSize,
+ final Map<String, Object> params)
+ {
+ if (isNetty)
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params, NETTY_ACCEPTOR_FACTORY),
+ pageSize,
+ maxAddressSize,
+ new HashMap<String, AddressSettings>());
+ }
+ else
+ {
+ return createServer(realFiles,
+ createClusteredDefaultConfig(index, params, INVM_ACCEPTOR_FACTORY),
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>());
+ }
+ }
+
+ protected ServerLocator createFactory(final boolean isNetty) throws Exception
+ {
+ if (isNetty)
+ {
+ return createNettyNonHALocator();
+ }
+ else
+ {
+ return createInVMNonHALocator();
+ }
+ }
+
+ protected void createQueue(final String address, final String queue) throws Exception
+ {
+ ServerLocator locator = createInVMNonHALocator();
+ ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSession session = sf.createSession();
+ session.createQueue(address, queue);
+ session.close();
+ sf.close();
+ locator.close();
+ }
+
+ protected ServerLocator createInVMNonHALocator()
+ {
+ return createNonHALocator(false);
+ }
+
+ protected ServerLocator createNettyNonHALocator()
+ {
+ return createNonHALocator(true);
+ }
+
+ protected ServerLocator createNonHALocator(final boolean isNetty)
+ {
+ ServerLocator locatorWithoutHA = isNetty ? HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY))
+ : HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
+ locators.add(locatorWithoutHA);
+ return locatorWithoutHA;
+ }
+
+ protected ServerLocator createInVMLocator(final int serverID)
+ {
+ TransportConfiguration tnspConfig = createInVMTransportConnectorConfig(serverID, UUIDGenerator.getInstance().generateStringUUID());
+
+ return HornetQClient.createServerLocatorWithHA(tnspConfig);
+ }
+
+ /**
+ * @param serverID
+ * @return
+ */
+ protected TransportConfiguration createInVMTransportConnectorConfig(final int serverID, String name)
+ {
+ Map<String, Object> server1Params = new HashMap<String, Object>();
+
+ if (serverID != 0)
+ {
+ server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, serverID);
+ }
+
+ TransportConfiguration tnspConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY, server1Params, name);
+ return tnspConfig;
+ }
+
+ // XXX unused
+ protected ClientSessionFactoryImpl createFactory(final String connectorClass) throws Exception
+ {
+ ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorClass));
+ return (ClientSessionFactoryImpl)locator.createSessionFactory();
+
+ }
+ public String getTextMessage(final ClientMessage m)
+ {
+ m.getBodyBuffer().resetReaderIndex();
+ return m.getBodyBuffer().readString();
+ }
+
+ protected ClientMessage createBytesMessage(final ClientSession session,
+ final byte type,
+ final byte[] b,
+ final boolean durable)
+ {
+ ClientMessage message = session.createMessage(type, durable, 0, System.currentTimeMillis(), (byte)1);
+ message.getBodyBuffer().writeBytes(b);
+ return message;
+ }
+
+ /**
+ * @param i
+ * @param message
+ * @throws Exception
+ */
+ protected void setBody(final int i, final ClientMessage message) throws Exception
+ {
+ message.getBodyBuffer().writeString("message" + i);
+ }
+
+ /**
+ * @param i
+ * @param message
+ */
+ protected void assertMessageBody(final int i, final ClientMessage message)
+ {
+ Assert.assertEquals(message.toString(), "message" + i, message.getBodyBuffer().readString());
+ }
+
+ /**
+ * Send durable messages with pre-specified body.
+ * @param session
+ * @param producer
+ * @param numMessages
+ * @throws Exception
+ */
+ public final void sendMessages(ClientSession session, ClientProducer producer, int numMessages) throws Exception
+ {
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ setBody(i, message);
+ message.putIntProperty("counter", i);
+ producer.send(message);
+ }
+ }
+
+
+ protected final void receiveMessagesAndAck(ClientConsumer consumer, final int start, int msgCount)
+ throws HornetQException
+ {
+ for (int i = start; i < msgCount; i++)
+ {
+ ClientMessage message = consumer.receive(1000);
+ Assert.assertNotNull("Expecting a message " + i, message);
+ assertMessageBody(i, message);
+ Assert.assertEquals(i, message.getIntProperty("counter").intValue());
+ message.acknowledge();
+ }
+ }
+
+ /**
+ * Deleting a file on LargeDire is an asynchronous process. We need to keep looking for a while
+ * if the file hasn't been deleted yet.
+ */
+ protected void validateNoFilesOnLargeDir(final int expect) throws Exception
+ {
+ File largeMessagesFileDir = new File(getLargeMessagesDir());
+
+ // Deleting the file is async... we keep looking for a period of the time until the file is really gone
+ long timeout = System.currentTimeMillis() + 5000;
+ while (timeout > System.currentTimeMillis() && largeMessagesFileDir.listFiles().length != expect)
+ {
+ Thread.sleep(100);
+ }
+
+
+ if (expect != largeMessagesFileDir.listFiles().length)
+ {
+ for (File file : largeMessagesFileDir.listFiles())
+ {
+ System.out.println("File " + file + " still on ");
+ }
+ }
+
+ Assert.assertEquals(expect, largeMessagesFileDir.listFiles().length);
+ }
+
+ /**
+ * Deleting a file on LargeDire is an asynchronous process. Wee need to keep looking for a while
+ * if the file hasn't been deleted yet
+ */
+ protected void validateNoFilesOnLargeDir() throws Exception
+ {
+ validateNoFilesOnLargeDir(0);
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+ class InVMNodeManagerServer extends HornetQServerImpl
+ {
+ final NodeManager nodeManager;
+
+ public InVMNodeManagerServer(final NodeManager nodeManager)
+ {
+ super();
+ this.nodeManager = nodeManager;
+ }
+
+ public InVMNodeManagerServer(final Configuration configuration, final NodeManager nodeManager)
+ {
+ super(configuration);
+ this.nodeManager = nodeManager;
+ }
+
+ public InVMNodeManagerServer(final Configuration configuration,
+ final MBeanServer mbeanServer,
+ final NodeManager nodeManager)
+ {
+ super(configuration, mbeanServer);
+ this.nodeManager = nodeManager;
+ }
+
+ public InVMNodeManagerServer(final Configuration configuration,
+ final HornetQSecurityManager securityManager,
+ final NodeManager nodeManager)
+ {
+ super(configuration, securityManager);
+ this.nodeManager = nodeManager;
+ }
+
+ public InVMNodeManagerServer(final Configuration configuration,
+ final MBeanServer mbeanServer,
+ final HornetQSecurityManager securityManager,
+ final NodeManager nodeManager)
+ {
+ super(configuration, mbeanServer, securityManager);
+ this.nodeManager = nodeManager;
+ }
+
+ @Override
+ protected NodeManager createNodeManager(final String directory)
+ {
+ return nodeManager;
+ }
+
+ }
+}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-10-21 14:24:50 UTC (rev 11575)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-10-21 15:34:20 UTC (rev 11576)
@@ -568,7 +568,7 @@
if (holder != null)
{
- holder.consumer.close();
+ holder.close();
// holder.session.close();
consumers[i] = null;
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/DeleteQueueRestartTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/DeleteQueueRestartTest.java 2011-10-21 14:24:50 UTC (rev 11575)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/DeleteQueueRestartTest.java 2011-10-21 15:34:20 UTC (rev 11576)
@@ -19,15 +19,20 @@
import junit.framework.Assert;
import org.hornetq.api.core.HornetQException;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.jms.client.HornetQBytesMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
* A DeleteMessagesRestartTest
*
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
+ *
* Created Mar 2, 2009 10:14:38 AM
*
*
@@ -81,7 +86,7 @@
for (int i = 0; i < 100; i++)
{
- ClientMessage msg = createBytesMessage(session, new byte[0], true);
+ ClientMessage msg = createBytesMessage(session, HornetQBytesMessage.TYPE, new byte[0], true);
prod.send(msg);
}
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java 2011-10-21 14:24:50 UTC (rev 11575)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java 2011-10-21 15:34:20 UTC (rev 11576)
@@ -28,11 +28,12 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.jms.client.HornetQBytesMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
* This is an integration-tests that will take some time to run.
- *
+ *
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
*/
public class PageStressTest extends ServiceTestBase
@@ -84,7 +85,7 @@
ClientProducer prod = session.createProducer(address);
- ClientMessage message = createBytesMessage(session, new byte[700], true);
+ ClientMessage message = createBytesMessage(session, HornetQBytesMessage.TYPE, new byte[700], true);
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
@@ -199,7 +200,7 @@
ClientProducer prod = session.createProducer(address);
- ClientMessage message = createBytesMessage(session, new byte[700], false);
+ ClientMessage message = createBytesMessage(session, HornetQBytesMessage.TYPE, new byte[700], false);
int NUMBER_OF_MESSAGES = 60000;
@@ -299,7 +300,7 @@
clearData();
locator = createInVMNonHALocator();
-
+
locator.setBlockOnAcknowledge(true);
locator.setBlockOnDurableSend(false);
locator.setBlockOnNonDurableSend(false);
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-10-21 14:24:50 UTC (rev 11575)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-10-21 15:34:20 UTC (rev 11576)
@@ -1,812 +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.util;
-
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-
-import junit.framework.Assert;
-
-import org.hornetq.api.core.HornetQException;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.ClientConsumer;
-import org.hornetq.api.core.client.ClientMessage;
-import org.hornetq.api.core.client.ClientProducer;
-import org.hornetq.api.core.client.ClientSession;
-import org.hornetq.api.core.client.ClientSessionFactory;
-import org.hornetq.api.core.client.HornetQClient;
-import org.hornetq.api.core.client.ServerLocator;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.client.impl.Topology;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
-import org.hornetq.core.remoting.impl.invm.InVMRegistry;
-import org.hornetq.core.remoting.impl.invm.TransportConstants;
-import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
-import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
-import org.hornetq.core.server.HornetQComponent;
-import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
-import org.hornetq.core.server.NodeManager;
-import org.hornetq.core.server.cluster.ClusterConnection;
-import org.hornetq.core.server.impl.HornetQServerImpl;
-import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
-import org.hornetq.core.settings.impl.AddressSettings;
-import org.hornetq.jms.client.HornetQBytesMessage;
-import org.hornetq.spi.core.security.HornetQSecurityManager;
-import org.hornetq.spi.core.security.HornetQSecurityManagerImpl;
-import org.hornetq.utils.UUIDGenerator;
-
-/**
- *
- * Base class with basic utilities on starting up a basic server
- *
- * @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
- *
- */
-public abstract class ServiceTestBase extends UnitTestCase
-{
-
- // Constants -----------------------------------------------------
-
- protected static final long WAIT_TIMEOUT = 10000;
-
-
- // Attributes ----------------------------------------------------
-
- protected static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
-
- public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
-
- protected static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
-
- protected static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
-
- private final List<ServerLocator> locators = new ArrayList<ServerLocator>();
-
- @Override
- protected void tearDown() throws Exception
- {
- for (ServerLocator locator : locators)
- {
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- locators.clear();
- super.tearDown();
-// checkFreePort(5445);
-// checkFreePort(5446);
-// checkFreePort(5447);
- if (InVMRegistry.instance.size() > 0)
- {
- fail("InVMREgistry size > 0");
- }
- }
-
- public static final void closeServerLocator(ServerLocator locator)
- {
- if (locator == null)
- return;
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- protected void waitForTopology(final HornetQServer server, final int nodes) throws Exception
- {
- waitForTopology(server, nodes, WAIT_TIMEOUT);
- }
-
- protected void waitForTopology(final HornetQServer server, final int nodes, final long timeout) throws Exception
- {
- log.debug("waiting for " + nodes + " on the topology for server = " + server);
-
- long start = System.currentTimeMillis();
-
- Set<ClusterConnection> ccs = server.getClusterManager().getClusterConnections();
-
- if (ccs.size() != 1)
- {
- throw new IllegalStateException("You need a single cluster connection on this version of waitForTopology on ServiceTestBase");
- }
-
- Topology topology = ccs.iterator().next().getTopology();
-
- do
- {
- if (nodes == topology.getMembers().size())
- {
- return;
- }
-
- Thread.sleep(10);
- }
- while (System.currentTimeMillis() - start < timeout);
-
- String msg = "Timed out waiting for cluster topology of " + nodes +
- " (received " +
- topology.getMembers().size() +
- ") topology = " +
- topology +
- ")";
-
- log.error(msg);
-
- throw new Exception(msg);
- }
-
-
- protected void waitForTopology(final HornetQServer server, String clusterConnectionName, final int nodes, final long timeout) throws Exception
- {
- log.debug("waiting for " + nodes + " on the topology for server = " + server);
-
- long start = System.currentTimeMillis();
-
- ClusterConnection clusterConnection = server.getClusterManager().getClusterConnection(clusterConnectionName);
-
-
- Topology topology = clusterConnection.getTopology();
-
- do
- {
- if (nodes == topology.getMembers().size())
- {
- return;
- }
-
- Thread.sleep(10);
- }
- while (System.currentTimeMillis() - start < timeout);
-
- String msg = "Timed out waiting for cluster topology of " + nodes +
- " (received " +
- topology.getMembers().size() +
- ") topology = " +
- topology +
- ")";
-
- log.error(msg);
-
- throw new Exception(msg);
- }
-
- protected final static void waitForComponent(final HornetQComponent component, final long seconds) throws Exception
- {
- long time = System.currentTimeMillis();
- long toWait = seconds * 1000;
- while (!component.isStarted())
- {
- try
- {
- Thread.sleep(50);
- }
- catch (InterruptedException e)
- {
- // ignore
- }
- if (System.currentTimeMillis() > (time + toWait))
- {
- fail("component did not start within timeout of " + seconds);
- }
- }
- }
-
- protected static final void stopComponent(HornetQComponent component)
- {
- if (component == null)
- return;
- if (component.isStarted())
- try
- {
- component.stop();
- }
- catch (Exception e)
- {
- // no-op
- }
- }
-
- protected static Map<String, Object> generateParams(final int node, final boolean netty)
- {
- Map<String, Object> params = new HashMap<String, Object>();
-
- if (netty)
- {
- params.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME,
- org.hornetq.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + node);
- }
- else
- {
- params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, node);
- }
-
- return params;
- }
-
- protected static TransportConfiguration createTransportConfiguration(boolean netty,
- boolean acceptor,
- Map<String, Object> params)
- {
- String className;
- if (netty)
- {
- if (acceptor)
- {
- className = NettyAcceptorFactory.class.getName();
- }
- else
- {
- className = NettyConnectorFactory.class.getName();
- }
- }
- else
- {
- if (acceptor)
- {
- className = InVMAcceptorFactory.class.getName();
- }
- else
- {
- className = InVMConnectorFactory.class.getName();
- }
- }
- return new TransportConfiguration(className, params);
- }
-
- // Static --------------------------------------------------------
- private final Logger log = Logger.getLogger(this.getClass());
-
- // Constructors --------------------------------------------------
-
- public ServiceTestBase()
- {
- super();
- }
-
- public ServiceTestBase(final String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void waitForServer(HornetQServer server) throws InterruptedException
- {
- long timetowait = System.currentTimeMillis() + 5000;
- while (!server.isStarted() && System.currentTimeMillis() < timetowait)
- {
- Thread.sleep(100);
- }
-
- if (!server.isStarted())
- {
- log.info(threadDump("Server didn't start"));
- fail("server didnt start");
- }
-
- if (!server.getConfiguration().isBackup())
- {
- timetowait = System.currentTimeMillis() + 5000;
- while (!server.isInitialised() && System.currentTimeMillis() < timetowait)
- {
- Thread.sleep(100);
- }
-
- if (!server.isInitialised())
- {
- fail("Server didn't initialize");
- }
- }
- }
-
-
- protected HornetQServer createServer(final boolean realFiles,
- final Configuration configuration,
- final int pageSize,
- final int maxAddressSize,
- final Map<String, AddressSettings> settings,
- final MBeanServer mbeanServer)
- {
- HornetQServer server;
-
- if (realFiles)
- {
- server = HornetQServers.newHornetQServer(configuration, mbeanServer, true);
- }
- else
- {
- server = HornetQServers.newHornetQServer(configuration, mbeanServer, false);
- }
-
- for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
- {
- server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
- }
-
- AddressSettings defaultSetting = new AddressSettings();
- defaultSetting.setPageSizeBytes(pageSize);
- defaultSetting.setMaxSizeBytes(maxAddressSize);
-
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-
- protected HornetQServer createServer(final boolean realFiles,
- final Configuration configuration,
- final int pageSize,
- final int maxAddressSize,
- final Map<String, AddressSettings> settings)
- {
- return createServer(realFiles, configuration, pageSize, maxAddressSize, AddressFullMessagePolicy.PAGE, settings);
- }
-
- protected HornetQServer createServer(final boolean realFiles,
- final Configuration configuration,
- final int pageSize,
- final int maxAddressSize,
- final AddressFullMessagePolicy fullPolicy,
- final Map<String, AddressSettings> settings)
- {
- HornetQServer server;
-
- if (realFiles)
- {
- server = HornetQServers.newHornetQServer(configuration);
- }
- else
- {
- server = HornetQServers.newHornetQServer(configuration, false);
- }
-
- if (settings != null)
- {
- for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
- {
- server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
- }
- }
-
- AddressSettings defaultSetting = new AddressSettings();
- defaultSetting.setPageSizeBytes(pageSize);
- defaultSetting.setMaxSizeBytes(maxAddressSize);
- defaultSetting.setAddressFullMessagePolicy(fullPolicy);
-
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-
- protected HornetQServer createServer(final boolean realFiles,
- final Configuration configuration,
- final MBeanServer mbeanServer,
- final Map<String, AddressSettings> settings)
- {
- HornetQServer server;
-
- if (realFiles)
- {
- server = HornetQServers.newHornetQServer(configuration, mbeanServer);
- }
- else
- {
- server = HornetQServers.newHornetQServer(configuration, mbeanServer, false);
- }
-
- for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
- {
- server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
- }
-
- AddressSettings defaultSetting = new AddressSettings();
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-
- protected HornetQServer createServer(final boolean realFiles)
- {
- return createServer(realFiles, false);
- }
-
- protected HornetQServer createServer(final boolean realFiles, final boolean netty)
- {
- return createServer(realFiles, createDefaultConfig(netty), -1, -1, new HashMap<String, AddressSettings>());
- }
-
- protected HornetQServer createServer(final boolean realFiles, final Configuration configuration)
- {
- return createServer(realFiles, configuration, -1, -1, new HashMap<String, AddressSettings>());
- }
-
- protected HornetQServer createInVMFailoverServer(final boolean realFiles,
- final Configuration configuration,
- final NodeManager nodeManager,
- final int id)
- {
- return createInVMFailoverServer(realFiles,
- configuration,
- -1,
- -1,
- new HashMap<String, AddressSettings>(),
- nodeManager,
- id);
- }
-
- protected HornetQServer createInVMFailoverServer(final boolean realFiles,
- final Configuration configuration,
- final int pageSize,
- final int maxAddressSize,
- final Map<String, AddressSettings> settings,
- NodeManager nodeManager,
- final int id)
- {
- HornetQServer server;
- HornetQSecurityManager securityManager = new HornetQSecurityManagerImpl();
- configuration.setPersistenceEnabled(realFiles);
- server = new InVMNodeManagerServer(configuration,
- ManagementFactory.getPlatformMBeanServer(),
- securityManager,
- nodeManager);
-
- server.setIdentity("Server " + id);
-
- for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
- {
- server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
- }
-
- AddressSettings defaultSetting = new AddressSettings();
- defaultSetting.setPageSizeBytes(pageSize);
- defaultSetting.setMaxSizeBytes(maxAddressSize);
-
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-
- protected HornetQServer createServer(final boolean realFiles,
- final Configuration configuration,
- final HornetQSecurityManager securityManager)
- {
- HornetQServer server;
-
- if (realFiles)
- {
- server = HornetQServers.newHornetQServer(configuration,
- ManagementFactory.getPlatformMBeanServer(),
- securityManager);
- }
- else
- {
- server = HornetQServers.newHornetQServer(configuration,
- ManagementFactory.getPlatformMBeanServer(),
- securityManager,
- false);
- }
-
- Map<String, AddressSettings> settings = new HashMap<String, AddressSettings>();
-
- for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
- {
- server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
- }
-
- AddressSettings defaultSetting = new AddressSettings();
-
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-
- protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
- final int index,
- final boolean realFiles,
- final Map<String, Object> params)
- {
- if (isNetty)
- {
- return createServer(realFiles,
- createClusteredDefaultConfig(index, params, NETTY_ACCEPTOR_FACTORY),
- -1,
- -1,
- new HashMap<String, AddressSettings>());
- }
- else
- {
- return createServer(realFiles,
- createClusteredDefaultConfig(index, params, INVM_ACCEPTOR_FACTORY),
- -1,
- -1,
- new HashMap<String, AddressSettings>());
- }
- }
-
- protected HornetQServer createClusteredServerWithParams(final boolean isNetty,
- final int index,
- final boolean realFiles,
- final int pageSize,
- final int maxAddressSize,
- final Map<String, Object> params)
- {
- if (isNetty)
- {
- return createServer(realFiles,
- createClusteredDefaultConfig(index, params, NETTY_ACCEPTOR_FACTORY),
- pageSize,
- maxAddressSize,
- new HashMap<String, AddressSettings>());
- }
- else
- {
- return createServer(realFiles,
- createClusteredDefaultConfig(index, params, INVM_ACCEPTOR_FACTORY),
- -1,
- -1,
- new HashMap<String, AddressSettings>());
- }
- }
-
- protected ServerLocator createFactory(final boolean isNetty) throws Exception
- {
- if (isNetty)
- {
- return createNettyNonHALocator();
- }
- else
- {
- return createInVMNonHALocator();
- }
- }
-
- protected void createQueue(final String address, final String queue) throws Exception
- {
- ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory sf = locator.createSessionFactory();
- ClientSession session = sf.createSession();
- session.createQueue(address, queue);
- session.close();
- sf.close();
- locator.close();
- }
-
- protected ServerLocator createInVMNonHALocator()
- {
- return createNonHALocator(false);
- }
-
- protected ServerLocator createNettyNonHALocator()
- {
- return createNonHALocator(true);
- }
-
- protected ServerLocator createNonHALocator(final boolean isNetty)
- {
- ServerLocator locatorWithoutHA = isNetty ? HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY))
- : HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
- locators.add(locatorWithoutHA);
- return locatorWithoutHA;
- }
-
- protected ServerLocator createInVMLocator(final int serverID)
- {
- TransportConfiguration tnspConfig = createInVMTransportConnectorConfig(serverID, UUIDGenerator.getInstance().generateStringUUID());
-
- return HornetQClient.createServerLocatorWithHA(tnspConfig);
- }
-
- /**
- * @param serverID
- * @return
- */
- protected TransportConfiguration createInVMTransportConnectorConfig(final int serverID, String name)
- {
- Map<String, Object> server1Params = new HashMap<String, Object>();
-
- if (serverID != 0)
- {
- server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, serverID);
- }
-
- TransportConfiguration tnspConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY, server1Params, name);
- return tnspConfig;
- }
-
- // XXX unused
- protected ClientSessionFactoryImpl createFactory(final String connectorClass) throws Exception
- {
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorClass));
- return (ClientSessionFactoryImpl)locator.createSessionFactory();
-
- }
- public String getTextMessage(final ClientMessage m)
- {
- m.getBodyBuffer().resetReaderIndex();
- return m.getBodyBuffer().readString();
- }
-
- protected ClientMessage createBytesMessage(final ClientSession session, final byte[] b, final boolean durable)
- {
- ClientMessage message = session.createMessage(HornetQBytesMessage.TYPE,
- durable,
- 0,
- System.currentTimeMillis(),
- (byte)1);
- message.getBodyBuffer().writeBytes(b);
- return message;
- }
-
- /**
- * @param i
- * @param message
- * @throws Exception
- */
- protected void setBody(final int i, final ClientMessage message) throws Exception
- {
- message.getBodyBuffer().writeString("message" + i);
- }
-
- /**
- * @param i
- * @param message
- */
- protected void assertMessageBody(final int i, final ClientMessage message)
- {
- Assert.assertEquals(message.toString(), "message" + i, message.getBodyBuffer().readString());
- }
-
- /**
- * Send durable messages with pre-specified body.
- * @param session
- * @param producer
- * @param numMessages
- * @throws Exception
- */
- public final void sendMessages(ClientSession session, ClientProducer producer, int numMessages) throws Exception
- {
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session.createMessage(true);
- setBody(i, message);
- message.putIntProperty("counter", i);
- producer.send(message);
- }
- }
-
-
- protected final void receiveMessagesAndAck(ClientConsumer consumer, final int start, int msgCount)
- throws HornetQException
- {
- for (int i = start; i < msgCount; i++)
- {
- ClientMessage message = consumer.receive(1000);
- Assert.assertNotNull("Expecting a message " + i, message);
- assertMessageBody(i, message);
- Assert.assertEquals(i, message.getIntProperty("counter").intValue());
- message.acknowledge();
- }
- }
-
- /**
- * Deleting a file on LargeDire is an asynchronous process. We need to keep looking for a while
- * if the file hasn't been deleted yet.
- */
- protected void validateNoFilesOnLargeDir(final int expect) throws Exception
- {
- File largeMessagesFileDir = new File(getLargeMessagesDir());
-
- // Deleting the file is async... we keep looking for a period of the time until the file is really gone
- long timeout = System.currentTimeMillis() + 5000;
- while (timeout > System.currentTimeMillis() && largeMessagesFileDir.listFiles().length != expect)
- {
- Thread.sleep(100);
- }
-
-
- if (expect != largeMessagesFileDir.listFiles().length)
- {
- for (File file : largeMessagesFileDir.listFiles())
- {
- System.out.println("File " + file + " still on ");
- }
- }
-
- Assert.assertEquals(expect, largeMessagesFileDir.listFiles().length);
- }
-
- /**
- * Deleting a file on LargeDire is an asynchronous process. Wee need to keep looking for a while
- * if the file hasn't been deleted yet
- */
- protected void validateNoFilesOnLargeDir() throws Exception
- {
- validateNoFilesOnLargeDir(0);
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
- class InVMNodeManagerServer extends HornetQServerImpl
- {
- final NodeManager nodeManager;
-
- public InVMNodeManagerServer(final NodeManager nodeManager)
- {
- super();
- this.nodeManager = nodeManager;
- }
-
- public InVMNodeManagerServer(final Configuration configuration, final NodeManager nodeManager)
- {
- super(configuration);
- this.nodeManager = nodeManager;
- }
-
- public InVMNodeManagerServer(final Configuration configuration,
- final MBeanServer mbeanServer,
- final NodeManager nodeManager)
- {
- super(configuration, mbeanServer);
- this.nodeManager = nodeManager;
- }
-
- public InVMNodeManagerServer(final Configuration configuration,
- final HornetQSecurityManager securityManager,
- final NodeManager nodeManager)
- {
- super(configuration, securityManager);
- this.nodeManager = nodeManager;
- }
-
- public InVMNodeManagerServer(final Configuration configuration,
- final MBeanServer mbeanServer,
- final HornetQSecurityManager securityManager,
- final NodeManager nodeManager)
- {
- super(configuration, mbeanServer, securityManager);
- this.nodeManager = nodeManager;
- }
-
- @Override
- protected NodeManager createNodeManager(final String directory)
- {
- return nodeManager;
- }
-
- }
-}
13 years, 2 months
JBoss hornetq SVN: r11575 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-21 10:24:50 -0400 (Fri, 21 Oct 2011)
New Revision: 11575
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java
Log:
JBPAPP-7353 Use Semaphore instead of Lock.
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java 2011-10-21 14:14:30 UTC (rev 11574)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/impl/netty/NettyConnection.java 2011-10-21 14:24:50 UTC (rev 11575)
@@ -14,8 +14,7 @@
package org.hornetq.core.remoting.impl.netty;
import java.util.Set;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.Semaphore;
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQBuffers;
@@ -61,7 +60,7 @@
private volatile HornetQBuffer batchBuffer;
- private final Lock writeLock = new ReentrantLock();
+ private final Semaphore writeLock = new Semaphore(1);
private Set<ReadyListener> readyListeners = new ConcurrentHashSet<ReadyListener>();
@@ -153,7 +152,7 @@
return;
}
- if (writeLock.tryLock())
+ if (writeLock.tryAcquire())
{
try
{
@@ -166,7 +165,7 @@
}
finally
{
- writeLock.unlock();
+ writeLock.release();
}
}
}
@@ -179,7 +178,8 @@
public void write(HornetQBuffer buffer, final boolean flush, final boolean batched)
{
- writeLock.lock();
+ try {
+ writeLock.acquire();
try
{
@@ -240,9 +240,14 @@
}
}
}
- finally
+ finally
+ {
+ writeLock.release();
+ }
+ }
+ catch (InterruptedException e)
{
- writeLock.unlock();
+ Thread.currentThread().interrupt();
}
}
13 years, 2 months