JBoss hornetq SVN: r10851 - branches/Branch_2_2_AS7.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-06-17 12:47:24 -0400 (Fri, 17 Jun 2011)
New Revision: 10851
Modified:
branches/Branch_2_2_AS7/build-maven.xml
Log:
added info to pom deploy
Modified: branches/Branch_2_2_AS7/build-maven.xml
===================================================================
--- branches/Branch_2_2_AS7/build-maven.xml 2011-06-17 16:38:19 UTC (rev 10850)
+++ branches/Branch_2_2_AS7/build-maven.xml 2011-06-17 16:47:24 UTC (rev 10851)
@@ -280,7 +280,34 @@
<modelVersion>4.0.0</modelVersion>${line.separator}
<groupId>org.hornetq</groupId>${line.separator}
<artifactId>${artifact.id}</artifactId>${line.separator}
- <version>${hornetq.version}</version>${line.separator}</project>"/>
+ <version>${hornetq.version}</version>${line.separator}
+ <name>HornetQ</name>${line.separator}
+ <url>http://hornetq.org</url>${line.separator}
+ <description>HornetQ Messaging System</description>${line.separator}
+ <licenses>${line.separator}
+ <license>${line.separator}
+ <name>Apache 2</name>${line.separator}
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>${line.s...
+ <distribution>repo</distribution>${line.separator}
+ </license>${line.separator}
+ </licenses>${line.separator}
+ <developers>${line.separator}
+ <developer>${line.separator}
+ <name>Clebert Suconic</name>${line.separator}
+ </developer>${line.separator}
+ <developer>${line.separator}
+ <name>Andy Taylor</name>${line.separator}
+ </developer>${line.separator}
+ <developer>${line.separator}
+ <name>Howard Gao</name>${line.separator}
+ </developer>${line.separator}
+ </developers>${line.separator}
+ <scm>${line.separator}
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/hornetq/trunk</co...
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/hornetq/trunk&...
+ <url>http://fisheye.jboss.org/browse/hornetq</url>${line.separator}
+ </scm>${line.separator}
+ </project>"/>
<!-- deploy the jar -->
<exec executable="mvn">
13 years, 6 months
JBoss hornetq SVN: r10850 - in branches/Branch_2_2_EAP_cluster_clean2: tests/src/org/hornetq/tests/integration/cluster/distribution and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-06-17 12:38:19 -0400 (Fri, 17 Jun 2011)
New Revision: 10850
Added:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java
Log:
tweaks
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-06-17 16:37:51 UTC (rev 10849)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-06-17 16:38:19 UTC (rev 10850)
@@ -316,7 +316,14 @@
initialisePart2();
- log.info("Server is now live");
+ if (identity != null)
+ {
+ log.info("Server " + identity + " is now live");
+ }
+ else
+ {
+ log.info("Server is now live");
+ }
}
catch (Exception e)
{
@@ -1134,7 +1141,7 @@
activateCallbacks.remove(callback);
}
- public synchronized ExecutorFactory getExecutorFactory()
+ public ExecutorFactory getExecutorFactory()
{
return executorFactory;
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-06-17 16:37:51 UTC (rev 10849)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-06-17 16:38:19 UTC (rev 10850)
@@ -248,15 +248,16 @@
final int consumerCount,
final boolean local) throws Exception
{
- // System.out.println("waiting for bindings on node " + node +
- // " address " +
- // address +
- // " count " +
- // count +
- // " consumerCount " +
- // consumerCount +
- // " local " +
- // local);
+ log.debug("waiting for bindings on node " + node +
+ " address " +
+ address +
+ " count " +
+ count +
+ " consumerCount " +
+ consumerCount +
+ " local " +
+ local);
+
HornetQServer server = servers[node];
if (server == null)
@@ -301,11 +302,9 @@
}
while (System.currentTimeMillis() - start < ClusterTestBase.WAIT_TIMEOUT);
- // System.out.println(threadDump(" - fired by ClusterTestBase::waitForBindings"));
-
- String msg = "Timed out waiting for bindings (bindingCount = " + bindingCount +
+ String msg = "Timed out waiting for bindings (bindingCount = " + bindingCount + " (expecting " + count + ") "+
", totConsumers = " +
- totConsumers +
+ totConsumers + " (expecting " + consumerCount + ")" +
")";
ClusterTestBase.log.error(msg);
@@ -1714,6 +1713,32 @@
pairs.add(serverTotc.getName());
}
+ ClusterConnectionConfiguration clusterConf = createClusterConfig(name,
+ address,
+ forwardWhenNoConsumers,
+ maxHops,
+ connectorFrom,
+ pairs);
+
+ serverFrom.getConfiguration().getClusterConfigurations().add(clusterConf);
+ }
+
+ /**
+ * @param name
+ * @param address
+ * @param forwardWhenNoConsumers
+ * @param maxHops
+ * @param connectorFrom
+ * @param pairs
+ * @return
+ */
+ protected ClusterConnectionConfiguration createClusterConfig(final String name,
+ final String address,
+ final boolean forwardWhenNoConsumers,
+ final int maxHops,
+ TransportConfiguration connectorFrom,
+ List<String> pairs)
+ {
ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration(name,
address,
connectorFrom.getName(),
@@ -1723,8 +1748,7 @@
maxHops,
1024,
pairs, false);
-
- serverFrom.getConfiguration().getClusterConfigurations().add(clusterConf);
+ return clusterConf;
}
protected void setupClusterConnectionWithBackups(final String name,
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java 2011-06-17 16:37:51 UTC (rev 10849)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/OnewayTwoNodeClusterTest.java 2011-06-17 16:38:19 UTC (rev 10850)
@@ -47,6 +47,7 @@
@Override
protected void tearDown() throws Exception
{
+ log.info("#test Tear down");
closeAllConsumers();
closeAllSessionFactories();
@@ -98,6 +99,20 @@
verifyNotReceive(0);
}
+ public void testLoop() throws Exception
+ {
+ for (int i = 0 ; i < 10; i++)
+ {
+ log.info("#test " + i);
+ testStartSourceServerBeforeTargetServer();
+ if (i + 1 < 100000)
+ {
+ tearDown();
+ setUp();
+ }
+ }
+
+ }
public void testStartSourceServerBeforeTargetServer() throws Exception
{
startServers(0, 1);
Added: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java (rev 0)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java 2011-06-17 16:38:19 UTC (rev 10850)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2010 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.integration.cluster.distribution;
+
+import java.util.List;
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.config.ClusterConnectionConfiguration;
+
+/**
+ * A SimpleSymmetricClusterTest
+ *
+ * @author clebert
+ *
+ *
+ */
+public class SimpleSymmetricClusterTest extends ClusterTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ setupServer(0, true, isNetty());
+ setupServer(1, true, isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1);
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0);
+
+ startServers(1, 0);
+ }
+
+
+ /**
+ * @param name
+ * @param address
+ * @param forwardWhenNoConsumers
+ * @param maxHops
+ * @param connectorFrom
+ * @param pairs
+ * @return
+ */
+ protected ClusterConnectionConfiguration createClusterConfig(final String name,
+ final String address,
+ final boolean forwardWhenNoConsumers,
+ final int maxHops,
+ TransportConfiguration connectorFrom,
+ List<String> pairs)
+ {
+ ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration(name,
+ address,
+ connectorFrom.getName(),
+ 2000,
+ true,
+ forwardWhenNoConsumers,
+ maxHops,
+ 1024,
+ pairs, false);
+ return clusterConf;
+ }
+
+
+ public void tearDown() throws Exception
+ {
+ stopServers(0, 1);
+ super.tearDown();
+ }
+
+ public boolean isNetty()
+ {
+ return false;
+ }
+
+ public void testSimple() throws Exception
+ {
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
13 years, 6 months
JBoss hornetq SVN: r10849 - in branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq: core/client/impl and 2 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-06-17 12:37:51 -0400 (Fri, 17 Jun 2011)
New Revision: 10849
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/api/core/DiscoveryGroupConfiguration.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/ClusterConnection.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/MessageFlowRecord.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
Log:
tweaks
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/api/core/DiscoveryGroupConfiguration.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/api/core/DiscoveryGroupConfiguration.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/api/core/DiscoveryGroupConfiguration.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -179,4 +179,26 @@
result = 31 * result + (int) (discoveryInitialWaitTimeout ^ (discoveryInitialWaitTimeout >>> 32));
return result;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "DiscoveryGroupConfiguration [discoveryInitialWaitTimeout=" + discoveryInitialWaitTimeout +
+ ", groupAddress=" +
+ groupAddress +
+ ", groupPort=" +
+ groupPort +
+ ", localBindAddress=" +
+ localBindAddress +
+ ", name=" +
+ name +
+ ", refreshTimeout=" +
+ refreshTimeout +
+ "]";
+ }
+
+
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -422,6 +422,13 @@
return;
}
+ synchronized (exitLock)
+ {
+ exitLock.notifyAll();
+ }
+
+ forceReturnChannel1();
+
// we need to stop the factory from connecting if it is in the middle of trying to failover before we get the lock
causeExit();
synchronized (createSessionLock)
@@ -942,7 +949,7 @@
{
if (isDebug)
{
- log.debug("Trying reconnection attempt " + count);
+ log.debug("Trying reconnection attempt " + count + "/" + reconnectAttempts);
}
getConnection();
@@ -1055,6 +1062,11 @@
try
{
DelegatingBufferHandler handler = new DelegatingBufferHandler();
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Trying to connect with connector = " + connectorFactory + ", parameters = " + connectorConfig.getParams());
+ }
connector = connectorFactory.createConnector(connectorConfig.getParams(),
handler,
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -65,7 +65,7 @@
private StaticConnector staticConnector = new StaticConnector();
- private Topology topology = new Topology();
+ private final Topology topology = new Topology();
private Pair<TransportConfiguration, TransportConfiguration>[] topologyArray;
@@ -599,7 +599,7 @@
threadPool,
scheduledThreadPool,
interceptors);
- factory.connect(initialConnectAttempts, failoverOnInitialConnection);
+ factory.connect(reconnectAttempts, failoverOnInitialConnection);
}
catch (HornetQException e)
{
@@ -1096,8 +1096,10 @@
{
staticConnector.disconnect();
}
+
+ Set<ClientSessionFactory> clonedFactory = new HashSet<ClientSessionFactory>(factories);
- for (ClientSessionFactory factory : factories)
+ for (ClientSessionFactory factory : clonedFactory)
{
factory.close();
}
@@ -1263,16 +1265,6 @@
public synchronized void factoryClosed(final ClientSessionFactory factory)
{
factories.remove(factory);
-
- if (factories.isEmpty())
- {
- // Go back to using the broadcast or static list
-
- receivedTopology = false;
-
- topology = null;
-
- }
}
public Topology getTopology()
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/ClusterConnection.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/ClusterConnection.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/ClusterConnection.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -41,14 +41,6 @@
*/
Map<String, String> getNodes();
- void handleReplicatedAddBinding(SimpleString address,
- SimpleString uniqueName,
- SimpleString routingName,
- long queueID,
- SimpleString filterString,
- SimpleString queueName,
- int distance) throws Exception;
-
void activate() throws Exception;
TransportConfiguration getConnector();
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/MessageFlowRecord.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/MessageFlowRecord.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/MessageFlowRecord.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -33,14 +33,8 @@
Bridge getBridge();
void close() throws Exception;
-
- public void resume() throws Exception;
-
+
boolean isClosed();
void reset() throws Exception;
-
- void pause() throws Exception;
-
- boolean isPaused();
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -617,7 +617,7 @@
protected ClientSessionFactoryInternal createSessionFactory() throws Exception
{
ClientSessionFactoryInternal csf = (ClientSessionFactoryInternal)serverLocator.createSessionFactory();
- // csf.setReconnectAttempts(0);
+ csf.setReconnectAttempts(0);
//csf.setInitialReconnectAttempts(1);
return csf;
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -489,7 +489,7 @@
// TODO: does it need to be sync?
- public synchronized void nodeUP(final String nodeID,
+ public void nodeUP(final String nodeID,
final Pair<TransportConfiguration, TransportConfiguration> connectorPair,
final boolean last)
{
@@ -563,10 +563,6 @@
else
{
log.info("Reattaching nodeID=" + nodeID);
- if (record.isPaused())
- {
- record.resume();
- }
}
}
catch (Exception e)
@@ -808,26 +804,8 @@
bridge.stop();
}
- public void pause() throws Exception
+ public boolean isClosed()
{
- paused = true;
- clearBindings();
- bridge.pause();
- }
-
- public boolean isPaused()
- {
- return paused;
- }
-
- public void resume() throws Exception
- {
- paused = false;
- bridge.resume();
- }
-
- public boolean isClosed()
- {
return isClosed;
}
@@ -836,7 +814,6 @@
clearBindings();
}
-
public void setBridge(final Bridge bridge)
{
this.bridge = bridge;
@@ -972,6 +949,7 @@
private synchronized void clearBindings() throws Exception
{
+ log.debug(ClusterConnectionImpl.this + " clearing bindings");
for (RemoteQueueBinding binding : new HashSet<RemoteQueueBinding>(bindings.values()))
{
removeBinding(binding.getClusterName());
@@ -980,6 +958,10 @@
private synchronized void doBindingAdded(final ClientMessage message) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ log.trace(ClusterConnectionImpl.this + " Adding binding " + message);
+ }
if (!message.containsProperty(ManagementHelper.HDR_DISTANCE))
{
throw new IllegalStateException("distance is null");
@@ -1039,6 +1021,11 @@
return;
}
+
+ if (isTrace)
+ {
+ log.trace("Adding binding " + clusterName + " into " + ClusterConnectionImpl.this);
+ }
bindings.put(clusterName, binding);
@@ -1058,6 +1045,10 @@
private void doBindingRemoved(final ClientMessage message) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ log.trace(ClusterConnectionImpl.this + " Removing binding " + message);
+ }
if (!message.containsProperty(ManagementHelper.HDR_CLUSTER_NAME))
{
throw new IllegalStateException("clusterName is null");
@@ -1082,6 +1073,10 @@
private synchronized void doConsumerCreated(final ClientMessage message) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ log.trace(ClusterConnectionImpl.this + " Consumer created " + message);
+ }
if (!message.containsProperty(ManagementHelper.HDR_DISTANCE))
{
throw new IllegalStateException("distance is null");
@@ -1136,6 +1131,10 @@
private synchronized void doConsumerClosed(final ClientMessage message) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ log.trace(ClusterConnectionImpl.this + " Consumer closed " + message);
+ }
if (!message.containsProperty(ManagementHelper.HDR_DISTANCE))
{
throw new IllegalStateException("distance is null");
@@ -1189,49 +1188,6 @@
}
- public void handleReplicatedAddBinding(final SimpleString address,
- final SimpleString uniqueName,
- final SimpleString routingName,
- final long queueID,
- final SimpleString filterString,
- final SimpleString queueName,
- final int distance) throws Exception
- {
- Binding queueBinding = postOffice.getBinding(queueName);
-
- if (queueBinding == null)
- {
- throw new IllegalStateException("Cannot find s & f queue " + queueName);
- }
-
- Queue queue = (Queue)queueBinding.getBindable();
-
- RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateUniqueID(),
- address,
- uniqueName,
- routingName,
- queueID,
- filterString,
- queue,
- queueName,
- distance);
-
- if (postOffice.getBinding(uniqueName) != null)
- {
- ClusterConnectionImpl.log.warn("Remoting queue binding " + uniqueName +
- " has already been bound in the post office. Most likely cause for this is you have a loop " +
- "in your cluster due to cluster max-hops being too large or you have multiple cluster connections to the same nodes using overlapping addresses");
-
- return;
- }
-
- postOffice.addBinding(binding);
-
- Bindings theBindings = postOffice.getBindingsForAddress(address);
-
- theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
- }
-
// for testing only
public Map<String, MessageFlowRecord> getRecords()
{
@@ -1286,6 +1242,17 @@
return null;
}
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "StaticClusterConnector [tcConfigs=" + Arrays.toString(tcConfigs) + "]";
+ }
+
+
}
private class DiscoveryClusterConnector implements ClusterConnector
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-06-17 15:52:20 UTC (rev 10848)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-06-17 16:37:51 UTC (rev 10849)
@@ -97,14 +97,8 @@
// the cluster connections which links this node to other cluster nodes
private final Map<String, ClusterConnection> clusterConnections = new HashMap<String, ClusterConnection>();
- // regular client listeners to be notified of cluster topology changes.
- // they correspond to regular clients using a HA ServerLocator
- private Set<ClusterTopologyListener> clientListeners = new ConcurrentHashSet<ClusterTopologyListener>();
+ private Set<ClusterTopologyListener> topologyListeners = new ConcurrentHashSet<ClusterTopologyListener>();
- // cluster connections listeners to be notified of cluster topology changes
- // they correspond to cluster connections on *other nodes connected to this one*
- private Set<ClusterTopologyListener> clusterConnectionListeners = new ConcurrentHashSet<ClusterTopologyListener>();
-
private Topology topology = new Topology();
private volatile ServerLocatorInternal backupServerLocator;
@@ -208,8 +202,7 @@
managementService.unregisterCluster(clusterConnection.getName().toString());
}
- clusterConnectionListeners.clear();
- clientListeners.clear();
+ topologyListeners.clear();
clusterConnections.clear();
topology.clear();
@@ -249,15 +242,10 @@
if (removed)
{
- for (ClusterTopologyListener listener : clientListeners)
+ for (ClusterTopologyListener listener : topologyListeners)
{
listener.nodeDown(nodeID);
}
-
- for (ClusterTopologyListener listener : clusterConnectionListeners)
- {
- listener.nodeDown(nodeID);
- }
}
}
@@ -274,16 +262,11 @@
return;
}
- for (ClusterTopologyListener listener : clientListeners)
+ for (ClusterTopologyListener listener : topologyListeners)
{
listener.nodeUP(nodeID, member.getConnector(), last);
}
- for (ClusterTopologyListener listener : clusterConnectionListeners)
- {
- listener.nodeUP(nodeID, member.getConnector(), last);
- }
-
// if this is a node being announced we are hearing it direct from the nodes CM so need to inform our cluster
// connections.
if (nodeAnnounce)
@@ -322,18 +305,7 @@
public void addClusterTopologyListener(final ClusterTopologyListener listener, final boolean clusterConnection)
{
- synchronized (this)
- {
- if (clusterConnection)
- {
- this.clusterConnectionListeners.add(listener);
- }
- else
- {
- this.clientListeners.add(listener);
- }
- }
-
+ topologyListeners.add(listener);
// We now need to send the current topology to the client
topology.sendTopology(listener);
}
@@ -341,14 +313,7 @@
public void removeClusterTopologyListener(final ClusterTopologyListener listener,
final boolean clusterConnection)
{
- if (clusterConnection)
- {
- this.clusterConnectionListeners.remove(listener);
- }
- else
- {
- this.clientListeners.remove(listener);
- }
+ topologyListeners.add(listener);
}
public Topology getTopology()
@@ -425,15 +390,14 @@
}
}
- for (ClusterTopologyListener listener : clientListeners)
+ for (ClusterTopologyListener listener : topologyListeners)
{
+ if (log.isDebugEnabled())
+ {
+ log.debug("Informing client listener " + listener + " about itself node " + nodeID + " with connector=" + member.getConnector());
+ }
listener.nodeUP(nodeID, member.getConnector(), false);
}
-
- for (ClusterTopologyListener listener : clusterConnectionListeners)
- {
- listener.nodeUP(nodeID, member.getConnector(), false);
- }
}
}
@@ -499,16 +463,10 @@
// Propagate the announcement
- for (ClusterTopologyListener listener : clientListeners)
+ for (ClusterTopologyListener listener : topologyListeners)
{
listener.nodeUP(nodeID, member.getConnector(), false);
}
-
- for (ClusterTopologyListener listener : clusterConnectionListeners)
- {
- listener.nodeUP(nodeID, member.getConnector(), false);
- }
-
}
private synchronized void deployBroadcastGroup(final BroadcastGroupConfiguration config) throws Exception
13 years, 6 months
JBoss hornetq SVN: r10848 - in trunk: hornetq-core/src and 12 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-06-17 11:52:20 -0400 (Fri, 17 Jun 2011)
New Revision: 10848
Added:
trunk/hornetq-core/src/test/
trunk/hornetq-core/src/test/java/
trunk/hornetq-core/src/test/java/org/
trunk/hornetq-core/src/test/java/org/hornetq/
trunk/hornetq-core/src/test/java/org/hornetq/core/
trunk/hornetq-core/src/test/java/org/hornetq/core/version/
trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/
trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java
trunk/hornetq-core/src/test/java/org/hornetq/tests/
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/RandomUtil.java
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Removed:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Modified:
trunk/hornetq-core/pom.xml
trunk/tests/unit-tests/pom.xml
Log:
Move base TestCases to hornetq-core/src/test, and one actual test case.
Modified: trunk/hornetq-core/pom.xml
===================================================================
--- trunk/hornetq-core/pom.xml 2011-06-17 15:50:19 UTC (rev 10847)
+++ trunk/hornetq-core/pom.xml 2011-06-17 15:52:20 UTC (rev 10848)
@@ -27,6 +27,11 @@
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
Copied: trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java (from rev 10847, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java 2011-06-17 15:52:20 UTC (rev 10848)
@@ -0,0 +1,109 @@
+/*
+ * 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.version.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import junit.framework.Assert;
+
+import org.hornetq.core.version.impl.VersionImpl;
+import org.hornetq.tests.util.UnitTestCase;
+
+/**
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class VersionImplTest extends UnitTestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testVersionImpl() throws Exception
+ {
+
+ String versionName = "HORNETQ";
+ int majorVersion = 2;
+ int minorVersion = 0;
+ int microVersion = 1;
+ int incrementingVersion = 10;
+ String versionSuffix = "suffix";
+ String nettyVersion = "netty";
+ int[] compatibleVersionList = {7,8,9,10};
+ VersionImpl version = new VersionImpl(versionName,
+ majorVersion,
+ minorVersion,
+ microVersion,
+ incrementingVersion,
+ versionSuffix,
+ nettyVersion,
+ compatibleVersionList);
+
+ Assert.assertEquals(versionName, version.getVersionName());
+ Assert.assertEquals(majorVersion, version.getMajorVersion());
+ Assert.assertEquals(minorVersion, version.getMinorVersion());
+ Assert.assertEquals(microVersion, version.getMicroVersion());
+ Assert.assertEquals(incrementingVersion, version.getIncrementingVersion());
+ Assert.assertEquals(versionSuffix, version.getVersionSuffix());
+ }
+
+ public void testEquals() throws Exception
+ {
+ String nettyVersion = "netty";
+ VersionImpl version = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion, new int[]{7,8,9,10});
+ VersionImpl sameVersion = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion, new int[]{7,8,9,10});
+ VersionImpl differentVersion = new VersionImpl("HORNETQ", 2, 0, 1, 11, "suffix", nettyVersion, new int[]{7,8,9,10,11});
+
+ Assert.assertFalse(version.equals(new Object()));
+
+ Assert.assertTrue(version.equals(version));
+ Assert.assertTrue(version.equals(sameVersion));
+ Assert.assertFalse(version.equals(differentVersion));
+ }
+
+ public void testSerialize() throws Exception
+ {
+ String nettyVersion = "netty";
+ VersionImpl version = new VersionImpl("uyiuy", 3, 7, 6, 12, "uhuhuh", nettyVersion, new int[]{9,10,11,12});
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(version);
+ oos.flush();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ VersionImpl version2 = (VersionImpl)ois.readObject();
+
+ Assert.assertTrue(version.equals(version2));
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/RandomUtil.java (from rev 10847, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/RandomUtil.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/RandomUtil.java 2011-06-17 15:52:20 UTC (rev 10848)
@@ -0,0 +1,176 @@
+/*
+ * 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.util.Random;
+import java.util.UUID;
+
+import javax.transaction.xa.Xid;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.transaction.impl.XidImpl;
+
+/**
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public final class RandomUtil
+{
+ // Constants -----------------------------------------------------
+
+ private static final Random random = new Random(System.currentTimeMillis());
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ public static String randomString()
+ {
+ return UUID.randomUUID().toString();
+ }
+
+ public static SimpleString randomSimpleString()
+ {
+ return new SimpleString(RandomUtil.randomString());
+ }
+
+ public static char randomChar()
+ {
+ return RandomUtil.randomString().charAt(0);
+ }
+
+ public static long randomLong()
+ {
+ return RandomUtil.random.nextLong();
+ }
+
+ public static long randomPositiveLong()
+ {
+ return Math.abs(RandomUtil.randomLong());
+ }
+
+ public static int randomInt()
+ {
+ return RandomUtil.random.nextInt();
+ }
+
+ public static int randomPositiveInt()
+ {
+ return Math.abs(RandomUtil.randomInt());
+ }
+
+
+ public static HornetQBuffer randomBuffer(final int size, final long... data)
+ {
+ HornetQBuffer buffer = HornetQBuffers.fixedBuffer(size + 8 * data.length);
+
+ for (long d : data)
+ {
+ buffer.writeLong(d);
+ }
+
+ for (int i = 0 ; i < size; i++)
+ {
+ buffer.writeByte(randomByte());
+ }
+
+ return buffer;
+ }
+
+
+
+
+ public static int randomInterval(final int min, final int max)
+ {
+ return min + randomMax(max - min);
+ }
+
+ public static int randomMax(final int max)
+ {
+ int value = randomPositiveInt() % max;
+
+ if (value == 0)
+ {
+ value = max;
+ }
+
+ return value;
+ }
+
+ public static int randomPort()
+ {
+ return RandomUtil.random.nextInt(65536);
+ }
+
+ public static short randomShort()
+ {
+ return (short)RandomUtil.random.nextInt(Short.MAX_VALUE);
+ }
+
+ public static byte randomByte()
+ {
+ return Integer.valueOf(RandomUtil.random.nextInt()).byteValue();
+ }
+
+ public static boolean randomBoolean()
+ {
+ return RandomUtil.random.nextBoolean();
+ }
+
+ public static byte[] randomBytes()
+ {
+ return RandomUtil.randomString().getBytes();
+ }
+
+ public static byte[] randomBytes(final int length)
+ {
+ byte[] bytes = new byte[length];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ bytes[i] = RandomUtil.randomByte();
+ }
+ return bytes;
+ }
+
+ public static double randomDouble()
+ {
+ return RandomUtil.random.nextDouble();
+ }
+
+ public static float randomFloat()
+ {
+ return RandomUtil.random.nextFloat();
+ }
+
+ public static Xid randomXid()
+ {
+ return new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes());
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java (from rev 10847, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-06-17 15:52:20 UTC (rev 10848)
@@ -0,0 +1,1229 @@
+/*
+ * 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.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.net.ServerSocket;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.naming.Context;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
+import org.hornetq.core.client.impl.ServerLocatorImpl;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
+import org.hornetq.core.postoffice.Binding;
+import org.hornetq.core.postoffice.Bindings;
+import org.hornetq.core.postoffice.PostOffice;
+import org.hornetq.core.postoffice.QueueBinding;
+import org.hornetq.core.postoffice.impl.LocalQueueBinding;
+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.netty.NettyAcceptorFactory;
+import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.core.server.MessageReference;
+import org.hornetq.core.server.Queue;
+import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.impl.ServerMessageImpl;
+import org.hornetq.core.transaction.impl.XidImpl;
+import org.hornetq.utils.UUIDGenerator;
+
+/**
+ *
+ * Helper base class for our unit tests
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ * @author <a href="mailto:csuconic@redhat.com">Clebert</a>
+ *
+ */
+public abstract class UnitTestCase extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(UnitTestCase.class);
+
+ public static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
+
+ public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
+
+ public static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
+
+ public static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
+
+ // Attributes ----------------------------------------------------
+
+ private static final String testDir = System.getProperty("java.io.tmpdir", "/tmp") + "/hornetq-unit-test";
+
+ // There is a verification about thread leakages. We only fail a single thread when this happens
+ private static Set<Thread> alreadyFailedThread = new HashSet<Thread>();
+
+ // Static --------------------------------------------------------
+
+ protected Configuration createDefaultConfig()
+ {
+ return createDefaultConfig(false);
+ }
+
+ protected Configuration createDefaultConfig(final boolean netty)
+ {
+ if (netty)
+ {
+ return createDefaultConfig(new HashMap<String, Object>(), INVM_ACCEPTOR_FACTORY, NETTY_ACCEPTOR_FACTORY);
+ }
+ else
+ {
+ return createDefaultConfig(new HashMap<String, Object>(), INVM_ACCEPTOR_FACTORY);
+ }
+ }
+
+ protected static Configuration createClusteredDefaultConfig(final int index,
+ final Map<String, Object> params,
+ final String... acceptors)
+ {
+ Configuration config = createDefaultConfig(index, params, acceptors);
+
+ config.setClustered(true);
+
+ return config;
+ }
+
+ protected static Configuration createDefaultConfig(final int index,
+ final Map<String, Object> params,
+ final String... acceptors)
+ {
+ Configuration configuration = createBasicConfig(index);
+
+ configuration.getAcceptorConfigurations().clear();
+
+ for (String acceptor : acceptors)
+ {
+ TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
+ configuration.getAcceptorConfigurations().add(transportConfig);
+ }
+
+ return configuration;
+ }
+
+ protected static ConfigurationImpl createBasicConfig()
+ {
+ return createBasicConfig(0);
+ }
+
+ /**
+ * @param serverID
+ * @return
+ */
+ protected static ConfigurationImpl createBasicConfig(final int serverID)
+ {
+ ConfigurationImpl configuration = new ConfigurationImpl();
+ configuration.setSecurityEnabled(false);
+ configuration.setBindingsDirectory(getBindingsDir(serverID, false));
+ configuration.setJournalMinFiles(2);
+ configuration.setJournalDirectory(getJournalDir(serverID, false));
+ configuration.setJournalFileSize(100 * 1024);
+ configuration.setJournalType(getDefaultJournalType());
+ configuration.setPagingDirectory(getPageDir(serverID, false));
+ configuration.setLargeMessagesDirectory(getLargeMessagesDir(serverID, false));
+ configuration.setJournalCompactMinFiles(0);
+ configuration.setJournalCompactPercentage(0);
+ return configuration;
+ }
+
+ protected static Configuration createDefaultConfig(final Map<String, Object> params, final String... acceptors)
+ {
+ Configuration configuration = new ConfigurationImpl();
+ configuration.setSecurityEnabled(false);
+ configuration.setJMXManagementEnabled(false);
+ configuration.setBindingsDirectory(getBindingsDir());
+ configuration.setJournalMinFiles(2);
+ configuration.setJournalDirectory(getJournalDir());
+ configuration.setJournalFileSize(100 * 1024);
+ configuration.setPagingDirectory(getPageDir());
+ configuration.setLargeMessagesDirectory(getLargeMessagesDir());
+ configuration.setJournalCompactMinFiles(0);
+ configuration.setJournalCompactPercentage(0);
+
+ configuration.setFileDeploymentEnabled(false);
+
+ configuration.setJournalType(getDefaultJournalType());
+
+ configuration.getAcceptorConfigurations().clear();
+
+ for (String acceptor : acceptors)
+ {
+ TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
+ configuration.getAcceptorConfigurations().add(transportConfig);
+ }
+
+ return configuration;
+ }
+
+ protected static String getUDPDiscoveryAddress()
+ {
+ return System.getProperty("TEST-UDP-ADDRESS", "230.1.2.3");
+ }
+
+ protected static String getUDPDiscoveryAddress(final int variant)
+ {
+ String value = getUDPDiscoveryAddress();
+
+ int posPoint = value.lastIndexOf('.');
+
+ int last = Integer.valueOf(value.substring(posPoint + 1));
+
+ return value.substring(0, posPoint + 1) + (last + variant);
+ }
+
+ public static int getUDPDiscoveryPort()
+ {
+ return Integer.parseInt(System.getProperty("TEST-UDP-PORT", "6750"));
+ }
+
+ public static int getUDPDiscoveryPort(final int variant)
+ {
+ return getUDPDiscoveryPort() + variant;
+ }
+
+ protected static JournalType getDefaultJournalType()
+ {
+ if (AsynchronousFileImpl.isLoaded())
+ {
+ return JournalType.ASYNCIO;
+ }
+ else
+ {
+ return JournalType.NIO;
+ }
+ }
+
+ /**
+ * @param name
+ */
+ public UnitTestCase(final String name)
+ {
+ super(name);
+ }
+
+ public UnitTestCase()
+ {
+ super();
+ }
+
+ public static void forceGC()
+ {
+ WeakReference<Object> dumbReference = new WeakReference<Object>(new Object());
+ // A loop that will wait GC, using the minimal time as possible
+ while (dumbReference.get() != null)
+ {
+ System.gc();
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+ }
+
+ public static void forceGC(final Reference<?> ref, final long timeout)
+ {
+ long waitUntil = System.currentTimeMillis() + timeout;
+ // A loop that will wait GC, using the minimal time as possible
+ while (ref.get() != null && System.currentTimeMillis() < waitUntil)
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ for (int i = 0; i < 1000; i++)
+ {
+ list.add("Some string with garbage with concatenation " + i);
+ }
+ list.clear();
+ list = null;
+ System.gc();
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+ }
+
+ // verify if these weak references are released after a few GCs
+ public static void checkWeakReferences(final WeakReference<?>... references)
+ {
+
+ int i = 0;
+ boolean hasValue = false;
+
+ do
+ {
+ hasValue = false;
+
+ if (i > 0)
+ {
+ UnitTestCase.forceGC();
+ }
+
+ for (WeakReference<?> ref : references)
+ {
+ if (ref.get() != null)
+ {
+ hasValue = true;
+ }
+ }
+ }
+ while (i++ <= 30 && hasValue);
+
+ for (WeakReference<?> ref : references)
+ {
+ Assert.assertNull(ref.get());
+ }
+ }
+
+ public static String threadDump(final String msg)
+ {
+ StringWriter str = new StringWriter();
+ PrintWriter out = new PrintWriter(str);
+
+ Map<Thread, StackTraceElement[]> stackTrace = Thread.getAllStackTraces();
+
+ out.println("*******************************************************************************");
+ out.println("Complete Thread dump " + msg);
+
+ for (Map.Entry<Thread, StackTraceElement[]> el : stackTrace.entrySet())
+ {
+ out.println("===============================================================================");
+ out.println("Thread " + el.getKey() +
+ " name = " +
+ el.getKey().getName() +
+ " id = " +
+ el.getKey().getId() +
+ " group = " +
+ el.getKey().getThreadGroup());
+ out.println();
+ for (StackTraceElement traceEl : el.getValue())
+ {
+ out.println(traceEl);
+ }
+ }
+
+ out.println("===============================================================================");
+ out.println("End Thread dump " + msg);
+ out.println("*******************************************************************************");
+
+ return str.toString();
+ }
+
+ protected static TestSuite createAIOTestSuite(final Class<?> clazz)
+ {
+ TestSuite suite = new TestSuite(clazz.getName() + " testsuite");
+
+ if (AIOSequentialFileFactory.isSupported())
+ {
+ suite.addTestSuite(clazz);
+ }
+ else
+ {
+ // System.out goes towards JUnit report
+ System.out.println("Test " + clazz.getName() + " ignored as AIO is not available");
+ }
+
+ return suite;
+ }
+
+ public static String dumpBytes(final byte[] bytes)
+ {
+ StringBuffer buff = new StringBuffer();
+
+ buff.append(System.identityHashCode(bytes) + ", size: " + bytes.length + " [");
+
+ for (int i = 0; i < bytes.length; i++)
+ {
+ buff.append(bytes[i]);
+
+ if (i != bytes.length - 1)
+ {
+ buff.append(", ");
+ }
+ }
+
+ buff.append("]");
+
+ return buff.toString();
+ }
+
+ public static String dumbBytesHex(final byte[] buffer, final int bytesPerLine)
+ {
+
+ StringBuffer buff = new StringBuffer();
+
+ buff.append("[");
+
+ for (int i = 0; i < buffer.length; i++)
+ {
+ buff.append(String.format("%1$2X", buffer[i]));
+ if (i + 1 < buffer.length)
+ {
+ buff.append(", ");
+ }
+ if ((i + 1) % bytesPerLine == 0)
+ {
+ buff.append("\n ");
+ }
+ }
+ buff.append("]");
+
+ return buff.toString();
+ }
+
+ public static void assertEqualsByteArrays(final byte[] expected, final byte[] actual)
+ {
+ // assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; i++)
+ {
+ Assert.assertEquals("byte at index " + i, expected[i], actual[i]);
+ }
+ }
+
+ public static void assertEqualsTransportConfigurations(final TransportConfiguration[] expected,
+ final TransportConfiguration[] actual)
+ {
+ assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; i++)
+ {
+ Assert.assertEquals("TransportConfiguration at index " + i, expected[i], actual[i]);
+ }
+ }
+
+ public static void assertEqualsBuffers(final int size, final HornetQBuffer expected, final HornetQBuffer actual)
+ {
+ // assertEquals(expected.length, actual.length);
+ expected.readerIndex(0);
+ actual.readerIndex(0);
+
+ for (int i = 0; i < size; i++)
+ {
+ byte b1 = expected.readByte();
+ byte b2 = actual.readByte();
+ Assert.assertEquals("byte at index " + i, b1, b2);
+ }
+ expected.resetReaderIndex();
+ actual.resetReaderIndex();
+ }
+
+ public static void assertEqualsByteArrays(final int length, final byte[] expected, final byte[] actual)
+ {
+ // we check only for the given length (the arrays might be
+ // larger)
+ Assert.assertTrue(expected.length >= length);
+ Assert.assertTrue(actual.length >= length);
+ for (int i = 0; i < length; i++)
+ {
+ Assert.assertEquals("byte at index " + i, expected[i], actual[i]);
+ }
+ }
+
+ public static void assertSameXids(final List<Xid> expected, final List<Xid> actual)
+ {
+ Assert.assertNotNull(expected);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(expected.size(), actual.size());
+
+ for (int i = 0; i < expected.size(); i++)
+ {
+ Xid expectedXid = expected.get(i);
+ Xid actualXid = actual.get(i);
+ UnitTestCase.assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid.getBranchQualifier());
+ Assert.assertEquals(expectedXid.getFormatId(), actualXid.getFormatId());
+ UnitTestCase.assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid.getGlobalTransactionId());
+ }
+ }
+
+ protected static void checkNoBinding(final Context context, final String binding)
+ {
+ try
+ {
+ context.lookup(binding);
+ Assert.fail("there must be no resource to look up for " + binding);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ protected static Object checkBinding(final Context context, final String binding) throws Exception
+ {
+ Object o = context.lookup(binding);
+ Assert.assertNotNull(o);
+ return o;
+ }
+
+ /**
+ * @param connectorConfigs
+ * @return
+ */
+ protected ArrayList<String> registerConnectors(final HornetQServer server,
+ final List<TransportConfiguration> connectorConfigs)
+ {
+ // The connectors need to be pre-configured at main config object but this method is taking
+ // TransportConfigurations directly
+ // So this will first register them at the config and then generate a list of objects
+ ArrayList<String> connectors = new ArrayList<String>();
+ for (TransportConfiguration tnsp : connectorConfigs)
+ {
+ String name = RandomUtil.randomString();
+
+ server.getConfiguration().getConnectorConfigurations().put(name, tnsp);
+
+ connectors.add(name);
+ }
+ return connectors;
+ }
+
+ protected static void checkFreePort(final int... ports)
+ {
+ for (int port : ports)
+ {
+ ServerSocket ssocket = null;
+ try
+ {
+ ssocket = new ServerSocket(port);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("port " + port + " is already bound");
+ }
+ finally
+ {
+ if (ssocket != null)
+ {
+ try
+ {
+ ssocket.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ /**
+ * @return the testDir
+ */
+ protected String getTestDir()
+ {
+ return testDir;
+ }
+
+ protected void clearData()
+ {
+ clearData(getTestDir());
+ }
+
+ protected void clearData(final String testDir)
+ {
+ // Need to delete the root
+
+ File file = new File(testDir);
+ deleteDirectory(file);
+ file.mkdirs();
+
+ recreateDirectory(getJournalDir(testDir));
+ recreateDirectory(getBindingsDir(testDir));
+ recreateDirectory(getPageDir(testDir));
+ recreateDirectory(getLargeMessagesDir(testDir));
+ recreateDirectory(getClientLargeMessagesDir(testDir));
+ recreateDirectory(getTemporaryDir(testDir));
+
+ System.out.println("deleted " + testDir);
+ }
+
+ /**
+ * @return the journalDir
+ */
+ public static String getJournalDir()
+ {
+ return getJournalDir(testDir);
+ }
+
+ protected static String getJournalDir(final String testDir)
+ {
+ return testDir + "/journal";
+ }
+
+ protected static String getJournalDir(final int index, final boolean backup)
+ {
+ String dir = getJournalDir(testDir) + index + "-" + (backup ? "B" : "L");
+
+ return dir;
+ }
+
+ /**
+ * @return the bindingsDir
+ */
+ protected static String getBindingsDir()
+ {
+ return getBindingsDir(testDir);
+ }
+
+ /**
+ * @return the bindingsDir
+ */
+ protected static String getBindingsDir(final String testDir)
+ {
+ return testDir + "/bindings";
+ }
+
+ /**
+ * @return the bindingsDir
+ */
+ protected static String getBindingsDir(final int index, final boolean backup)
+ {
+ return getBindingsDir(testDir) + index + "-" + (backup ? "B" : "L");
+ }
+
+ /**
+ * @return the pageDir
+ */
+ protected static String getPageDir()
+ {
+ return getPageDir(testDir);
+ }
+
+ /**
+ * @return the pageDir
+ */
+ protected static String getPageDir(final String testDir)
+ {
+ return testDir + "/page";
+ }
+
+ protected static String getPageDir(final int index, final boolean backup)
+ {
+ return getPageDir(testDir) + index + "-" + (backup ? "B" : "L");
+ }
+
+ /**
+ * @return the largeMessagesDir
+ */
+ protected static String getLargeMessagesDir()
+ {
+ return getLargeMessagesDir(testDir);
+ }
+
+ /**
+ * @return the largeMessagesDir
+ */
+ protected static String getLargeMessagesDir(final String testDir)
+ {
+ return testDir + "/large-msg";
+ }
+
+ protected static String getLargeMessagesDir(final int index, final boolean backup)
+ {
+ return getLargeMessagesDir(testDir) + index + "-" + (backup ? "B" : "L");
+ }
+
+ /**
+ * @return the clientLargeMessagesDir
+ */
+ protected String getClientLargeMessagesDir()
+ {
+ return getClientLargeMessagesDir(testDir);
+ }
+
+ /**
+ * @return the clientLargeMessagesDir
+ */
+ protected String getClientLargeMessagesDir(final String testDir)
+ {
+ return testDir + "/client-large-msg";
+ }
+
+ /**
+ * @return the temporaryDir
+ */
+ protected String getTemporaryDir()
+ {
+ return getTemporaryDir(testDir);
+ }
+
+ /**
+ * @return the temporaryDir
+ */
+ protected String getTemporaryDir(final String testDir)
+ {
+ return testDir + "/temp";
+ }
+
+ protected static void expectHornetQException(final String message, final int errorCode, final HornetQAction action)
+ {
+ try
+ {
+ action.run();
+ Assert.fail(message);
+ }
+ catch (Exception e)
+ {
+ Assert.assertTrue(e instanceof HornetQException);
+ Assert.assertEquals(errorCode, ((HornetQException)e).getCode());
+ }
+ }
+
+ protected static void expectHornetQException(final int errorCode, final HornetQAction action)
+ {
+ UnitTestCase.expectHornetQException("must throw a HornetQException with the expected errorCode: " + errorCode,
+ errorCode,
+ action);
+ }
+
+ protected static void expectXAException(final int errorCode, final HornetQAction action)
+ {
+ try
+ {
+ action.run();
+ Assert.fail("must throw a XAException with the expected errorCode: " + errorCode);
+ }
+ catch (Exception e)
+ {
+ Assert.assertTrue(e instanceof XAException);
+ Assert.assertEquals(errorCode, ((XAException)e).errorCode);
+ }
+ }
+
+ public static byte getSamplebyte(final long position)
+ {
+ return (byte)('a' + position % ('z' - 'a' + 1));
+ }
+
+ // Creates a Fake LargeStream without using a real file
+ public static InputStream createFakeLargeStream(final long size) throws Exception
+ {
+ return new InputStream()
+ {
+ private long count;
+
+ private boolean closed = false;
+
+ @Override
+ public void close() throws IOException
+ {
+ super.close();
+ closed = true;
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Stream was closed");
+ }
+ if (count++ < size)
+ {
+ return UnitTestCase.getSamplebyte(count - 1);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ };
+
+ }
+
+ /** It validates a Bean (POJO) using simple setters and getters with random values.
+ * You can pass a list of properties to be ignored, as some properties will have a pre-defined domain (not being possible to use random-values on them) */
+ protected void validateGettersAndSetters(final Object pojo, final String... ignoredProperties) throws Exception
+ {
+ HashSet<String> ignoreSet = new HashSet<String>();
+
+ for (String ignore : ignoredProperties)
+ {
+ ignoreSet.add(ignore);
+ }
+
+ BeanInfo info = Introspector.getBeanInfo(pojo.getClass());
+
+ PropertyDescriptor properties[] = info.getPropertyDescriptors();
+
+ for (PropertyDescriptor prop : properties)
+ {
+ Object value;
+
+ if (prop.getPropertyType() == String.class)
+ {
+ value = RandomUtil.randomString();
+ }
+ else if (prop.getPropertyType() == Integer.class || prop.getPropertyType() == Integer.TYPE)
+ {
+ value = RandomUtil.randomInt();
+ }
+ else if (prop.getPropertyType() == Long.class || prop.getPropertyType() == Long.TYPE)
+ {
+ value = RandomUtil.randomLong();
+ }
+ else if (prop.getPropertyType() == Boolean.class || prop.getPropertyType() == Boolean.TYPE)
+ {
+ value = RandomUtil.randomBoolean();
+ }
+ else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE)
+ {
+ value = RandomUtil.randomDouble();
+ }
+ else
+ {
+ System.out.println("Can't validate property of type " + prop.getPropertyType() + " on " + prop.getName());
+ value = null;
+ }
+
+ if (value != null && prop.getWriteMethod() != null && prop.getReadMethod() == null)
+ {
+ System.out.println("WriteOnly property " + prop.getName() + " on " + pojo.getClass());
+ }
+ else if (value != null & prop.getWriteMethod() != null &&
+ prop.getReadMethod() != null &&
+ !ignoreSet.contains(prop.getName()))
+ {
+ System.out.println("Validating " + prop.getName() + " type = " + prop.getPropertyType());
+ prop.getWriteMethod().invoke(pojo, value);
+
+ Assert.assertEquals("Property " + prop.getName(), value, prop.getReadMethod().invoke(pojo));
+ }
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ Map<Thread, StackTraceElement[]> previousThreads;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ OperationContextImpl.clearContext();
+
+ deleteDirectory(new File(getTestDir()));
+
+ InVMRegistry.instance.clear();
+
+ // checkFreePort(TransportConstants.DEFAULT_PORT);
+
+ previousThreads = Thread.getAllStackTraces();
+
+ UnitTestCase.log.info("###### starting test " + this.getClass().getName() + "." + getName());
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ cleanupPools();
+
+ Map<Thread, StackTraceElement[]> threadMap = Thread.getAllStackTraces();
+ for (Thread thread : threadMap.keySet())
+ {
+ StackTraceElement[] stack = threadMap.get(thread);
+ for (StackTraceElement stackTraceElement : stack)
+ {
+ if (stackTraceElement.getMethodName().contains("getConnectionWithRetry") && !alreadyFailedThread.contains(thread))
+ {
+ alreadyFailedThread.add(thread);
+ System.out.println(threadDump(getName() + " has left threads running. Look at thread " +
+ thread.getName() +
+ " id = " +
+ thread.getId() +
+ " has running locators on test " +
+ getName() +
+ " on this following dump"));
+ fail("test left serverlocator running, this could effect other tests");
+ // System.exit(0);
+ }
+ else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread))
+ {
+ alreadyFailedThread.add(thread);
+ System.out.println(threadDump(getName() + " has left threads running. Look at thread " +
+ thread.getName() +
+ " id = " +
+ thread.getId() +
+ " is still broadcasting " +
+ getName() +
+ " on this following dump"));
+ fail("test left broadcastgroupimpl running, this could effect other tests");
+ // System.exit(0);
+ }
+ }
+ }
+
+ Map<Thread, StackTraceElement[]> postThreads = Thread.getAllStackTraces();
+
+ if (postThreads.size() > previousThreads.size())
+ {
+ StringBuffer buffer = new StringBuffer();
+
+
+ buffer.append("*********************************************************************************\n");
+ buffer.append("LEAKING THREADS\n");
+
+ for (Thread aliveThread : postThreads.keySet())
+ {
+ if (!aliveThread.getName().contains("SunPKCS11") && !previousThreads.containsKey(aliveThread))
+ {
+ buffer.append("=============================================================================\n");
+ buffer.append("Thread " + aliveThread + " is still alive with the following stackTrace:\n");
+ StackTraceElement[] elements = postThreads.get(aliveThread);
+ for (StackTraceElement el : elements)
+ {
+ buffer.append(el + "\n");
+ }
+ }
+
+ }
+ buffer.append("*********************************************************************************\n");
+
+ System.out.println(buffer.toString());
+
+ }
+
+ super.tearDown();
+ }
+
+ /**
+ *
+ */
+ protected void cleanupPools()
+ {
+ OperationContextImpl.clearContext();
+
+ deleteDirectory(new File(getTestDir()));
+
+ int invmSize = InVMRegistry.instance.size();
+ if (invmSize > 0)
+ {
+ InVMRegistry.instance.clear();
+ fail("invm registry still had acceptors registered");
+ }
+
+ if (AsynchronousFileImpl.getTotalMaxIO() != 0)
+ {
+ AsynchronousFileImpl.resetMaxAIO();
+ Assert.fail("test did not close all its files " + AsynchronousFileImpl.getTotalMaxIO());
+ }
+
+ // We shutdown the global pools to give a better isolation between tests
+ ServerLocatorImpl.clearThreadPools();
+ }
+
+ protected byte[] autoEncode(final Object... args)
+ {
+
+ int size = 0;
+
+ for (Object arg : args)
+ {
+ if (arg instanceof Byte)
+ {
+ size++;
+ }
+ else if (arg instanceof Boolean)
+ {
+ size++;
+ }
+ else if (arg instanceof Integer)
+ {
+ size += 4;
+ }
+ else if (arg instanceof Long)
+ {
+ size += 8;
+ }
+ else if (arg instanceof Float)
+ {
+ size += 4;
+ }
+ else if (arg instanceof Double)
+ {
+ size += 8;
+ }
+ else
+ {
+ throw new IllegalArgumentException("method autoEncode doesn't know how to convert " + arg.getClass() +
+ " yet");
+ }
+ }
+
+ ByteBuffer buffer = ByteBuffer.allocate(size);
+
+ for (Object arg : args)
+ {
+ if (arg instanceof Byte)
+ {
+ buffer.put(((Byte)arg).byteValue());
+ }
+ else if (arg instanceof Boolean)
+ {
+ Boolean b = (Boolean)arg;
+ buffer.put((byte)(b.booleanValue() ? 1 : 0));
+ }
+ else if (arg instanceof Integer)
+ {
+ buffer.putInt(((Integer)arg).intValue());
+ }
+ else if (arg instanceof Long)
+ {
+ buffer.putLong(((Long)arg).longValue());
+ }
+ else if (arg instanceof Float)
+ {
+ buffer.putFloat(((Float)arg).floatValue());
+ }
+ else if (arg instanceof Double)
+ {
+ buffer.putDouble(((Double)arg).doubleValue());
+ }
+ else
+ {
+ throw new IllegalArgumentException("method autoEncode doesn't know how to convert " + arg.getClass() +
+ " yet");
+ }
+ }
+
+ return buffer.array();
+ }
+
+ protected void recreateDirectory(final String directory)
+ {
+ File file = new File(directory);
+ deleteDirectory(file);
+ file.mkdirs();
+ }
+
+ protected boolean deleteDirectory(final File directory)
+ {
+ if (directory.isDirectory())
+ {
+ String[] files = directory.list();
+
+ for (int j = 0; j < files.length; j++)
+ {
+ if (!deleteDirectory(new File(directory, files[j])))
+ {
+ return false;
+ }
+ }
+ }
+
+ return directory.delete();
+ }
+
+ protected void copyRecursive(final File from, final File to) throws Exception
+ {
+ if (from.isDirectory())
+ {
+ if (!to.exists())
+ {
+ to.mkdir();
+ }
+
+ String[] subs = from.list();
+
+ for (String sub : subs)
+ {
+ copyRecursive(new File(from, sub), new File(to, sub));
+ }
+ }
+ else
+ {
+ InputStream in = null;
+
+ OutputStream out = null;
+
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(from));
+
+ out = new BufferedOutputStream(new FileOutputStream(to));
+
+ int b;
+
+ while ((b = in.read()) != -1)
+ {
+ out.write(b);
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+
+ if (out != null)
+ {
+ out.close();
+ }
+ }
+ }
+ }
+
+ protected void assertRefListsIdenticalRefs(final List<MessageReference> l1, final List<MessageReference> l2)
+ {
+ if (l1.size() != l2.size())
+ {
+ Assert.fail("Lists different sizes: " + l1.size() + ", " + l2.size());
+ }
+
+ Iterator<MessageReference> iter1 = l1.iterator();
+ Iterator<MessageReference> iter2 = l2.iterator();
+
+ while (iter1.hasNext())
+ {
+ MessageReference o1 = iter1.next();
+ MessageReference o2 = iter2.next();
+
+ Assert.assertTrue("expected " + o1 + " but was " + o2, o1 == o2);
+ }
+ }
+
+ protected ServerMessage generateMessage(final long id)
+ {
+ ServerMessage message = new ServerMessageImpl(id, 1000);
+
+ message.setMessageID(id);
+
+ message.getBodyBuffer().writeString(UUID.randomUUID().toString());
+
+ message.setAddress(new SimpleString("foo"));
+
+ return message;
+ }
+
+ protected MessageReference generateReference(final Queue queue, final long id)
+ {
+ ServerMessage message = generateMessage(id);
+
+ return message.createReference(queue);
+ }
+
+ protected int calculateRecordSize(final int size, final int alignment)
+ {
+ return (size / alignment + (size % alignment != 0 ? 1 : 0)) * alignment;
+ }
+
+ protected XidImpl newXID()
+ {
+ return new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
+ }
+
+ protected int getMessageCount(final HornetQServer service, final String address) throws Exception
+ {
+ return getMessageCount(service.getPostOffice(), address);
+ }
+
+ /**
+ * @param address
+ * @param postOffice
+ * @return
+ * @throws Exception
+ */
+ protected int getMessageCount(final PostOffice postOffice, final String address) throws Exception
+ {
+ int messageCount = 0;
+
+ List<QueueBinding> bindings = getLocalQueueBindings(postOffice, address);
+
+ for (QueueBinding qBinding : bindings)
+ {
+ messageCount += qBinding.getQueue().getMessageCount();
+ }
+
+ return messageCount;
+ }
+
+ protected
+ List<QueueBinding>
+ getLocalQueueBindings(final PostOffice postOffice, final String address) throws Exception
+ {
+ ArrayList<QueueBinding> bindingsFound = new ArrayList<QueueBinding>();
+
+ Bindings bindings = postOffice.getBindingsForAddress(new SimpleString(address));
+
+ for (Binding binding : bindings.getBindings())
+ {
+ if (binding instanceof LocalQueueBinding)
+ {
+ bindingsFound.add((QueueBinding)binding);
+ }
+ }
+ return bindingsFound;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ protected static interface HornetQAction
+ {
+ void run() throws Exception;
+ }
+
+}
Modified: trunk/tests/unit-tests/pom.xml
===================================================================
--- trunk/tests/unit-tests/pom.xml 2011-06-17 15:50:19 UTC (rev 10847)
+++ trunk/tests/unit-tests/pom.xml 2011-06-17 15:52:20 UTC (rev 10848)
@@ -16,6 +16,8 @@
<groupId>org.hornetq</groupId>
<artifactId>hornetq-core</artifactId>
<version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2011-06-17 15:50:19 UTC (rev 10847)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2011-06-17 15:52:20 UTC (rev 10848)
@@ -1,109 +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.version.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import junit.framework.Assert;
-
-import org.hornetq.core.version.impl.VersionImpl;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class VersionImplTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testVersionImpl() throws Exception
- {
-
- String versionName = "HORNETQ";
- int majorVersion = 2;
- int minorVersion = 0;
- int microVersion = 1;
- int incrementingVersion = 10;
- String versionSuffix = "suffix";
- String nettyVersion = "netty";
- int[] compatibleVersionList = {7,8,9,10};
- VersionImpl version = new VersionImpl(versionName,
- majorVersion,
- minorVersion,
- microVersion,
- incrementingVersion,
- versionSuffix,
- nettyVersion,
- compatibleVersionList);
-
- Assert.assertEquals(versionName, version.getVersionName());
- Assert.assertEquals(majorVersion, version.getMajorVersion());
- Assert.assertEquals(minorVersion, version.getMinorVersion());
- Assert.assertEquals(microVersion, version.getMicroVersion());
- Assert.assertEquals(incrementingVersion, version.getIncrementingVersion());
- Assert.assertEquals(versionSuffix, version.getVersionSuffix());
- }
-
- public void testEquals() throws Exception
- {
- String nettyVersion = "netty";
- VersionImpl version = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion, new int[]{7,8,9,10});
- VersionImpl sameVersion = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion, new int[]{7,8,9,10});
- VersionImpl differentVersion = new VersionImpl("HORNETQ", 2, 0, 1, 11, "suffix", nettyVersion, new int[]{7,8,9,10,11});
-
- Assert.assertFalse(version.equals(new Object()));
-
- Assert.assertTrue(version.equals(version));
- Assert.assertTrue(version.equals(sameVersion));
- Assert.assertFalse(version.equals(differentVersion));
- }
-
- public void testSerialize() throws Exception
- {
- String nettyVersion = "netty";
- VersionImpl version = new VersionImpl("uyiuy", 3, 7, 6, 12, "uhuhuh", nettyVersion, new int[]{9,10,11,12});
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(version);
- oos.flush();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- VersionImpl version2 = (VersionImpl)ois.readObject();
-
- Assert.assertTrue(version.equals(version2));
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java 2011-06-17 15:50:19 UTC (rev 10847)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java 2011-06-17 15:52:20 UTC (rev 10848)
@@ -1,176 +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.util.Random;
-import java.util.UUID;
-
-import javax.transaction.xa.Xid;
-
-import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.api.core.HornetQBuffers;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.transaction.impl.XidImpl;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public final class RandomUtil
-{
- // Constants -----------------------------------------------------
-
- private static final Random random = new Random(System.currentTimeMillis());
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- public static String randomString()
- {
- return UUID.randomUUID().toString();
- }
-
- public static SimpleString randomSimpleString()
- {
- return new SimpleString(RandomUtil.randomString());
- }
-
- public static char randomChar()
- {
- return RandomUtil.randomString().charAt(0);
- }
-
- public static long randomLong()
- {
- return RandomUtil.random.nextLong();
- }
-
- public static long randomPositiveLong()
- {
- return Math.abs(RandomUtil.randomLong());
- }
-
- public static int randomInt()
- {
- return RandomUtil.random.nextInt();
- }
-
- public static int randomPositiveInt()
- {
- return Math.abs(RandomUtil.randomInt());
- }
-
-
- public static HornetQBuffer randomBuffer(final int size, final long... data)
- {
- HornetQBuffer buffer = HornetQBuffers.fixedBuffer(size + 8 * data.length);
-
- for (long d : data)
- {
- buffer.writeLong(d);
- }
-
- for (int i = 0 ; i < size; i++)
- {
- buffer.writeByte(randomByte());
- }
-
- return buffer;
- }
-
-
-
-
- public static int randomInterval(final int min, final int max)
- {
- return min + randomMax(max - min);
- }
-
- public static int randomMax(final int max)
- {
- int value = randomPositiveInt() % max;
-
- if (value == 0)
- {
- value = max;
- }
-
- return value;
- }
-
- public static int randomPort()
- {
- return RandomUtil.random.nextInt(65536);
- }
-
- public static short randomShort()
- {
- return (short)RandomUtil.random.nextInt(Short.MAX_VALUE);
- }
-
- public static byte randomByte()
- {
- return Integer.valueOf(RandomUtil.random.nextInt()).byteValue();
- }
-
- public static boolean randomBoolean()
- {
- return RandomUtil.random.nextBoolean();
- }
-
- public static byte[] randomBytes()
- {
- return RandomUtil.randomString().getBytes();
- }
-
- public static byte[] randomBytes(final int length)
- {
- byte[] bytes = new byte[length];
- for (int i = 0; i < bytes.length; i++)
- {
- bytes[i] = RandomUtil.randomByte();
- }
- return bytes;
- }
-
- public static double randomDouble()
- {
- return RandomUtil.random.nextDouble();
- }
-
- public static float randomFloat()
- {
- return RandomUtil.random.nextFloat();
- }
-
- public static Xid randomXid()
- {
- return new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes());
- }
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-06-17 15:50:19 UTC (rev 10847)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-06-17 15:52:20 UTC (rev 10848)
@@ -1,1229 +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.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-import java.net.ServerSocket;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.naming.Context;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.api.core.HornetQException;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
-import org.hornetq.core.client.impl.ServerLocatorImpl;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
-import org.hornetq.core.postoffice.Binding;
-import org.hornetq.core.postoffice.Bindings;
-import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.postoffice.QueueBinding;
-import org.hornetq.core.postoffice.impl.LocalQueueBinding;
-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.netty.NettyAcceptorFactory;
-import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
-import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.JournalType;
-import org.hornetq.core.server.MessageReference;
-import org.hornetq.core.server.Queue;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.core.server.impl.ServerMessageImpl;
-import org.hornetq.core.transaction.impl.XidImpl;
-import org.hornetq.utils.UUIDGenerator;
-
-/**
- *
- * Helper base class for our unit tests
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:csuconic@redhat.com">Clebert</a>
- *
- */
-public class UnitTestCase extends TestCase
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(UnitTestCase.class);
-
- public static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
-
- public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
-
- public static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
-
- public static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
-
- // Attributes ----------------------------------------------------
-
- private static final String testDir = System.getProperty("java.io.tmpdir", "/tmp") + "/hornetq-unit-test";
-
- // There is a verification about thread leakages. We only fail a single thread when this happens
- private static Set<Thread> alreadyFailedThread = new HashSet<Thread>();
-
- // Static --------------------------------------------------------
-
- protected Configuration createDefaultConfig()
- {
- return createDefaultConfig(false);
- }
-
- protected Configuration createDefaultConfig(final boolean netty)
- {
- if (netty)
- {
- return createDefaultConfig(new HashMap<String, Object>(), INVM_ACCEPTOR_FACTORY, NETTY_ACCEPTOR_FACTORY);
- }
- else
- {
- return createDefaultConfig(new HashMap<String, Object>(), INVM_ACCEPTOR_FACTORY);
- }
- }
-
- protected static Configuration createClusteredDefaultConfig(final int index,
- final Map<String, Object> params,
- final String... acceptors)
- {
- Configuration config = createDefaultConfig(index, params, acceptors);
-
- config.setClustered(true);
-
- return config;
- }
-
- protected static Configuration createDefaultConfig(final int index,
- final Map<String, Object> params,
- final String... acceptors)
- {
- Configuration configuration = createBasicConfig(index);
-
- configuration.getAcceptorConfigurations().clear();
-
- for (String acceptor : acceptors)
- {
- TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
- configuration.getAcceptorConfigurations().add(transportConfig);
- }
-
- return configuration;
- }
-
- protected static ConfigurationImpl createBasicConfig()
- {
- return createBasicConfig(0);
- }
-
- /**
- * @param serverID
- * @return
- */
- protected static ConfigurationImpl createBasicConfig(final int serverID)
- {
- ConfigurationImpl configuration = new ConfigurationImpl();
- configuration.setSecurityEnabled(false);
- configuration.setBindingsDirectory(getBindingsDir(serverID, false));
- configuration.setJournalMinFiles(2);
- configuration.setJournalDirectory(getJournalDir(serverID, false));
- configuration.setJournalFileSize(100 * 1024);
- configuration.setJournalType(getDefaultJournalType());
- configuration.setPagingDirectory(getPageDir(serverID, false));
- configuration.setLargeMessagesDirectory(getLargeMessagesDir(serverID, false));
- configuration.setJournalCompactMinFiles(0);
- configuration.setJournalCompactPercentage(0);
- return configuration;
- }
-
- protected static Configuration createDefaultConfig(final Map<String, Object> params, final String... acceptors)
- {
- Configuration configuration = new ConfigurationImpl();
- configuration.setSecurityEnabled(false);
- configuration.setJMXManagementEnabled(false);
- configuration.setBindingsDirectory(getBindingsDir());
- configuration.setJournalMinFiles(2);
- configuration.setJournalDirectory(getJournalDir());
- configuration.setJournalFileSize(100 * 1024);
- configuration.setPagingDirectory(getPageDir());
- configuration.setLargeMessagesDirectory(getLargeMessagesDir());
- configuration.setJournalCompactMinFiles(0);
- configuration.setJournalCompactPercentage(0);
-
- configuration.setFileDeploymentEnabled(false);
-
- configuration.setJournalType(getDefaultJournalType());
-
- configuration.getAcceptorConfigurations().clear();
-
- for (String acceptor : acceptors)
- {
- TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
- configuration.getAcceptorConfigurations().add(transportConfig);
- }
-
- return configuration;
- }
-
- protected static String getUDPDiscoveryAddress()
- {
- return System.getProperty("TEST-UDP-ADDRESS", "230.1.2.3");
- }
-
- protected static String getUDPDiscoveryAddress(final int variant)
- {
- String value = getUDPDiscoveryAddress();
-
- int posPoint = value.lastIndexOf('.');
-
- int last = Integer.valueOf(value.substring(posPoint + 1));
-
- return value.substring(0, posPoint + 1) + (last + variant);
- }
-
- public static int getUDPDiscoveryPort()
- {
- return Integer.parseInt(System.getProperty("TEST-UDP-PORT", "6750"));
- }
-
- public static int getUDPDiscoveryPort(final int variant)
- {
- return getUDPDiscoveryPort() + variant;
- }
-
- protected static JournalType getDefaultJournalType()
- {
- if (AsynchronousFileImpl.isLoaded())
- {
- return JournalType.ASYNCIO;
- }
- else
- {
- return JournalType.NIO;
- }
- }
-
- /**
- * @param name
- */
- public UnitTestCase(final String name)
- {
- super(name);
- }
-
- public UnitTestCase()
- {
- super();
- }
-
- public static void forceGC()
- {
- WeakReference<Object> dumbReference = new WeakReference<Object>(new Object());
- // A loop that will wait GC, using the minimal time as possible
- while (dumbReference.get() != null)
- {
- System.gc();
- try
- {
- Thread.sleep(500);
- }
- catch (InterruptedException e)
- {
- }
- }
- }
-
- public static void forceGC(final Reference<?> ref, final long timeout)
- {
- long waitUntil = System.currentTimeMillis() + timeout;
- // A loop that will wait GC, using the minimal time as possible
- while (ref.get() != null && System.currentTimeMillis() < waitUntil)
- {
- ArrayList<String> list = new ArrayList<String>();
- for (int i = 0; i < 1000; i++)
- {
- list.add("Some string with garbage with concatenation " + i);
- }
- list.clear();
- list = null;
- System.gc();
- try
- {
- Thread.sleep(500);
- }
- catch (InterruptedException e)
- {
- }
- }
- }
-
- // verify if these weak references are released after a few GCs
- public static void checkWeakReferences(final WeakReference<?>... references)
- {
-
- int i = 0;
- boolean hasValue = false;
-
- do
- {
- hasValue = false;
-
- if (i > 0)
- {
- UnitTestCase.forceGC();
- }
-
- for (WeakReference<?> ref : references)
- {
- if (ref.get() != null)
- {
- hasValue = true;
- }
- }
- }
- while (i++ <= 30 && hasValue);
-
- for (WeakReference<?> ref : references)
- {
- Assert.assertNull(ref.get());
- }
- }
-
- public static String threadDump(final String msg)
- {
- StringWriter str = new StringWriter();
- PrintWriter out = new PrintWriter(str);
-
- Map<Thread, StackTraceElement[]> stackTrace = Thread.getAllStackTraces();
-
- out.println("*******************************************************************************");
- out.println("Complete Thread dump " + msg);
-
- for (Map.Entry<Thread, StackTraceElement[]> el : stackTrace.entrySet())
- {
- out.println("===============================================================================");
- out.println("Thread " + el.getKey() +
- " name = " +
- el.getKey().getName() +
- " id = " +
- el.getKey().getId() +
- " group = " +
- el.getKey().getThreadGroup());
- out.println();
- for (StackTraceElement traceEl : el.getValue())
- {
- out.println(traceEl);
- }
- }
-
- out.println("===============================================================================");
- out.println("End Thread dump " + msg);
- out.println("*******************************************************************************");
-
- return str.toString();
- }
-
- protected static TestSuite createAIOTestSuite(final Class<?> clazz)
- {
- TestSuite suite = new TestSuite(clazz.getName() + " testsuite");
-
- if (AIOSequentialFileFactory.isSupported())
- {
- suite.addTestSuite(clazz);
- }
- else
- {
- // System.out goes towards JUnit report
- System.out.println("Test " + clazz.getName() + " ignored as AIO is not available");
- }
-
- return suite;
- }
-
- public static String dumpBytes(final byte[] bytes)
- {
- StringBuffer buff = new StringBuffer();
-
- buff.append(System.identityHashCode(bytes) + ", size: " + bytes.length + " [");
-
- for (int i = 0; i < bytes.length; i++)
- {
- buff.append(bytes[i]);
-
- if (i != bytes.length - 1)
- {
- buff.append(", ");
- }
- }
-
- buff.append("]");
-
- return buff.toString();
- }
-
- public static String dumbBytesHex(final byte[] buffer, final int bytesPerLine)
- {
-
- StringBuffer buff = new StringBuffer();
-
- buff.append("[");
-
- for (int i = 0; i < buffer.length; i++)
- {
- buff.append(String.format("%1$2X", buffer[i]));
- if (i + 1 < buffer.length)
- {
- buff.append(", ");
- }
- if ((i + 1) % bytesPerLine == 0)
- {
- buff.append("\n ");
- }
- }
- buff.append("]");
-
- return buff.toString();
- }
-
- public static void assertEqualsByteArrays(final byte[] expected, final byte[] actual)
- {
- // assertEquals(expected.length, actual.length);
- for (int i = 0; i < expected.length; i++)
- {
- Assert.assertEquals("byte at index " + i, expected[i], actual[i]);
- }
- }
-
- public static void assertEqualsTransportConfigurations(final TransportConfiguration[] expected,
- final TransportConfiguration[] actual)
- {
- assertEquals(expected.length, actual.length);
- for (int i = 0; i < expected.length; i++)
- {
- Assert.assertEquals("TransportConfiguration at index " + i, expected[i], actual[i]);
- }
- }
-
- public static void assertEqualsBuffers(final int size, final HornetQBuffer expected, final HornetQBuffer actual)
- {
- // assertEquals(expected.length, actual.length);
- expected.readerIndex(0);
- actual.readerIndex(0);
-
- for (int i = 0; i < size; i++)
- {
- byte b1 = expected.readByte();
- byte b2 = actual.readByte();
- Assert.assertEquals("byte at index " + i, b1, b2);
- }
- expected.resetReaderIndex();
- actual.resetReaderIndex();
- }
-
- public static void assertEqualsByteArrays(final int length, final byte[] expected, final byte[] actual)
- {
- // we check only for the given length (the arrays might be
- // larger)
- Assert.assertTrue(expected.length >= length);
- Assert.assertTrue(actual.length >= length);
- for (int i = 0; i < length; i++)
- {
- Assert.assertEquals("byte at index " + i, expected[i], actual[i]);
- }
- }
-
- public static void assertSameXids(final List<Xid> expected, final List<Xid> actual)
- {
- Assert.assertNotNull(expected);
- Assert.assertNotNull(actual);
- Assert.assertEquals(expected.size(), actual.size());
-
- for (int i = 0; i < expected.size(); i++)
- {
- Xid expectedXid = expected.get(i);
- Xid actualXid = actual.get(i);
- UnitTestCase.assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid.getBranchQualifier());
- Assert.assertEquals(expectedXid.getFormatId(), actualXid.getFormatId());
- UnitTestCase.assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid.getGlobalTransactionId());
- }
- }
-
- protected static void checkNoBinding(final Context context, final String binding)
- {
- try
- {
- context.lookup(binding);
- Assert.fail("there must be no resource to look up for " + binding);
- }
- catch (Exception e)
- {
- }
- }
-
- protected static Object checkBinding(final Context context, final String binding) throws Exception
- {
- Object o = context.lookup(binding);
- Assert.assertNotNull(o);
- return o;
- }
-
- /**
- * @param connectorConfigs
- * @return
- */
- protected ArrayList<String> registerConnectors(final HornetQServer server,
- final List<TransportConfiguration> connectorConfigs)
- {
- // The connectors need to be pre-configured at main config object but this method is taking
- // TransportConfigurations directly
- // So this will first register them at the config and then generate a list of objects
- ArrayList<String> connectors = new ArrayList<String>();
- for (TransportConfiguration tnsp : connectorConfigs)
- {
- String name = RandomUtil.randomString();
-
- server.getConfiguration().getConnectorConfigurations().put(name, tnsp);
-
- connectors.add(name);
- }
- return connectors;
- }
-
- protected static void checkFreePort(final int... ports)
- {
- for (int port : ports)
- {
- ServerSocket ssocket = null;
- try
- {
- ssocket = new ServerSocket(port);
- }
- catch (Exception e)
- {
- throw new IllegalStateException("port " + port + " is already bound");
- }
- finally
- {
- if (ssocket != null)
- {
- try
- {
- ssocket.close();
- }
- catch (IOException e)
- {
- }
- }
- }
- }
- }
-
- // Constructors --------------------------------------------------
-
- // Protected -----------------------------------------------------
-
- /**
- * @return the testDir
- */
- protected String getTestDir()
- {
- return testDir;
- }
-
- protected void clearData()
- {
- clearData(getTestDir());
- }
-
- protected void clearData(final String testDir)
- {
- // Need to delete the root
-
- File file = new File(testDir);
- deleteDirectory(file);
- file.mkdirs();
-
- recreateDirectory(getJournalDir(testDir));
- recreateDirectory(getBindingsDir(testDir));
- recreateDirectory(getPageDir(testDir));
- recreateDirectory(getLargeMessagesDir(testDir));
- recreateDirectory(getClientLargeMessagesDir(testDir));
- recreateDirectory(getTemporaryDir(testDir));
-
- System.out.println("deleted " + testDir);
- }
-
- /**
- * @return the journalDir
- */
- public static String getJournalDir()
- {
- return getJournalDir(testDir);
- }
-
- protected static String getJournalDir(final String testDir)
- {
- return testDir + "/journal";
- }
-
- protected static String getJournalDir(final int index, final boolean backup)
- {
- String dir = getJournalDir(testDir) + index + "-" + (backup ? "B" : "L");
-
- return dir;
- }
-
- /**
- * @return the bindingsDir
- */
- protected static String getBindingsDir()
- {
- return getBindingsDir(testDir);
- }
-
- /**
- * @return the bindingsDir
- */
- protected static String getBindingsDir(final String testDir)
- {
- return testDir + "/bindings";
- }
-
- /**
- * @return the bindingsDir
- */
- protected static String getBindingsDir(final int index, final boolean backup)
- {
- return getBindingsDir(testDir) + index + "-" + (backup ? "B" : "L");
- }
-
- /**
- * @return the pageDir
- */
- protected static String getPageDir()
- {
- return getPageDir(testDir);
- }
-
- /**
- * @return the pageDir
- */
- protected static String getPageDir(final String testDir)
- {
- return testDir + "/page";
- }
-
- protected static String getPageDir(final int index, final boolean backup)
- {
- return getPageDir(testDir) + index + "-" + (backup ? "B" : "L");
- }
-
- /**
- * @return the largeMessagesDir
- */
- protected static String getLargeMessagesDir()
- {
- return getLargeMessagesDir(testDir);
- }
-
- /**
- * @return the largeMessagesDir
- */
- protected static String getLargeMessagesDir(final String testDir)
- {
- return testDir + "/large-msg";
- }
-
- protected static String getLargeMessagesDir(final int index, final boolean backup)
- {
- return getLargeMessagesDir(testDir) + index + "-" + (backup ? "B" : "L");
- }
-
- /**
- * @return the clientLargeMessagesDir
- */
- protected String getClientLargeMessagesDir()
- {
- return getClientLargeMessagesDir(testDir);
- }
-
- /**
- * @return the clientLargeMessagesDir
- */
- protected String getClientLargeMessagesDir(final String testDir)
- {
- return testDir + "/client-large-msg";
- }
-
- /**
- * @return the temporaryDir
- */
- protected String getTemporaryDir()
- {
- return getTemporaryDir(testDir);
- }
-
- /**
- * @return the temporaryDir
- */
- protected String getTemporaryDir(final String testDir)
- {
- return testDir + "/temp";
- }
-
- protected static void expectHornetQException(final String message, final int errorCode, final HornetQAction action)
- {
- try
- {
- action.run();
- Assert.fail(message);
- }
- catch (Exception e)
- {
- Assert.assertTrue(e instanceof HornetQException);
- Assert.assertEquals(errorCode, ((HornetQException)e).getCode());
- }
- }
-
- protected static void expectHornetQException(final int errorCode, final HornetQAction action)
- {
- UnitTestCase.expectHornetQException("must throw a HornetQException with the expected errorCode: " + errorCode,
- errorCode,
- action);
- }
-
- protected static void expectXAException(final int errorCode, final HornetQAction action)
- {
- try
- {
- action.run();
- Assert.fail("must throw a XAException with the expected errorCode: " + errorCode);
- }
- catch (Exception e)
- {
- Assert.assertTrue(e instanceof XAException);
- Assert.assertEquals(errorCode, ((XAException)e).errorCode);
- }
- }
-
- public static byte getSamplebyte(final long position)
- {
- return (byte)('a' + position % ('z' - 'a' + 1));
- }
-
- // Creates a Fake LargeStream without using a real file
- public static InputStream createFakeLargeStream(final long size) throws Exception
- {
- return new InputStream()
- {
- private long count;
-
- private boolean closed = false;
-
- @Override
- public void close() throws IOException
- {
- super.close();
- closed = true;
- }
-
- @Override
- public int read() throws IOException
- {
- if (closed)
- {
- throw new IOException("Stream was closed");
- }
- if (count++ < size)
- {
- return UnitTestCase.getSamplebyte(count - 1);
- }
- else
- {
- return -1;
- }
- }
- };
-
- }
-
- /** It validates a Bean (POJO) using simple setters and getters with random values.
- * You can pass a list of properties to be ignored, as some properties will have a pre-defined domain (not being possible to use random-values on them) */
- protected void validateGettersAndSetters(final Object pojo, final String... ignoredProperties) throws Exception
- {
- HashSet<String> ignoreSet = new HashSet<String>();
-
- for (String ignore : ignoredProperties)
- {
- ignoreSet.add(ignore);
- }
-
- BeanInfo info = Introspector.getBeanInfo(pojo.getClass());
-
- PropertyDescriptor properties[] = info.getPropertyDescriptors();
-
- for (PropertyDescriptor prop : properties)
- {
- Object value;
-
- if (prop.getPropertyType() == String.class)
- {
- value = RandomUtil.randomString();
- }
- else if (prop.getPropertyType() == Integer.class || prop.getPropertyType() == Integer.TYPE)
- {
- value = RandomUtil.randomInt();
- }
- else if (prop.getPropertyType() == Long.class || prop.getPropertyType() == Long.TYPE)
- {
- value = RandomUtil.randomLong();
- }
- else if (prop.getPropertyType() == Boolean.class || prop.getPropertyType() == Boolean.TYPE)
- {
- value = RandomUtil.randomBoolean();
- }
- else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE)
- {
- value = RandomUtil.randomDouble();
- }
- else
- {
- System.out.println("Can't validate property of type " + prop.getPropertyType() + " on " + prop.getName());
- value = null;
- }
-
- if (value != null && prop.getWriteMethod() != null && prop.getReadMethod() == null)
- {
- System.out.println("WriteOnly property " + prop.getName() + " on " + pojo.getClass());
- }
- else if (value != null & prop.getWriteMethod() != null &&
- prop.getReadMethod() != null &&
- !ignoreSet.contains(prop.getName()))
- {
- System.out.println("Validating " + prop.getName() + " type = " + prop.getPropertyType());
- prop.getWriteMethod().invoke(pojo, value);
-
- Assert.assertEquals("Property " + prop.getName(), value, prop.getReadMethod().invoke(pojo));
- }
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- Map<Thread, StackTraceElement[]> previousThreads;
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- OperationContextImpl.clearContext();
-
- deleteDirectory(new File(getTestDir()));
-
- InVMRegistry.instance.clear();
-
- // checkFreePort(TransportConstants.DEFAULT_PORT);
-
- previousThreads = Thread.getAllStackTraces();
-
- UnitTestCase.log.info("###### starting test " + this.getClass().getName() + "." + getName());
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- cleanupPools();
-
- Map<Thread, StackTraceElement[]> threadMap = Thread.getAllStackTraces();
- for (Thread thread : threadMap.keySet())
- {
- StackTraceElement[] stack = threadMap.get(thread);
- for (StackTraceElement stackTraceElement : stack)
- {
- if (stackTraceElement.getMethodName().contains("getConnectionWithRetry") && !alreadyFailedThread.contains(thread))
- {
- alreadyFailedThread.add(thread);
- System.out.println(threadDump(getName() + " has left threads running. Look at thread " +
- thread.getName() +
- " id = " +
- thread.getId() +
- " has running locators on test " +
- getName() +
- " on this following dump"));
- fail("test left serverlocator running, this could effect other tests");
- // System.exit(0);
- }
- else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread))
- {
- alreadyFailedThread.add(thread);
- System.out.println(threadDump(getName() + " has left threads running. Look at thread " +
- thread.getName() +
- " id = " +
- thread.getId() +
- " is still broadcasting " +
- getName() +
- " on this following dump"));
- fail("test left broadcastgroupimpl running, this could effect other tests");
- // System.exit(0);
- }
- }
- }
-
- Map<Thread, StackTraceElement[]> postThreads = Thread.getAllStackTraces();
-
- if (postThreads.size() > previousThreads.size())
- {
- StringBuffer buffer = new StringBuffer();
-
-
- buffer.append("*********************************************************************************\n");
- buffer.append("LEAKING THREADS\n");
-
- for (Thread aliveThread : postThreads.keySet())
- {
- if (!aliveThread.getName().contains("SunPKCS11") && !previousThreads.containsKey(aliveThread))
- {
- buffer.append("=============================================================================\n");
- buffer.append("Thread " + aliveThread + " is still alive with the following stackTrace:\n");
- StackTraceElement[] elements = postThreads.get(aliveThread);
- for (StackTraceElement el : elements)
- {
- buffer.append(el + "\n");
- }
- }
-
- }
- buffer.append("*********************************************************************************\n");
-
- System.out.println(buffer.toString());
-
- }
-
- super.tearDown();
- }
-
- /**
- *
- */
- protected void cleanupPools()
- {
- OperationContextImpl.clearContext();
-
- deleteDirectory(new File(getTestDir()));
-
- int invmSize = InVMRegistry.instance.size();
- if (invmSize > 0)
- {
- InVMRegistry.instance.clear();
- fail("invm registry still had acceptors registered");
- }
-
- if (AsynchronousFileImpl.getTotalMaxIO() != 0)
- {
- AsynchronousFileImpl.resetMaxAIO();
- Assert.fail("test did not close all its files " + AsynchronousFileImpl.getTotalMaxIO());
- }
-
- // We shutdown the global pools to give a better isolation between tests
- ServerLocatorImpl.clearThreadPools();
- }
-
- protected byte[] autoEncode(final Object... args)
- {
-
- int size = 0;
-
- for (Object arg : args)
- {
- if (arg instanceof Byte)
- {
- size++;
- }
- else if (arg instanceof Boolean)
- {
- size++;
- }
- else if (arg instanceof Integer)
- {
- size += 4;
- }
- else if (arg instanceof Long)
- {
- size += 8;
- }
- else if (arg instanceof Float)
- {
- size += 4;
- }
- else if (arg instanceof Double)
- {
- size += 8;
- }
- else
- {
- throw new IllegalArgumentException("method autoEncode doesn't know how to convert " + arg.getClass() +
- " yet");
- }
- }
-
- ByteBuffer buffer = ByteBuffer.allocate(size);
-
- for (Object arg : args)
- {
- if (arg instanceof Byte)
- {
- buffer.put(((Byte)arg).byteValue());
- }
- else if (arg instanceof Boolean)
- {
- Boolean b = (Boolean)arg;
- buffer.put((byte)(b.booleanValue() ? 1 : 0));
- }
- else if (arg instanceof Integer)
- {
- buffer.putInt(((Integer)arg).intValue());
- }
- else if (arg instanceof Long)
- {
- buffer.putLong(((Long)arg).longValue());
- }
- else if (arg instanceof Float)
- {
- buffer.putFloat(((Float)arg).floatValue());
- }
- else if (arg instanceof Double)
- {
- buffer.putDouble(((Double)arg).doubleValue());
- }
- else
- {
- throw new IllegalArgumentException("method autoEncode doesn't know how to convert " + arg.getClass() +
- " yet");
- }
- }
-
- return buffer.array();
- }
-
- protected void recreateDirectory(final String directory)
- {
- File file = new File(directory);
- deleteDirectory(file);
- file.mkdirs();
- }
-
- protected boolean deleteDirectory(final File directory)
- {
- if (directory.isDirectory())
- {
- String[] files = directory.list();
-
- for (int j = 0; j < files.length; j++)
- {
- if (!deleteDirectory(new File(directory, files[j])))
- {
- return false;
- }
- }
- }
-
- return directory.delete();
- }
-
- protected void copyRecursive(final File from, final File to) throws Exception
- {
- if (from.isDirectory())
- {
- if (!to.exists())
- {
- to.mkdir();
- }
-
- String[] subs = from.list();
-
- for (String sub : subs)
- {
- copyRecursive(new File(from, sub), new File(to, sub));
- }
- }
- else
- {
- InputStream in = null;
-
- OutputStream out = null;
-
- try
- {
- in = new BufferedInputStream(new FileInputStream(from));
-
- out = new BufferedOutputStream(new FileOutputStream(to));
-
- int b;
-
- while ((b = in.read()) != -1)
- {
- out.write(b);
- }
- }
- finally
- {
- if (in != null)
- {
- in.close();
- }
-
- if (out != null)
- {
- out.close();
- }
- }
- }
- }
-
- protected void assertRefListsIdenticalRefs(final List<MessageReference> l1, final List<MessageReference> l2)
- {
- if (l1.size() != l2.size())
- {
- Assert.fail("Lists different sizes: " + l1.size() + ", " + l2.size());
- }
-
- Iterator<MessageReference> iter1 = l1.iterator();
- Iterator<MessageReference> iter2 = l2.iterator();
-
- while (iter1.hasNext())
- {
- MessageReference o1 = iter1.next();
- MessageReference o2 = iter2.next();
-
- Assert.assertTrue("expected " + o1 + " but was " + o2, o1 == o2);
- }
- }
-
- protected ServerMessage generateMessage(final long id)
- {
- ServerMessage message = new ServerMessageImpl(id, 1000);
-
- message.setMessageID(id);
-
- message.getBodyBuffer().writeString(UUID.randomUUID().toString());
-
- message.setAddress(new SimpleString("foo"));
-
- return message;
- }
-
- protected MessageReference generateReference(final Queue queue, final long id)
- {
- ServerMessage message = generateMessage(id);
-
- return message.createReference(queue);
- }
-
- protected int calculateRecordSize(final int size, final int alignment)
- {
- return (size / alignment + (size % alignment != 0 ? 1 : 0)) * alignment;
- }
-
- protected XidImpl newXID()
- {
- return new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- }
-
- protected int getMessageCount(final HornetQServer service, final String address) throws Exception
- {
- return getMessageCount(service.getPostOffice(), address);
- }
-
- /**
- * @param address
- * @param postOffice
- * @return
- * @throws Exception
- */
- protected int getMessageCount(final PostOffice postOffice, final String address) throws Exception
- {
- int messageCount = 0;
-
- List<QueueBinding> bindings = getLocalQueueBindings(postOffice, address);
-
- for (QueueBinding qBinding : bindings)
- {
- messageCount += qBinding.getQueue().getMessageCount();
- }
-
- return messageCount;
- }
-
- protected
- List<QueueBinding>
- getLocalQueueBindings(final PostOffice postOffice, final String address) throws Exception
- {
- ArrayList<QueueBinding> bindingsFound = new ArrayList<QueueBinding>();
-
- Bindings bindings = postOffice.getBindingsForAddress(new SimpleString(address));
-
- for (Binding binding : bindings.getBindings())
- {
- if (binding instanceof LocalQueueBinding)
- {
- bindingsFound.add((QueueBinding)binding);
- }
- }
- return bindingsFound;
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- protected static interface HornetQAction
- {
- void run() throws Exception;
- }
-
-}
13 years, 6 months
JBoss hornetq SVN: r10847 - in trunk/tests: integration-tests/src/test/java/org/hornetq/tests/integration/management and 7 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-06-17 11:50:19 -0400 (Fri, 17 Jun 2011)
New Revision: 10847
Added:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/CreateMessage.java
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessagePriorityTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java
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/security/SecurityTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/ExpiryRunnerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQRecoveryTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/XaTimeoutTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Log:
Move CreateMessage utility methods to own class, removing JMS dependencies from base TestCases.
(allowing unit-testing code to be moved to hornetq-core/src/tests.)
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -27,6 +27,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.spi.core.protocol.RemotingConnection;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -82,7 +83,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -116,7 +117,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -150,7 +151,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -188,7 +189,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -228,7 +229,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
session.close();
@@ -293,7 +294,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -37,6 +37,7 @@
import org.hornetq.core.server.Consumer;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.impl.ServerConsumerImpl;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -434,7 +435,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- prod.send(createTextMessage(session, "Msg" + i));
+ prod.send(CreateMessage.createTextMessage(session, "Msg" + i, true));
}
for (int i = 0; i < numberOfMessages - 1; i++)
@@ -534,7 +535,7 @@
// or the client will be buffering messages
Assert.assertNull(consNeverUsed.receive(1));
- ClientMessage msg = createTextMessage(session, "This one will expire");
+ ClientMessage msg = CreateMessage.createTextMessage(session, "This one will expire", true);
if (largeMessages)
{
msg.getBodyBuffer().writeBytes(new byte[600]);
@@ -543,7 +544,7 @@
msg.setExpiration(System.currentTimeMillis() + 100);
prod.send(msg);
- msg = createTextMessage(session, "First-on-non-buffered");
+ msg = CreateMessage.createTextMessage(session, "First-on-non-buffered", true);
prod.send(msg);
@@ -560,7 +561,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- msg = createTextMessage(session, "Msg" + i);
+ msg = CreateMessage.createTextMessage(session, "Msg" + i, true);
if (largeMessages)
{
@@ -665,7 +666,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- ClientMessage msg = createTextMessage(session1, "Msg" + i);
+ ClientMessage msg = CreateMessage.createTextMessage(session1, "Msg" + i, true);
if (largeMessages)
{
msg.getBodyBuffer().writeBytes(new byte[600]);
@@ -736,7 +737,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- ClientMessage msg = createTextMessage(session1, "Msg" + i);
+ ClientMessage msg = CreateMessage.createTextMessage(session1, "Msg" + i, true);
if (largeMessages)
{
msg.getBodyBuffer().writeBytes(new byte[600]);
@@ -1009,7 +1010,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- ClientMessage msg = createTextMessage(session, "Msg" + i);
+ ClientMessage msg = CreateMessage.createTextMessage(session, "Msg" + i, true);
if (largeMessages)
{
msg.getBodyBuffer().writeBytes(new byte[600]);
@@ -1171,7 +1172,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- ClientMessage msg = createTextMessage(session, "Msg" + i);
+ ClientMessage msg = CreateMessage.createTextMessage(session, "Msg" + i, true);
if (largeMessage)
{
msg.getBodyBuffer().writeBytes(new byte[600]);
@@ -1319,7 +1320,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
- ClientMessage msg = createTextMessage(sessionA, "Msg" + i);
+ ClientMessage msg = CreateMessage.createTextMessage(sessionA, "Msg" + i, true);
if (largeMessages)
{
msg.getBodyBuffer().writeBytes(new byte[600]);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -37,6 +37,7 @@
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -65,7 +66,7 @@
clientSession.createQueue(dla, dlq, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- producer.send(createTextMessage("heyho!", clientSession));
+ producer.send(CreateMessage.createTextMessage("heyho!", clientSession));
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(qName);
ClientMessage m = clientConsumer.receive(500);
@@ -95,7 +96,7 @@
clientSession.createQueue(dla, dlq, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- producer.send(createTextMessage("heyho!", clientSession));
+ producer.send(CreateMessage.createTextMessage("heyho!", clientSession));
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(qName);
ClientMessage m = clientConsumer.receive(5000);
@@ -132,7 +133,7 @@
clientSession.createQueue(dla, dlq, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- producer.send(createTextMessage("heyho!", clientSession));
+ producer.send(CreateMessage.createTextMessage("heyho!", clientSession));
ClientConsumer clientConsumer = clientSession.createConsumer(qName);
final CountDownLatch latch = new CountDownLatch(2);
TestHandler handler = new TestHandler(latch, clientSession);
@@ -189,7 +190,7 @@
clientSession.createQueue(dla, dlq2, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- producer.send(createTextMessage("heyho!", clientSession));
+ producer.send(CreateMessage.createTextMessage("heyho!", clientSession));
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(qName);
ClientMessage m = clientConsumer.receive(500);
@@ -223,7 +224,7 @@
server.getAddressSettingsRepository().addMatch(qName.toString(), addressSettings);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- producer.send(createTextMessage("heyho!", clientSession));
+ producer.send(CreateMessage.createTextMessage("heyho!", clientSession));
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(qName);
ClientMessage m = clientConsumer.receive(500);
@@ -258,7 +259,7 @@
for (int i = 0; i < NUM_MESSAGES; i++)
{
- ClientMessage tm = createTextMessage("Message:" + i, clientSession);
+ ClientMessage tm = CreateMessage.createTextMessage("Message:" + i, clientSession);
producer.send(tm);
}
@@ -339,7 +340,7 @@
clientSession.createQueue(deadLetterAdress, deadLetterQueue, false);
ClientProducer producer = clientSession.createProducer(address);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
producer.send(clientMessage);
clientSession.start();
@@ -381,7 +382,7 @@
clientSession.createQueue(deadLetterAdress, deadLetterQueue, false);
ClientProducer producer = clientSession.createProducer(address);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
producer.send(clientMessage);
clientSession.start();
@@ -430,7 +431,7 @@
clientSession.createQueue(specificDeadLetterAddress, specificDeadLetterQueue, false);
ClientProducer producer = clientSession.createProducer(address);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
producer.send(clientMessage);
clientSession.start();
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -25,6 +25,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -53,7 +54,7 @@
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
clientMessage.setExpiration(System.currentTimeMillis());
producer.send(clientMessage);
@@ -84,7 +85,7 @@
clientSession.createQueue(ea, eq2, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
clientMessage.setExpiration(System.currentTimeMillis());
producer.send(clientMessage);
@@ -136,7 +137,7 @@
clientSession.createQueue(ea, eq2, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
clientMessage.setExpiration(System.currentTimeMillis());
producer.send(clientMessage);
clientSession.start();
@@ -167,7 +168,7 @@
long expiration = System.currentTimeMillis();
for (int i = 0; i < NUM_MESSAGES; i++)
{
- ClientMessage tm = createTextMessage("Message:" + i, clientSession);
+ ClientMessage tm = CreateMessage.createTextMessage("Message:" + i, clientSession);
tm.setExpiration(expiration);
producer.send(tm);
}
@@ -212,7 +213,7 @@
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
clientMessage.setExpiration(System.currentTimeMillis());
producer.send(clientMessage);
@@ -241,7 +242,7 @@
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
clientMessage.setExpiration(System.currentTimeMillis());
producer.send(clientMessage);
@@ -279,7 +280,7 @@
clientSession.createQueue(specificExpiryAddress, specificExpiryQueue, false);
ClientProducer producer = clientSession.createProducer(address);
- ClientMessage clientMessage = createTextMessage("heyho!", clientSession);
+ ClientMessage clientMessage = CreateMessage.createTextMessage("heyho!", clientSession);
clientMessage.setExpiration(System.currentTimeMillis());
producer.send(clientMessage);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageCounterTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -18,6 +18,7 @@
import org.hornetq.api.core.client.*;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -75,7 +76,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingConnectionFactoryTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -27,6 +27,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -64,7 +65,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
clientProducer.send(message);
}
CountDownLatch latch = new CountDownLatch(numMessages);
@@ -91,7 +92,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
clientProducer.send(message);
clientProducer2.send(message);
clientProducer3.send(message);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageGroupingTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -32,6 +32,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.transaction.impl.XidImpl;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -99,7 +100,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
clientProducer.send(message);
}
@@ -131,7 +132,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
@@ -174,7 +175,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
@@ -222,7 +223,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
@@ -283,7 +284,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
@@ -358,7 +359,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
@@ -419,7 +420,7 @@
int numMessages = 100;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
@@ -493,7 +494,7 @@
int numMessages = 4;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, clientSession);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0 || i == 0)
{
message.putStringProperty(Message.HDR_GROUP_ID, groupId);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessageHandlerTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -21,6 +21,7 @@
import org.hornetq.api.core.client.*;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -74,7 +75,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -135,7 +136,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
@@ -237,7 +238,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -325,7 +326,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessagePriorityTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessagePriorityTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/MessagePriorityTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -29,6 +29,7 @@
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -72,7 +73,7 @@
for (int i = 0; i < 10; i++)
{
- ClientMessage m = createTextMessage(Integer.toString(i), session);
+ ClientMessage m = CreateMessage.createTextMessage(Integer.toString(i), session);
m.setPriority((byte)i);
producer.send(m);
}
@@ -114,7 +115,7 @@
for (int i = 0; i < 10; i++)
{
- ClientMessage m = createTextMessage(Integer.toString(i), session);
+ ClientMessage m = CreateMessage.createTextMessage(Integer.toString(i), session);
m.setPriority((byte)i);
producer.send(m);
}
@@ -153,28 +154,28 @@
// 3 7
// 3 3
// 1 9
- messages[0] = createTextMessage("a", session);
+ messages[0] = CreateMessage.createTextMessage("a", session);
messages[0].setPriority((byte)0);
- messages[1] = createTextMessage("b", session);
+ messages[1] = CreateMessage.createTextMessage("b", session);
messages[1].setPriority((byte)0);
- messages[2] = createTextMessage("c", session);
+ messages[2] = CreateMessage.createTextMessage("c", session);
messages[2].setPriority((byte)0);
- messages[3] = createTextMessage("d", session);
+ messages[3] = CreateMessage.createTextMessage("d", session);
messages[3].setPriority((byte)7);
- messages[4] = createTextMessage("e", session);
+ messages[4] = CreateMessage.createTextMessage("e", session);
messages[4].setPriority((byte)7);
- messages[5] = createTextMessage("f", session);
+ messages[5] = CreateMessage.createTextMessage("f", session);
messages[5].setPriority((byte)7);
- messages[6] = createTextMessage("g", session);
+ messages[6] = CreateMessage.createTextMessage("g", session);
messages[6].setPriority((byte)3);
- messages[7] = createTextMessage("h", session);
+ messages[7] = CreateMessage.createTextMessage("h", session);
messages[7].setPriority((byte)3);
- messages[8] = createTextMessage("i", session);
+ messages[8] = CreateMessage.createTextMessage("i", session);
messages[8].setPriority((byte)3);
- messages[9] = createTextMessage("j", session);
+ messages[9] = CreateMessage.createTextMessage("j", session);
messages[9].setPriority((byte)9);
for (int i = 0; i < 10; i++)
@@ -222,7 +223,7 @@
for (int i = 0; i < 10; i++)
{
- ClientMessage m = createTextMessage(Integer.toString(i), session);
+ ClientMessage m = CreateMessage.createTextMessage(Integer.toString(i), session);
m.setPriority((byte)i);
producer.send(m);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -23,6 +23,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -51,7 +52,7 @@
SimpleString dlq = new SimpleString("DLQ1");
clientSession.createQueue(dla, dlq, null, false);
ClientProducer producer = clientSession.createProducer(address);
- producer.send(createTextMessage("heyho!", clientSession));
+ producer.send(CreateMessage.createTextMessage("heyho!", clientSession));
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(dlq);
ClientMessage m = clientConsumer.receive(500);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -20,6 +20,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -77,7 +78,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -124,7 +125,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("x"), i);
producer.send(message);
}
@@ -172,7 +173,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
if (i % 2 == 0)
{
message.putStringProperty(new SimpleString("color"), new SimpleString("RED"));
@@ -210,7 +211,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -248,7 +249,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("x"), i);
producer.send(message);
}
@@ -303,7 +304,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
@@ -338,7 +339,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -29,6 +29,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.server.Queue;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -247,7 +248,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
producer.send(message);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -35,6 +35,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -97,7 +98,7 @@
for (int i = 0; i < 10; i++)
{
- prod.send(createTextMessage(session, Integer.toString(i), persistent));
+ prod.send(CreateMessage.createTextMessage(session, Integer.toString(i), persistent));
}
session.commit();
@@ -196,7 +197,7 @@
RedeliveryConsumerTest.log.info("created");
ClientProducer prod = session.createProducer(ADDRESS);
- prod.send(createTextMessage(session, "Hello"));
+ prod.send(CreateMessage.createTextMessage(session, "Hello", true));
session.commit();
session.close();
@@ -251,7 +252,7 @@
RedeliveryConsumerTest.log.info("created");
ClientProducer prod = session.createProducer(ADDRESS);
- prod.send(createTextMessage(session, "Hello"));
+ prod.send(CreateMessage.createTextMessage(session, "Hello", true));
session.commit();
session.close();
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionStopStartTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -21,6 +21,7 @@
import org.hornetq.api.core.client.*;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -74,7 +75,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -118,7 +119,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -165,7 +166,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -255,7 +256,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -353,7 +354,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -455,7 +456,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -572,7 +573,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -625,7 +626,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
@@ -666,7 +667,7 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = createTextMessage("m" + i, session);
+ ClientMessage message = CreateMessage.createTextMessage("m" + i, session);
message.putIntProperty(new SimpleString("i"), i);
producer.send(message);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -22,6 +22,7 @@
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -49,8 +50,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -74,8 +75,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -107,8 +108,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -148,8 +149,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -177,8 +178,8 @@
clientSession.createQueue(addressAB, queueName1, null, false);
clientSession.createQueue(addressAC, queueName2, null, false);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -209,8 +210,8 @@
clientSession.deleteQueue(queueName1);
// the wildcard binding should still exist
Assert.assertEquals(server.getPostOffice().getBindingsForAddress(addressAB).getBindings().size(), 1);
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -259,15 +260,15 @@
ClientProducer producer = clientSession.createProducer();
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(addressAB, createTextMessage("m1", clientSession));
- producer.send(addressAC, createTextMessage("m2", clientSession));
- producer.send(addressAD, createTextMessage("m3", clientSession));
- producer.send(addressAE, createTextMessage("m4", clientSession));
- producer.send(addressAF, createTextMessage("m5", clientSession));
- producer.send(addressAG, createTextMessage("m6", clientSession));
- producer.send(addressAH, createTextMessage("m7", clientSession));
- producer.send(addressAJ, createTextMessage("m8", clientSession));
- producer.send(addressAK, createTextMessage("m9", clientSession));
+ producer.send(addressAB, CreateMessage.createTextMessage("m1", clientSession));
+ producer.send(addressAC, CreateMessage.createTextMessage("m2", clientSession));
+ producer.send(addressAD, CreateMessage.createTextMessage("m3", clientSession));
+ producer.send(addressAE, CreateMessage.createTextMessage("m4", clientSession));
+ producer.send(addressAF, CreateMessage.createTextMessage("m5", clientSession));
+ producer.send(addressAG, CreateMessage.createTextMessage("m6", clientSession));
+ producer.send(addressAH, CreateMessage.createTextMessage("m7", clientSession));
+ producer.send(addressAJ, CreateMessage.createTextMessage("m8", clientSession));
+ producer.send(addressAK, CreateMessage.createTextMessage("m9", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
@@ -356,15 +357,15 @@
ClientProducer producer = clientSession.createProducer();
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(addressAB, createTextMessage("m1", clientSession));
- producer.send(addressAC, createTextMessage("m2", clientSession));
- producer.send(addressAD, createTextMessage("m3", clientSession));
- producer.send(addressAE, createTextMessage("m4", clientSession));
- producer.send(addressAF, createTextMessage("m5", clientSession));
- producer.send(addressAG, createTextMessage("m6", clientSession));
- producer.send(addressAH, createTextMessage("m7", clientSession));
- producer.send(addressAJ, createTextMessage("m8", clientSession));
- producer.send(addressAK, createTextMessage("m9", clientSession));
+ producer.send(addressAB, CreateMessage.createTextMessage("m1", clientSession));
+ producer.send(addressAC, CreateMessage.createTextMessage("m2", clientSession));
+ producer.send(addressAD, CreateMessage.createTextMessage("m3", clientSession));
+ producer.send(addressAE, CreateMessage.createTextMessage("m4", clientSession));
+ producer.send(addressAF, CreateMessage.createTextMessage("m5", clientSession));
+ producer.send(addressAG, CreateMessage.createTextMessage("m6", clientSession));
+ producer.send(addressAH, CreateMessage.createTextMessage("m7", clientSession));
+ producer.send(addressAJ, CreateMessage.createTextMessage("m8", clientSession));
+ producer.send(addressAK, CreateMessage.createTextMessage("m9", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
@@ -433,8 +434,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -462,8 +463,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -492,8 +493,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -521,8 +522,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -550,8 +551,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -575,8 +576,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -602,8 +603,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m2", m.getBodyBuffer().readString());
@@ -627,8 +628,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m2", m.getBodyBuffer().readString());
@@ -652,8 +653,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -677,8 +678,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -702,8 +703,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
@@ -730,8 +731,8 @@
ClientProducer producer2 = clientSession.createProducer(addressAC);
ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
clientSession.start();
- producer.send(createTextMessage("m1", clientSession));
- producer2.send(createTextMessage("m2", clientSession));
+ producer.send(CreateMessage.createTextMessage("m1", clientSession));
+ producer2.send(CreateMessage.createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals("m1", m.getBodyBuffer().readString());
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -45,6 +45,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.transaction.impl.XidImpl;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.UUIDGenerator;
@@ -722,10 +723,10 @@
ClientSession clientSession = csf.createSession(true, false, false);
clientSession.createQueue(atestq, atestq, null, true);
- ClientMessage m1 = createTextMessage(clientSession, "");
- ClientMessage m2 = createTextMessage(clientSession, "");
- ClientMessage m3 = createTextMessage(clientSession, "");
- ClientMessage m4 = createTextMessage(clientSession, "");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession, "", true);
+ ClientMessage m2 = CreateMessage.createTextMessage(clientSession, "", true);
+ ClientMessage m3 = CreateMessage.createTextMessage(clientSession, "", true);
+ ClientMessage m4 = CreateMessage.createTextMessage(clientSession, "", true);
m1.putStringProperty("m1", "m1");
m2.putStringProperty("m2", "m2");
m3.putStringProperty("m3", "m3");
@@ -767,10 +768,10 @@
ClientSession clientSession = csf.createSession(true, false, false);
clientSession.createQueue(atestq, atestq, null, true);
- ClientMessage m1 = createTextMessage(clientSession, "");
- ClientMessage m2 = createTextMessage(clientSession, "");
- ClientMessage m3 = createTextMessage(clientSession, "");
- ClientMessage m4 = createTextMessage(clientSession, "");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession, "", true);
+ ClientMessage m2 = CreateMessage.createTextMessage(clientSession, "", true);
+ ClientMessage m3 = CreateMessage.createTextMessage(clientSession, "", true);
+ ClientMessage m4 = CreateMessage.createTextMessage(clientSession, "", true);
m1.putStringProperty("m1", "m1");
m2.putStringProperty("m2", "m2");
m3.putStringProperty("m3", "m3");
@@ -809,7 +810,7 @@
ClientSession clientSession = csf.createSession(true, false, false);
clientSession.createQueue(recQueue, recQueue, null, true);
clientSession.createQueue(sendQueue, sendQueue, null, true);
- ClientMessage m1 = createTextMessage(clientSession, "");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession, "", true);
m1.putStringProperty("m1", "m1");
ClientProducer clientProducer = clientSession.createProducer(recQueue);
clientProducer.send(m1);
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-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/DeleteQueueRestartTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -21,6 +21,7 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.client.*;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -81,7 +82,7 @@
for (int i = 0; i < 100; i++)
{
- ClientMessage msg = createBytesMessage(session, new byte[0], true);
+ ClientMessage msg = CreateMessage.createBytesMessage(session, new byte[0], true);
prod.send(msg);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -41,6 +41,7 @@
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.spi.core.security.HornetQSecurityManager;
import org.hornetq.spi.core.security.JAASSecurityManager;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
import org.jboss.security.SimpleGroup;
@@ -870,8 +871,8 @@
ClientSession sendingSession = cf.createSession("auser", "pass", false, false, false, false, 0);
ClientProducer prod = sendingSession.createProducer(SecurityTest.addressA);
- prod.send(createTextMessage(sendingSession, "Test", true));
- prod.send(createTextMessage(sendingSession, "Test", true));
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
try
{
sendingSession.commit();
@@ -890,8 +891,8 @@
sendingSession.start(xid, XAResource.TMNOFLAGS);
prod = sendingSession.createProducer(SecurityTest.addressA);
- prod.send(createTextMessage(sendingSession, "Test", true));
- prod.send(createTextMessage(sendingSession, "Test", true));
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
sendingSession.end(xid, XAResource.TMSUCCESS);
try
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/ExpiryRunnerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/ExpiryRunnerTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/ExpiryRunnerTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -31,6 +31,7 @@
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -59,7 +60,7 @@
long expiration = System.currentTimeMillis();
for (int i = 0; i < numMessages; i++)
{
- ClientMessage m = createTextMessage("m" + i, clientSession);
+ ClientMessage m = CreateMessage.createTextMessage("m" + i, clientSession);
m.setExpiration(expiration);
producer.send(m);
}
@@ -80,10 +81,10 @@
long expiration = System.currentTimeMillis();
for (int i = 0; i < numMessages; i++)
{
- ClientMessage m = createTextMessage("m" + i, clientSession);
+ ClientMessage m = CreateMessage.createTextMessage("m" + i, clientSession);
m.setExpiration(expiration);
producer.send(m);
- m = createTextMessage("m" + i, clientSession);
+ m = CreateMessage.createTextMessage("m" + i, clientSession);
m.setExpiration(expiration);
producer2.send(m);
}
@@ -99,7 +100,7 @@
long expiration = System.currentTimeMillis();
for (int i = 0; i < numMessages; i++)
{
- ClientMessage m = createTextMessage("m" + i, clientSession);
+ ClientMessage m = CreateMessage.createTextMessage("m" + i, clientSession);
if (i % 2 == 0)
{
m.setExpiration(expiration);
@@ -119,7 +120,7 @@
long expiration = System.currentTimeMillis() + 1000;
for (int i = 0; i < numMessages; i++)
{
- ClientMessage m = createTextMessage("m" + i, clientSession);
+ ClientMessage m = CreateMessage.createTextMessage("m" + i, clientSession);
m.setExpiration(expiration);
producer.send(m);
}
@@ -151,7 +152,7 @@
long expiration = System.currentTimeMillis();
for (int i = 0; i < numMessages; i++)
{
- ClientMessage m = createTextMessage("m" + i, clientSession);
+ ClientMessage m = CreateMessage.createTextMessage("m" + i, clientSession);
m.setExpiration(expiration);
producer.send(m);
}
@@ -190,7 +191,7 @@
long sendMessagesUntil = System.currentTimeMillis() + 2000;
do
{
- ClientMessage m = createTextMessage("m" + numMessages++, clientSession);
+ ClientMessage m = CreateMessage.createTextMessage("m" + numMessages++, clientSession);
m.setExpiration(expiration);
producer.send(m);
Thread.sleep(100);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQRecoveryTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQRecoveryTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQRecoveryTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -26,6 +26,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.core.transaction.impl.XidImpl;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -55,13 +56,13 @@
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
clientSessionXa.start(xid, XAResource.TMNOFLAGS);
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
producer.send(m1);
producer.send(m2);
@@ -94,22 +95,22 @@
ClientConsumer consumer = clientSessionXa.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m1.setDurable(true);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m2.setDurable(true);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m3.setDurable(true);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m4.setDurable(true);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m5.setDurable(true);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m6.setDurable(true);
clientSessionXa.start(xid, XAResource.TMNOFLAGS);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/server/LVQTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -24,6 +24,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -50,10 +51,10 @@
{
ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
producer.send(m1);
producer.send(m2);
@@ -70,13 +71,13 @@
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
producer.send(m1);
producer.send(m2);
@@ -97,10 +98,10 @@
{
ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
producer.send(m1);
clientSession.start();
@@ -119,10 +120,10 @@
{
ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
producer.send(m1);
clientSession.start();
@@ -146,17 +147,17 @@
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
clientSession.start();
producer.send(m1);
@@ -198,10 +199,10 @@
ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
producer.send(m1);
producer.send(m2);
@@ -218,13 +219,13 @@
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
producer.send(m1);
producer.send(m2);
@@ -250,13 +251,13 @@
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId2);
producer.send(m1);
producer.send(m2);
@@ -295,7 +296,7 @@
ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, messageId1);
producer.send(m1);
clientSessionTxReceives.start();
@@ -315,17 +316,17 @@
ClientProducer producer = clientSessionTxSends.createProducer(address);
ClientConsumer consumer = clientSessionTxSends.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
producer.send(m1);
producer.send(m2);
@@ -346,22 +347,22 @@
ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m1.setDurable(true);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m2.setDurable(true);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m3.setDurable(true);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m4.setDurable(true);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m5.setDurable(true);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m6.setDurable(true);
producer.send(m1);
@@ -384,22 +385,22 @@
ClientProducer producer = clientSessionTxSends.createProducer(address);
ClientConsumer consumer = clientSessionTxSends.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m1.setDurable(true);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m2.setDurable(true);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m3.setDurable(true);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m4.setDurable(true);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m5.setDurable(true);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m6.setDurable(true);
producer.send(m1);
@@ -423,22 +424,22 @@
ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m1.setDurable(true);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m2.setDurable(true);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m3.setDurable(true);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m4.setDurable(true);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m5.setDurable(true);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m6.setDurable(true);
clientSession.start();
@@ -479,22 +480,22 @@
ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
- ClientMessage m1 = createTextMessage("m1", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
m1.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m1.setDurable(true);
- ClientMessage m2 = createTextMessage("m2", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
m2.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m2.setDurable(true);
- ClientMessage m3 = createTextMessage("m3", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
m3.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m3.setDurable(true);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
m4.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m4.setDurable(true);
- ClientMessage m5 = createTextMessage("m5", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
m5.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m5.setDurable(true);
- ClientMessage m6 = createTextMessage("m6", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
m6.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
m6.setDurable(true);
clientSessionTxReceives.start();
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -30,6 +30,7 @@
import org.hornetq.core.remoting.impl.netty.TransportConstants;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
@@ -76,7 +77,7 @@
session.createQueue(CoreClientOverSSLTest.QUEUE, CoreClientOverSSLTest.QUEUE, false);
ClientProducer producer = session.createProducer(CoreClientOverSSLTest.QUEUE);
- ClientMessage message = createTextMessage(text, session);
+ ClientMessage message = CreateMessage.createTextMessage(text, session);
producer.send(message);
ClientConsumer consumer = session.createConsumer(CoreClientOverSSLTest.QUEUE);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -31,6 +31,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.core.transaction.impl.XidImpl;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.UUIDGenerator;
@@ -268,8 +269,8 @@
ClientSession recSession = sessionFactory.createSession();
recSession.start();
ClientConsumer clientConsumer = recSession.createConsumer(atestq);
- ClientMessage m1 = createTextMessage(clientSession, "m1");
- ClientMessage m2 = createTextMessage(clientSession, "m2");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession, "m1", true);
+ ClientMessage m2 = CreateMessage.createTextMessage(clientSession, "m2", true);
clientSession.start(xid, XAResource.TMNOFLAGS);
clientProducer.send(m1);
clientSession.end(xid, XAResource.TMSUSPEND);
@@ -294,7 +295,7 @@
Xid xid3 = newXID();
ClientProducer clientProducer = clientSession.createProducer(atestq);
ClientConsumer clientConsumer = clientSession.createConsumer(atestq);
- ClientMessage m1 = createTextMessage(clientSession, "m1");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession, "m1", true);
clientSession.start(xid, XAResource.TMNOFLAGS);
clientProducer.send(m1);
clientSession.end(xid, XAResource.TMSUCCESS);
@@ -320,10 +321,10 @@
{
Xid xid = newXID();
- ClientMessage m1 = createTextMessage(clientSession, "m1");
- ClientMessage m2 = createTextMessage(clientSession, "m2");
- ClientMessage m3 = createTextMessage(clientSession, "m3");
- ClientMessage m4 = createTextMessage(clientSession, "m4");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession, "m1", true);
+ ClientMessage m2 = CreateMessage.createTextMessage(clientSession, "m2", true);
+ ClientMessage m3 = CreateMessage.createTextMessage(clientSession, "m3", true);
+ ClientMessage m4 = CreateMessage.createTextMessage(clientSession, "m4", true);
ClientProducer clientProducer = clientSession.createProducer(atestq);
clientSession.start(xid, XAResource.TMNOFLAGS);
clientProducer.send(m1);
@@ -362,10 +363,10 @@
ClientSession clientSession2 = sessionFactory.createSession(false, true, true);
ClientProducer clientProducer = clientSession2.createProducer(atestq);
- ClientMessage m1 = createTextMessage(clientSession2, "m1");
- ClientMessage m2 = createTextMessage(clientSession2, "m2");
- ClientMessage m3 = createTextMessage(clientSession2, "m3");
- ClientMessage m4 = createTextMessage(clientSession2, "m4");
+ ClientMessage m1 = CreateMessage.createTextMessage(clientSession2, "m1", true);
+ ClientMessage m2 = CreateMessage.createTextMessage(clientSession2, "m2", true);
+ ClientMessage m3 = CreateMessage.createTextMessage(clientSession2, "m3", true);
+ ClientMessage m4 = CreateMessage.createTextMessage(clientSession2, "m4", true);
clientProducer.send(m1);
clientProducer.send(m2);
clientProducer.send(m3);
@@ -414,7 +415,7 @@
ClientProducer clientProducer = clientSession2.createProducer(atestq);
for (int i = 0; i < numSessions; i++)
{
- clientProducer.send(createTextMessage(clientSession2, "m" + i));
+ clientProducer.send(CreateMessage.createTextMessage(clientSession2, "m" + i, true));
}
ClientSession[] clientSessions = new ClientSession[numSessions];
ClientConsumer[] clientConsumers = new ClientConsumer[numSessions];
@@ -684,8 +685,8 @@
for (int i = 0; i < 100; i++)
{
- prodA.send(createTextMessage(sessionA, "A" + i));
- prodB.send(createTextMessage(sessionB, "B" + i));
+ prodA.send(CreateMessage.createTextMessage(sessionA, "A" + i, true));
+ prodB.send(CreateMessage.createTextMessage(sessionB, "B" + i, true));
}
sessionA.end(xid, XAResource.TMSUCCESS);
@@ -774,7 +775,7 @@
ClientProducer prod = session.createProducer(ADDRESS);
for (int nmsg = 0; nmsg < NUMBER_OF_MSGS; nmsg++)
{
- ClientMessage msg = createTextMessage(session, "SimpleMessage" + nmsg);
+ ClientMessage msg = CreateMessage.createTextMessage(session, "SimpleMessage" + nmsg, true);
prod.send(msg);
}
@@ -784,7 +785,7 @@
session.start(xid, XAResource.TMRESUME);
}
- prod.send(createTextMessage(session, "one more"));
+ prod.send(CreateMessage.createTextMessage(session, "one more", true));
prod.close();
@@ -801,7 +802,7 @@
// The Join Session will have its own queue, as it's not possible to guarantee ordering since this
// producer will be using a different session
ClientProducer newProd = newJoinSession.createProducer(ADDRESS.concat("-join"));
- newProd.send(createTextMessage(newJoinSession, "After Join"));
+ newProd.send(CreateMessage.createTextMessage(newJoinSession, "After Join", true));
}
session.end(xid, XAResource.TMSUCCESS);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/XaTimeoutTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/XaTimeoutTest.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/XaTimeoutTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -40,6 +40,7 @@
import org.hornetq.core.transaction.Transaction;
import org.hornetq.core.transaction.TransactionOperation;
import org.hornetq.core.transaction.impl.XidImpl;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.UUIDGenerator;
@@ -131,10 +132,10 @@
{
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientMessage m1 = createTextMessage("m1", clientSession);
- ClientMessage m2 = createTextMessage("m2", clientSession);
- ClientMessage m3 = createTextMessage("m3", clientSession);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
clientSession.setTransactionTimeout(1);
clientSession.start(xid, XAResource.TMNOFLAGS);
clientProducer.send(m1);
@@ -162,10 +163,10 @@
{
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientMessage m1 = createTextMessage("m1", clientSession);
- ClientMessage m2 = createTextMessage("m2", clientSession);
- ClientMessage m3 = createTextMessage("m3", clientSession);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
ClientSession clientSession2 = sessionFactory.createSession(false, true, true);
ClientProducer clientProducer2 = clientSession2.createProducer(atestq);
clientProducer2.send(m1);
@@ -232,14 +233,14 @@
{
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientMessage m1 = createTextMessage("m1", clientSession);
- ClientMessage m2 = createTextMessage("m2", clientSession);
- ClientMessage m3 = createTextMessage("m3", clientSession);
- ClientMessage m4 = createTextMessage("m4", clientSession);
- ClientMessage m5 = createTextMessage("m5", clientSession);
- ClientMessage m6 = createTextMessage("m6", clientSession);
- ClientMessage m7 = createTextMessage("m7", clientSession);
- ClientMessage m8 = createTextMessage("m8", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
+ ClientMessage m7 = CreateMessage.createTextMessage("m7", clientSession);
+ ClientMessage m8 = CreateMessage.createTextMessage("m8", clientSession);
ClientSession clientSession2 = sessionFactory.createSession(false, true, true);
ClientProducer clientProducer2 = clientSession2.createProducer(atestq);
clientProducer2.send(m1);
@@ -312,14 +313,14 @@
{
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientMessage m1 = createTextMessage("m1", clientSession);
- ClientMessage m2 = createTextMessage("m2", clientSession);
- ClientMessage m3 = createTextMessage("m3", clientSession);
- ClientMessage m4 = createTextMessage("m4", clientSession);
- ClientMessage m5 = createTextMessage("m5", clientSession);
- ClientMessage m6 = createTextMessage("m6", clientSession);
- ClientMessage m7 = createTextMessage("m7", clientSession);
- ClientMessage m8 = createTextMessage("m8", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
+ ClientMessage m5 = CreateMessage.createTextMessage("m5", clientSession);
+ ClientMessage m6 = CreateMessage.createTextMessage("m6", clientSession);
+ ClientMessage m7 = CreateMessage.createTextMessage("m7", clientSession);
+ ClientMessage m8 = CreateMessage.createTextMessage("m8", clientSession);
ClientSession clientSession2 = sessionFactory.createSession(false, true, true);
ClientProducer clientProducer2 = clientSession2.createProducer(atestq);
clientProducer2.send(m1);
@@ -387,10 +388,10 @@
{
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientMessage m1 = createTextMessage("m1", clientSession);
- ClientMessage m2 = createTextMessage("m2", clientSession);
- ClientMessage m3 = createTextMessage("m3", clientSession);
- ClientMessage m4 = createTextMessage("m4", clientSession);
+ ClientMessage m1 = CreateMessage.createTextMessage("m1", clientSession);
+ ClientMessage m2 = CreateMessage.createTextMessage("m2", clientSession);
+ ClientMessage m3 = CreateMessage.createTextMessage("m3", clientSession);
+ ClientMessage m4 = CreateMessage.createTextMessage("m4", clientSession);
clientSession.start(xid, XAResource.TMNOFLAGS);
clientProducer.send(m1);
clientProducer.send(m2);
@@ -455,7 +456,7 @@
for (int i = 0; i < messages.length; i++)
{
- messages[i] = createTextMessage("m" + i, clientSession);
+ messages[i] = CreateMessage.createTextMessage("m" + i, clientSession);
}
for (int i = 0; i < clientSessions.length; i++)
{
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-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -28,6 +28,7 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.CreateMessage;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -84,7 +85,7 @@
ClientProducer prod = session.createProducer(address);
- ClientMessage message = createBytesMessage(session, new byte[700], true);
+ ClientMessage message = CreateMessage.createBytesMessage(session, 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 = CreateMessage.createBytesMessage(session, new byte[700], false);
int NUMBER_OF_MESSAGES = 60000;
Added: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/CreateMessage.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/CreateMessage.java (rev 0)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/CreateMessage.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -0,0 +1,50 @@
+package org.hornetq.tests.util;
+
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.jms.client.HornetQBytesMessage;
+import org.hornetq.jms.client.HornetQTextMessage;
+
+public final class CreateMessage
+{
+
+ private CreateMessage()
+ {
+ // Utility class
+ }
+
+ public static ClientMessage createTextMessage(final String s, final ClientSession clientSession)
+ {
+ ClientMessage message = clientSession.createMessage(HornetQTextMessage.TYPE,
+ true,
+ 0,
+ System.currentTimeMillis(),
+ (byte)4);
+ message.getBodyBuffer().writeString(s);
+ return message;
+ }
+
+ public static
+ 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;
+ }
+
+ public static ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable)
+ {
+ ClientMessage message = session.createMessage(HornetQTextMessage.TYPE,
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
+ message.getBodyBuffer().writeString(s);
+ return message;
+ }
+
+}
Modified: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/RandomUtil.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -25,11 +25,11 @@
/**
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
+ *
* @version <tt>$Revision$</tt>
- *
+ *
*/
-public class RandomUtil
+public final class RandomUtil
{
// Constants -----------------------------------------------------
@@ -73,8 +73,8 @@
{
return Math.abs(RandomUtil.randomInt());
}
-
+
public static HornetQBuffer randomBuffer(final int size, final long... data)
{
HornetQBuffer buffer = HornetQBuffers.fixedBuffer(size + 8 * data.length);
@@ -86,29 +86,29 @@
for (int i = 0 ; i < size; i++)
{
- buffer.writeByte((byte)randomByte());
+ buffer.writeByte(randomByte());
}
return buffer;
}
-
-
+
+
public static int randomInterval(final int min, final int max)
{
return min + randomMax(max - min);
}
-
- public static int randomMax(int max)
+
+ public static int randomMax(final int max)
{
int value = randomPositiveInt() % max;
-
+
if (value == 0)
{
value = max;
}
-
+
return value;
}
Modified: 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-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -44,8 +44,6 @@
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.jms.client.HornetQTextMessage;
import org.hornetq.spi.core.security.HornetQSecurityManager;
import org.hornetq.spi.core.security.HornetQSecurityManagerImpl;
@@ -454,42 +452,15 @@
}
- protected ClientMessage createTextMessage(final ClientSession session, final String s)
- {
- return createTextMessage(session, s, true);
- }
-
public String getTextMessage(final ClientMessage m)
{
m.getBodyBuffer().resetReaderIndex();
return m.getBodyBuffer().readString();
}
- protected ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable)
- {
- ClientMessage message = session.createMessage(HornetQTextMessage.TYPE,
- durable,
- 0,
- System.currentTimeMillis(),
- (byte)1);
- message.getBodyBuffer().writeString(s);
- return message;
- }
-
- 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;
- }
-
/**
- * 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
+ * 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
{
Modified: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-06-17 15:48:01 UTC (rev 10846)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-06-17 15:50:19 UTC (rev 10847)
@@ -51,8 +51,6 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.ClientMessage;
-import org.hornetq.api.core.client.ClientSession;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.client.impl.ServerLocatorImpl;
import org.hornetq.core.config.Configuration;
@@ -77,7 +75,6 @@
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
import org.hornetq.core.transaction.impl.XidImpl;
-import org.hornetq.jms.client.HornetQTextMessage;
import org.hornetq.utils.UUIDGenerator;
/**
@@ -919,7 +916,6 @@
Map<Thread, StackTraceElement[]> postThreads = Thread.getAllStackTraces();
- boolean failedThread = false;
if (postThreads.size() > previousThreads.size())
{
StringBuffer buffer = new StringBuffer();
@@ -932,7 +928,6 @@
{
if (!aliveThread.getName().contains("SunPKCS11") && !previousThreads.containsKey(aliveThread))
{
- failedThread = true;
buffer.append("=============================================================================\n");
buffer.append("Thread " + aliveThread + " is still alive with the following stackTrace:\n");
StackTraceElement[] elements = postThreads.get(aliveThread);
@@ -949,8 +944,6 @@
}
- //assertFalse("Thread Failed", failedThread);
-
super.tearDown();
}
@@ -1176,22 +1169,6 @@
return (size / alignment + (size % alignment != 0 ? 1 : 0)) * alignment;
}
- protected ClientMessage createTextMessage(final String s, final ClientSession clientSession)
- {
- return createTextMessage(s, true, clientSession);
- }
-
- protected ClientMessage createTextMessage(final String s, final boolean durable, final ClientSession clientSession)
- {
- ClientMessage message = clientSession.createMessage(HornetQTextMessage.TYPE,
- durable,
- 0,
- System.currentTimeMillis(),
- (byte)4);
- message.getBodyBuffer().writeString(s);
- return message;
- }
-
protected XidImpl newXID()
{
return new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
13 years, 6 months
JBoss hornetq SVN: r10846 - trunk/hornetq-core/src/main/java/org/hornetq/core/config.
by do-not-reply@jboss.org
Author: borges
Date: 2011-06-17 11:48:01 -0400 (Fri, 17 Jun 2011)
New Revision: 10846
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/config/Configuration.java
Log:
Fix javadoc issues.
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/config/Configuration.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/config/Configuration.java 2011-06-17 15:47:32 UTC (rev 10845)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/config/Configuration.java 2011-06-17 15:48:01 UTC (rev 10846)
@@ -29,21 +29,19 @@
import org.hornetq.spi.core.logging.LogDelegateFactory;
/**
- *
* A Configuration is used to configure HornetQ servers.
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
*/
public interface Configuration extends Serializable
{
// General attributes -------------------------------------------------------------------
- /** To be used on dependency management on the application server */
+ /** To be used on dependency management on the application server. */
String getName();
- /** To be used on dependency management on the application server */
+ /** To be used on dependency management on the application server. */
void setName(String name);
/**
@@ -59,13 +57,14 @@
void setClustered(boolean clustered);
/**
- * returns whether a backup will auto die when a live server is failing back
+ * Returns whether a backup will auto die when a live server is failing back.
+ *
* @return
*/
public boolean isAllowAutoFailBack();
/**
- * whether a backup will auto die when a live server is failing back
+ * Whether a backup will auto die when a live server is failing back.
*
* @param allowAutoFailBack true if allowed
*/
@@ -279,13 +278,14 @@
void setConnectorConfigurations(Map<String, TransportConfiguration> infos);
/**
- * Returns the name of the connector used to connect to the live node - only used when using shared nothing (shared store = false).
- * <br>
+ * Returns the name of the connector used to connect to the live node - only used when using
+ * shared nothing (shared store = false).
*/
String getLiveConnectorName();
/**
- * Sets the name of the connector used to connect to the live node - only used when using shared nothing (shared store = false).
+ * Sets the name of the connector used to connect to the live node - only used when using shared
+ * nothing (shared store = false).
*/
void setLiveConnectorName(String name);
@@ -864,13 +864,13 @@
*/
List<ConnectorServiceConfiguration> getConnectorServiceConfigurations();
- /*
- * how long to wait before failback occurs on restart
- * */
+ /**
+ * How long to wait before failback occurs on restart.
+ */
long getFailbackDelay();
- /*
- * set the failback delay
- * */
+ /**
+ * Set the failback delay.
+ */
void setFailbackDelay(long delay);
}
13 years, 6 months
JBoss hornetq SVN: r10845 - trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-06-17 11:47:32 -0400 (Fri, 17 Jun 2011)
New Revision: 10845
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
Remove unused imports and dead code.
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-06-17 15:47:00 UTC (rev 10844)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-06-17 15:47:32 UTC (rev 10845)
@@ -63,13 +63,11 @@
import org.hornetq.core.paging.impl.PagingManagerImpl;
import org.hornetq.core.paging.impl.PagingStoreFactoryNIO;
import org.hornetq.core.persistence.GroupingInfo;
-import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.QueueBindingInfo;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.persistence.config.PersistedAddressSetting;
import org.hornetq.core.persistence.config.PersistedRoles;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.persistence.impl.nullpm.NullStorageManager;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.DuplicateIDCache;
@@ -1181,7 +1179,7 @@
{
return new PagingManagerImpl(new PagingStoreFactoryNIO(configuration.getPagingDirectory(),
- (long)configuration.getJournalBufferSize_NIO(),
+ configuration.getJournalBufferSize_NIO(),
scheduledPool,
executorFactory,
configuration.isJournalSyncNonTransactional()),
@@ -1281,14 +1279,6 @@
return true;
}
- private class FileActivateRunner implements Runnable
- {
- public void run()
- {
-
- }
- }
-
private void initialiseLogging()
{
LogDelegateFactory logDelegateFactory = (LogDelegateFactory)instantiateInstance(configuration.getLogDelegateFactoryClassName());
@@ -1907,6 +1897,7 @@
}
}
+ @Override
public String toString()
{
return "HornetQServerImpl::" + (identity == null ? "" : (identity + ", ")) + (nodeManager != null ? ("serverUUID=" + nodeManager.getUUID()) : "");
13 years, 6 months
JBoss hornetq SVN: r10844 - trunk/etc.
by do-not-reply@jboss.org
Author: borges
Date: 2011-06-17 11:47:00 -0400 (Fri, 17 Jun 2011)
New Revision: 10844
Modified:
trunk/etc/org.eclipse.jdt.core.prefs
Log:
Adjust Eclipse formatting settings to achieve line wrapping.
Modified: trunk/etc/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/etc/org.eclipse.jdt.core.prefs 2011-06-17 13:09:57 UTC (rev 10843)
+++ trunk/etc/org.eclipse.jdt.core.prefs 2011-06-17 15:47:00 UTC (rev 10844)
@@ -1,4 +1,4 @@
-#Thu May 26 18:16:51 CEST 2011
+#Fri Jun 17 11:54:22 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -22,20 +22,20 @@
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=82
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=82
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=82
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=82
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=80
-org.eclipse.jdt.core.formatter.alignment_for_assignment=32
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=82
+org.eclipse.jdt.core.formatter.alignment_for_assignment=16
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=82
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=82
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=18
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=82
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=82
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=32
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=82
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=82
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=82
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
@@ -80,6 +80,7 @@
org.eclipse.jdt.core.formatter.comment.line_length=100
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=3
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=3
@@ -99,9 +100,13 @@
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=3
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
@@ -285,7 +290,7 @@
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=3
-org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=false
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
13 years, 6 months
JBoss hornetq SVN: r10843 - tags.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-06-17 09:09:57 -0400 (Fri, 17 Jun 2011)
New Revision: 10843
Added:
tags/HornetQ_2_2_5_Final_pending/
Log:
pending release for 2.2.5.Final
13 years, 6 months
JBoss hornetq SVN: r10842 - tags.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-06-17 09:07:46 -0400 (Fri, 17 Jun 2011)
New Revision: 10842
Removed:
tags/HornetQ_2_2_5_Final_pending/
Log:
unneeded branch
13 years, 6 months